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 command: check
test-features: test-features:
name: Test Suite name: Test Features
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v1
@ -44,9 +44,21 @@ jobs:
with: with:
command: test command: test
args: --no-default-features 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: test-versions:
name: Test Suite name: Test Versions
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
@ -78,7 +90,7 @@ jobs:
if: ${{ matrix.target == 'wasm32-unknown-unknown' }} if: ${{ matrix.target == 'wasm32-unknown-unknown' }}
test-os: test-os:
name: Test Suite name: Test Operating Systems
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
strategy: strategy:
matrix: matrix:

View File

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

View File

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