Add feature more gates for capture-spantrace (#70)

* Add feature more gates for capture-spantrace

When only the `issue-url` features is enabled, with the default
features being disabled, the crate fails to build

```
$ cargo build --no-default-features --features issue-url
   Compiling color-eyre v0.5.7-alpha.0 (/Users/paul/dev/color-eyre)
error[E0432]: unresolved import `tracing_error`
 --> src/section/github.rs:5:5
  |
5 | use tracing_error::SpanTrace;
  |     ^^^^^^^^^^^^^ use of undeclared type or module `tracing_error`

error[E0282]: type annotations needed
  --> src/section/github.rs:28:25
   |
28 |             span_trace: None,
   |                         ^^^^ cannot infer type for type parameter `T` declared on the enum `Option`

error: aborting due to 2 previous errors
```

This commit add feature gates for capture-spantrace to the github
issue module, so that the issue-url feature can be used standalone.

* ignore broken doctest and add new ci configs

* make the ci configs differentiable

Co-authored-by: Jane Lusby <jlusby@yaah.dev>
This commit is contained in:
Paul Horn 2020-11-06 01:24:05 +01:00 committed by GitHub
parent dd2103291a
commit 030dc5a547
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 4 deletions

View File

@ -25,7 +25,7 @@ jobs:
command: check
test-features:
name: Test Suite
name: Test Features
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
@ -44,9 +44,21 @@ jobs:
with:
command: test
args: --no-default-features
- uses: actions-rs/cargo@v1
with:
command: test
args: --no-default-features --features issue-url
- uses: actions-rs/cargo@v1
with:
command: test
args: --no-default-features --features track-caller
- uses: actions-rs/cargo@v1
with:
command: test
args: --no-default-features --features capture-spantrace
test-versions:
name: Test Suite
name: Test Versions
runs-on: ubuntu-latest
strategy:
matrix:
@ -78,7 +90,7 @@ jobs:
if: ${{ matrix.target == 'wasm32-unknown-unknown' }}
test-os:
name: Test Suite
name: Test Operating Systems
runs-on: ${{ matrix.os }}
strategy:
matrix:

View File

@ -1,6 +1,7 @@
use crate::writers::DisplayExt;
use backtrace::Backtrace;
use std::{fmt, panic::Location};
#[cfg(feature = "capture-spantrace")]
use tracing_error::SpanTrace;
use url::Url;
@ -11,6 +12,7 @@ pub(crate) struct IssueSection<'a> {
msg: &'a str,
location: Option<&'a Location<'a>>,
backtrace: Option<&'a Backtrace>,
#[cfg(feature = "capture-spantrace")]
span_trace: Option<&'a SpanTrace>,
metadata: &'a [(String, Display<'a>)],
}
@ -22,6 +24,7 @@ impl<'a> IssueSection<'a> {
msg,
location: None,
backtrace: None,
#[cfg(feature = "capture-spantrace")]
span_trace: None,
metadata: &[],
}
@ -37,6 +40,7 @@ impl<'a> IssueSection<'a> {
self
}
#[cfg(feature = "capture-spantrace")]
pub(crate) fn with_span_trace(mut self, span_trace: impl Into<Option<&'a SpanTrace>>) -> Self {
self.span_trace = span_trace.into();
self
@ -62,6 +66,7 @@ impl fmt::Display for IssueSection<'_> {
body.push_section("Metadata", metadata)?;
}
#[cfg(feature = "capture-spantrace")]
if let Some(st) = self.span_trace {
body.push_section(
"SpanTrace",

View File

@ -86,7 +86,7 @@ pub trait SectionExt: Sized {
///
/// # Examples
///
/// ```rust
/// ```rust,no_run
/// use color_eyre::{eyre::eyre, Help, SectionExt, eyre::Report};
///
/// let all_in_header = "header\n body\n body";