Skip to content
Myr

Merge pull request 293 from LukasKalbertodt/use-stable-backtrace

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Tolnay · committed by David Tolnay · parents 43f4af0, ad30865 · Browse files · 3 files+10 added−21 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+10 added−21 removed

  • other:+10 added−21 removed

3 files+10 added−21 removed

modified:src/error.rs+2 added-6 removed
361 unmodified lines
362 /// `RUST_LIB_BACKTRACE=0`.363 ///364 /// # Stability365 ///366 /// Standard library backtraces are only available on the nightly channel.367 /// Tracking issue: [rust-lang/rust#53487][tracking].368 ///369 /// On stable compilers, this function is only available if the crate's366 /// Standard library backtraces are only available when using Rust ≥ 1.65.367 /// On older compilers, this function is only available if the crate's368 /// "backtrace" feature is enabled, and will use the `backtrace` crate as369 /// the underlying backtrace implementation.370 ///371 /// ```toml372 /// [dependencies]373 /// anyhow = { version = "1.0", features = ["backtrace"] }374 /// ```377 ///378 /// [tracking]: https://github.com/rust-lang/rust/issues/53487375 #[cfg(any(std_backtrace, feature = "backtrace"))]376 #[cfg_attr(doc_cfg, doc(cfg(any(nightly, feature = "backtrace"))))]377 pub fn backtrace(&self) -> &impl_backtrace!() {378 unsafe { ErrorImpl::backtrace(self.inner.by_ref()) }
646 unmodified lines
modified:src/lib.rs+4 added-8 removed
126 unmodified lines
127//! }128//! # ;129//! ```130//!131//! - If using the nightly channel, or stable with `features = ["backtrace"]`, a132//! backtrace is captured and printed with the error if the underlying error133//! type does not already provide its own. In order to see backtraces, they134//! must be enabled through the environment variables described in135//! [`std::backtrace`]:131//! - If using Rust ≥ 1.65 or `features = ["backtrace"]`, a backtrace is captured132//! and printed with the error if the underlying error type does not already133//! provide its own. In order to see backtraces, they must be enabled through the134//! environment variables described in [`std::backtrace`]:135//!136//! - If you want panics and errors to both have backtraces, set137//! `RUST_BACKTRACE=1`;138//! - If you want only errors to have backtraces, set `RUST_LIB_BACKTRACE=1`;139//! - If you want only panics to have backtraces, set `RUST_BACKTRACE=1` and140//! `RUST_LIB_BACKTRACE=0`.141//!143//! The tracking issue for this feature is [rust-lang/rust#53487].144//!142//! [`std::backtrace`]: https://doc.rust-lang.org/std/backtrace/index.html#environment-variables146//! [rust-lang/rust#53487]: https://github.com/rust-lang/rust/issues/53487143//!144//! - Anyhow works with any error type that has an impl of `std::error::Error`,145//! including ones defined in your crate. We do not bundle a `derive(Error)`146//! macro but you can write the impls yourself or use a standalone macro like
545 unmodified lines
modified:README.md+4 added-7 removed