Skip to content

Commit 97dfbd7

Browse files
committed
Use unstable backtrace feature
This replaces the backtrace crate and removes quite a few recursive dependencies. There was a proposal to stabilize backtrace, but it was decided that it is better to wait until the interface with the Error trait is decided. See rust-lang/rust#72981
1 parent f163fdd commit 97dfbd7

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

ext/crates/error/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,3 @@ authors = ["Dexter Chua <[email protected]>"]
55
edition = "2018"
66

77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8-
9-
[dependencies]
10-
backtrace = "0.3"

ext/crates/error/src/lib.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
#![feature(backtrace)]
12
use std::error::Error as StdError;
3+
use std::backtrace::Backtrace;
24

35
pub type Result<T> = std::result::Result<T, Error>;
46

57
#[derive(Debug)]
68
pub struct Error {
79
error: Box<dyn StdError + Send + Sync + 'static>,
8-
backtrace: backtrace::Backtrace,
10+
backtrace: Backtrace,
911
}
1012

1113
impl Error {
@@ -16,7 +18,7 @@ impl Error {
1618
impl std::fmt::Display for Error {
1719
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1820
writeln!(f, "{}", self.error)?;
19-
writeln!(f, "{:?}", self.backtrace)?;
21+
writeln!(f, "{}", self.backtrace)?;
2022
Ok(())
2123
}
2224
}
@@ -25,7 +27,7 @@ impl<E: StdError + Send + Sync + 'static> From<E> for Error {
2527
fn from(error: E) -> Error {
2628
Self {
2729
error: Box::new(error),
28-
backtrace: backtrace::Backtrace::new(),
30+
backtrace: Backtrace::capture(),
2931
}
3032
}
3133
}

0 commit comments

Comments
 (0)