Skip to content
This repository was archived by the owner on Aug 16, 2021. It is now read-only.

Split backtrace and std features up. #128

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ cache: cargo
script:
- cargo test
- cargo test --no-default-features
- cargo test --no-default-features --features std
- cargo test --no-default-features --features backtrace
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ optional = true
version = "0.3.3"

[features]
default = ["std", "derive"]
std = ["backtrace"]
default = ["std", "derive", "backtrace"]
std = []
derive = ["failure_derive"]

[[example]]
Expand Down
14 changes: 12 additions & 2 deletions src/backtrace/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use core::fmt::{self, Debug, Display};

without_std! {
without_backtrace! {
/// A `Backtrace`.
///
/// This is an opaque wrapper around the backtrace provided by
Expand Down Expand Up @@ -39,6 +39,16 @@ without_std! {
pub fn new() -> Backtrace {
Backtrace { _secret: () }
}

#[cfg(feature = "std")]
pub(crate) fn none() -> Backtrace {
Backtrace { _secret: () }
}

#[cfg(feature = "std")]
pub(crate) fn is_none(&self) -> bool {
true
}
}

impl Default for Backtrace {
Expand All @@ -60,7 +70,7 @@ without_std! {
}
}

with_std! {
with_backtrace! {
extern crate backtrace;

mod internal;
Expand Down
6 changes: 6 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@

macro_rules! with_std { ($($i:item)*) => ($(#[cfg(feature = "std")]$i)*) }
macro_rules! without_std { ($($i:item)*) => ($(#[cfg(not(feature = "std"))]$i)*) }
macro_rules! with_backtrace {
($($i:item)*) => ($(#[cfg(all(feature = "backtrace", feature = "std"))]$i)*)
}
macro_rules! without_backtrace {
($($i:item)*) => ($(#[cfg(any(not(feature = "backtrace"), not(feature = "std")))]$i)*)
}

mod backtrace;
mod compat;
Expand Down