File tree 4 files changed +16
-12
lines changed
4 files changed +16
-12
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,10 @@ default = ["std"]
16
16
std = []
17
17
18
18
[dependencies ]
19
+ # On compilers older than 1.65, features=["backtrace"] may be used to enable
20
+ # backtraces via the `backtrace` crate. This feature has no effect on 1.65+
21
+ # besides bringing in an unused dependency, as `std::backtrace` is always
22
+ # preferred.
19
23
backtrace = { version = " 0.3.51" , optional = true }
20
24
21
25
[dev-dependencies ]
Original file line number Diff line number Diff line change @@ -75,10 +75,10 @@ anyhow = "1.0"
75
75
}
76
76
```
77
77
78
- - If using Rust ≥ 1.65 or ` features = ["backtrace"] ` , a backtrace is captured
79
- and printed with the error if the underlying error type does not already
80
- provide its own. In order to see backtraces, they must be enabled through the
81
- environment variables described in [ ` std::backtrace ` ] :
78
+ - If using Rust & ge ; 1.65, a backtrace is captured and printed with the error if
79
+ the underlying error type does not already provide its own. In order to see
80
+ backtraces, they must be enabled through the environment variables described
81
+ in [ ` std::backtrace ` ] :
82
82
83
83
- If you want panics and errors to both have backtraces, set
84
84
` RUST_BACKTRACE=1 ` ;
Original file line number Diff line number Diff line change @@ -363,17 +363,17 @@ impl Error {
363
363
///
364
364
/// # Stability
365
365
///
366
- /// Standard library backtraces are only available when using Rust ≥ 1.65.
367
- /// On older compilers, this function is only available if the crate's
366
+ /// Standard library backtraces are only available when using Rust ≥
367
+ /// 1.65. On older compilers, this function is only available if the crate's
368
368
/// "backtrace" feature is enabled, and will use the `backtrace` crate as
369
- /// the underlying backtrace implementation.
369
+ /// the underlying backtrace implementation. The return type of this
370
+ /// function on old compilers is `&(impl Debug + Display)`.
370
371
///
371
372
/// ```toml
372
373
/// [dependencies]
373
374
/// anyhow = { version = "1.0", features = ["backtrace"] }
374
375
/// ```
375
376
#[ cfg( any( std_backtrace, feature = "backtrace" ) ) ]
376
- #[ cfg_attr( doc_cfg, doc( cfg( any( nightly, feature = "backtrace" ) ) ) ) ]
377
377
pub fn backtrace ( & self ) -> & impl_backtrace ! ( ) {
378
378
unsafe { ErrorImpl :: backtrace ( self . inner . by_ref ( ) ) }
379
379
}
Original file line number Diff line number Diff line change 128
128
//! # ;
129
129
//! ```
130
130
//!
131
- //! - If using Rust ≥ 1.65 or `features = ["backtrace"]` , a backtrace is captured
132
- //! and printed with the error if the underlying error type does not already
133
- //! provide its own. In order to see backtraces, they must be enabled through the
134
- //! environment variables described in [`std::backtrace`]:
131
+ //! - If using Rust ≥ 1.65, a backtrace is captured and printed with the
132
+ //! error if the underlying error type does not already provide its own. In
133
+ //! order to see backtraces, they must be enabled through the environment
134
+ //! variables described in [`std::backtrace`]:
135
135
//!
136
136
//! - If you want panics and errors to both have backtraces, set
137
137
//! `RUST_BACKTRACE=1`;
You can’t perform that action at this time.
0 commit comments