Skip to content

Commit 53109e6

Browse files
authored
Merge pull request #332 from dtolnay/stdbacktrace
Rename `cfg(backtrace)` -> `cfg(std_backtrace)`
2 parents cf66194 + df47705 commit 53109e6

File tree

5 files changed

+24
-24
lines changed

5 files changed

+24
-24
lines changed

build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fn main() {
5151

5252
match compile_probe() {
5353
Some(status) if status.success() => {
54-
println!("cargo:rustc-cfg=backtrace");
54+
println!("cargo:rustc-cfg=std_backtrace");
5555
println!("cargo:rustc-cfg=error_generic_member_access");
5656
}
5757
_ => {}

src/backtrace.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
1-
#[cfg(backtrace)]
1+
#[cfg(std_backtrace)]
22
pub(crate) use std::backtrace::{Backtrace, BacktraceStatus};
33

4-
#[cfg(all(not(backtrace), feature = "backtrace"))]
4+
#[cfg(all(not(std_backtrace), feature = "backtrace"))]
55
pub(crate) use self::capture::{Backtrace, BacktraceStatus};
66

7-
#[cfg(not(any(backtrace, feature = "backtrace")))]
7+
#[cfg(not(any(std_backtrace, feature = "backtrace")))]
88
pub(crate) enum Backtrace {}
99

10-
#[cfg(backtrace)]
10+
#[cfg(std_backtrace)]
1111
macro_rules! impl_backtrace {
1212
() => {
1313
std::backtrace::Backtrace
1414
};
1515
}
1616

17-
#[cfg(all(not(backtrace), feature = "backtrace"))]
17+
#[cfg(all(not(std_backtrace), feature = "backtrace"))]
1818
macro_rules! impl_backtrace {
1919
() => {
2020
impl core::fmt::Debug + core::fmt::Display
2121
};
2222
}
2323

24-
#[cfg(any(backtrace, feature = "backtrace"))]
24+
#[cfg(any(std_backtrace, feature = "backtrace"))]
2525
macro_rules! backtrace {
2626
() => {
2727
Some(crate::backtrace::Backtrace::capture())
2828
};
2929
}
3030

31-
#[cfg(not(any(backtrace, feature = "backtrace")))]
31+
#[cfg(not(any(std_backtrace, feature = "backtrace")))]
3232
macro_rules! backtrace {
3333
() => {
3434
None
@@ -48,22 +48,22 @@ macro_rules! backtrace_if_absent {
4848
#[cfg(all(
4949
feature = "std",
5050
not(error_generic_member_access),
51-
any(backtrace, feature = "backtrace")
51+
any(std_backtrace, feature = "backtrace")
5252
))]
5353
macro_rules! backtrace_if_absent {
5454
($err:expr) => {
5555
backtrace!()
5656
};
5757
}
5858

59-
#[cfg(all(feature = "std", not(backtrace), not(feature = "backtrace")))]
59+
#[cfg(all(feature = "std", not(std_backtrace), not(feature = "backtrace")))]
6060
macro_rules! backtrace_if_absent {
6161
($err:expr) => {
6262
None
6363
};
6464
}
6565

66-
#[cfg(all(not(backtrace), feature = "backtrace"))]
66+
#[cfg(all(not(std_backtrace), feature = "backtrace"))]
6767
mod capture {
6868
use backtrace::{BacktraceFmt, BytesOrWideString, Frame, PrintFmt, SymbolName};
6969
use core::cell::UnsafeCell;

src/error.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl Error {
101101
object_drop_rest: object_drop_front::<E>,
102102
#[cfg(all(
103103
not(error_generic_member_access),
104-
any(backtrace, feature = "backtrace")
104+
any(std_backtrace, feature = "backtrace")
105105
))]
106106
object_backtrace: no_backtrace,
107107
};
@@ -129,7 +129,7 @@ impl Error {
129129
object_drop_rest: object_drop_front::<M>,
130130
#[cfg(all(
131131
not(error_generic_member_access),
132-
any(backtrace, feature = "backtrace")
132+
any(std_backtrace, feature = "backtrace")
133133
))]
134134
object_backtrace: no_backtrace,
135135
};
@@ -158,7 +158,7 @@ impl Error {
158158
object_drop_rest: object_drop_front::<M>,
159159
#[cfg(all(
160160
not(error_generic_member_access),
161-
any(backtrace, feature = "backtrace")
161+
any(std_backtrace, feature = "backtrace")
162162
))]
163163
object_backtrace: no_backtrace,
164164
};
@@ -189,7 +189,7 @@ impl Error {
189189
object_drop_rest: context_drop_rest::<C, E>,
190190
#[cfg(all(
191191
not(error_generic_member_access),
192-
any(backtrace, feature = "backtrace")
192+
any(std_backtrace, feature = "backtrace")
193193
))]
194194
object_backtrace: no_backtrace,
195195
};
@@ -218,7 +218,7 @@ impl Error {
218218
object_drop_rest: object_drop_front::<Box<dyn StdError + Send + Sync>>,
219219
#[cfg(all(
220220
not(error_generic_member_access),
221-
any(backtrace, feature = "backtrace")
221+
any(std_backtrace, feature = "backtrace")
222222
))]
223223
object_backtrace: no_backtrace,
224224
};
@@ -334,7 +334,7 @@ impl Error {
334334
object_drop_rest: context_chain_drop_rest::<C>,
335335
#[cfg(all(
336336
not(error_generic_member_access),
337-
any(backtrace, feature = "backtrace")
337+
any(std_backtrace, feature = "backtrace")
338338
))]
339339
object_backtrace: context_backtrace::<C>,
340340
};
@@ -376,7 +376,7 @@ impl Error {
376376
/// ```
377377
///
378378
/// [tracking]: https://github.com/rust-lang/rust/issues/53487
379-
#[cfg(any(backtrace, feature = "backtrace"))]
379+
#[cfg(any(std_backtrace, feature = "backtrace"))]
380380
#[cfg_attr(doc_cfg, doc(cfg(any(nightly, feature = "backtrace"))))]
381381
pub fn backtrace(&self) -> &impl_backtrace!() {
382382
unsafe { ErrorImpl::backtrace(self.inner.by_ref()) }
@@ -622,7 +622,7 @@ struct ErrorVTable {
622622
object_drop_rest: unsafe fn(Own<ErrorImpl>, TypeId),
623623
#[cfg(all(
624624
not(error_generic_member_access),
625-
any(backtrace, feature = "backtrace")
625+
any(std_backtrace, feature = "backtrace")
626626
))]
627627
object_backtrace: unsafe fn(Ref<ErrorImpl>) -> Option<&Backtrace>,
628628
}
@@ -730,7 +730,7 @@ where
730730

731731
#[cfg(all(
732732
not(error_generic_member_access),
733-
any(backtrace, feature = "backtrace")
733+
any(std_backtrace, feature = "backtrace")
734734
))]
735735
fn no_backtrace(e: Ref<ErrorImpl>) -> Option<&Backtrace> {
736736
let _ = e;
@@ -854,7 +854,7 @@ where
854854
// Safety: requires layout of *e to match ErrorImpl<ContextError<C, Error>>.
855855
#[cfg(all(
856856
not(error_generic_member_access),
857-
any(backtrace, feature = "backtrace")
857+
any(std_backtrace, feature = "backtrace")
858858
))]
859859
#[allow(clippy::unnecessary_wraps)]
860860
unsafe fn context_backtrace<C>(e: Ref<ErrorImpl>) -> Option<&Backtrace>
@@ -926,7 +926,7 @@ impl ErrorImpl {
926926
return unsafe { (vtable(this.ptr).object_mut)(this) };
927927
}
928928

929-
#[cfg(any(backtrace, feature = "backtrace"))]
929+
#[cfg(any(std_backtrace, feature = "backtrace"))]
930930
pub(crate) unsafe fn backtrace(this: Ref<Self>) -> &Backtrace {
931931
// This unwrap can only panic if the underlying error's backtrace method
932932
// is nondeterministic, which would only happen in maliciously

src/fmt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl ErrorImpl {
4040
}
4141
}
4242

43-
#[cfg(any(backtrace, feature = "backtrace"))]
43+
#[cfg(any(std_backtrace, feature = "backtrace"))]
4444
{
4545
use crate::backtrace::BacktraceStatus;
4646

tests/test_fmt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ fn test_altdisplay() {
7979
}
8080

8181
#[test]
82-
#[cfg_attr(not(backtrace), ignore)]
82+
#[cfg_attr(not(std_backtrace), ignore)]
8383
fn test_debug() {
8484
assert_eq!(EXPECTED_DEBUG_F, format!("{:?}", f().unwrap_err()));
8585
assert_eq!(EXPECTED_DEBUG_G, format!("{:?}", g().unwrap_err()));

0 commit comments

Comments
 (0)