Open hellow554 opened 2 years ago
Could this be related to @shepmaster's recent changes in #306? To the best of my knowledge, SNAFU does not take advantage of #[track_caller]
yet, and I imagine that there could be some more tricks in this pull request.
Hmm, I don't have a great answer to the why, but the good news is that soon this will become moot:
use snafu::prelude::*;
#[derive(Debug, Snafu)]
struct NeatError {
backtrace: snafu::Backtrace,
}
fn main() {
println!("{}", NeatSnafu.build().backtrace);
}
features = ["backtraces"]
0 backtrace::backtrace::libunwind::trace::hccd7e83906acb689
/Users/shep/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.66/src/backtrace/libunwind.rs:93
backtrace::backtrace::trace_unsynchronized::h32cdfaf0744a9709
/Users/shep/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.66/src/backtrace/mod.rs:66
1 backtrace::backtrace::trace::h0f26207a195201cc
/Users/shep/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.66/src/backtrace/mod.rs:53
2 backtrace::capture::Backtrace::create::hb02d7ef832adfdad
/Users/shep/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.66/src/capture.rs:176
3 backtrace::capture::Backtrace::new::hb97f424b0533f138
/Users/shep/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.66/src/capture.rs:140
4 <snafu::backtrace_shim::Backtrace as snafu::GenerateImplicitData>::generate::hdd9a23f449cedb9a
/Users/shep/Projects/snafu/src/backtrace_shim.rs:15
bt_example::NeatSnafu::build::hbea4ca5e0aafdd0a
/private/tmp/bt-example/src/main.rs:3
5 bt_example::main::hacce18dfcbd76c8a
/private/tmp/bt-example/src/main.rs:9
6 core::ops::function::FnOnce::call_once::h74f7fb924d26a014
/rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/ops/function.rs:248
7 std::sys_common::backtrace::__rust_begin_short_backtrace::he57537c4ce6a66de
/rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/sys_common/backtrace.rs:122
8 std::rt::lang_start::{{closure}}::ha4bb6f22b59e222f
/rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/rt.rs:145
9 core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h7cd8ae72620b0d1f
/rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/ops/function.rs:280
std::panicking::try::do_call::h0bbb0f423dd9d86c
/rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/panicking.rs:492
std::panicking::try::hdaabe7e5908702af
/rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/panicking.rs:456
std::panic::catch_unwind::h7ee653eae81d0a43
/rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/panic.rs:137
std::rt::lang_start_internal::{{closure}}::he727754da11a45c1
/rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/rt.rs:128
std::panicking::try::do_call::h0171064c04d908b7
/rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/panicking.rs:492
std::panicking::try::h9c521838fe914345
/rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/panicking.rs:456
std::panic::catch_unwind::hac847f960377a9be
/rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/panic.rs:137
std::rt::lang_start_internal::hef2161f9571a51d7
/rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/rt.rs:128
10 std::rt::lang_start::hade2d0e3fc9aeef5
/rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/rt.rs:144
11 _main
features = ["backtraces", "backtraces-impl-std"]
(with Rust 1.65)
0: std::backtrace_rs::backtrace::libunwind::trace
at /rustc/2a65764f21cf10b7e03c645f1ad0946e42758e0a/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
1: std::backtrace_rs::backtrace::trace_unsynchronized
at /rustc/2a65764f21cf10b7e03c645f1ad0946e42758e0a/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: std::backtrace::Backtrace::create
at /rustc/2a65764f21cf10b7e03c645f1ad0946e42758e0a/library/std/src/backtrace.rs:333:13
3: <std::backtrace::Backtrace as snafu::GenerateImplicitData>::generate
at /Users/shep/Projects/snafu/src/lib.rs:1256:9
4: bt_example::NeatSnafu::build
at ./src/main.rs:3:17
5: bt_example::main
at ./src/main.rs:9:20
6: core::ops::function::FnOnce::call_once
at /rustc/2a65764f21cf10b7e03c645f1ad0946e42758e0a/library/core/src/ops/function.rs:248:5
7: std::sys_common::backtrace::__rust_begin_short_backtrace
at /rustc/2a65764f21cf10b7e03c645f1ad0946e42758e0a/library/std/src/sys_common/backtrace.rs:122:18
8: std::rt::lang_start::{{closure}}
at /rustc/2a65764f21cf10b7e03c645f1ad0946e42758e0a/library/std/src/rt.rs:166:18
9: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once
at /rustc/2a65764f21cf10b7e03c645f1ad0946e42758e0a/library/core/src/ops/function.rs:283:13
10: std::panicking::try::do_call
at /rustc/2a65764f21cf10b7e03c645f1ad0946e42758e0a/library/std/src/panicking.rs:492:40
11: std::panicking::try
at /rustc/2a65764f21cf10b7e03c645f1ad0946e42758e0a/library/std/src/panicking.rs:456:19
12: std::panic::catch_unwind
at /rustc/2a65764f21cf10b7e03c645f1ad0946e42758e0a/library/std/src/panic.rs:137:14
13: std::rt::lang_start_internal::{{closure}}
at /rustc/2a65764f21cf10b7e03c645f1ad0946e42758e0a/library/std/src/rt.rs:148:48
14: std::panicking::try::do_call
at /rustc/2a65764f21cf10b7e03c645f1ad0946e42758e0a/library/std/src/panicking.rs:492:40
15: std::panicking::try
at /rustc/2a65764f21cf10b7e03c645f1ad0946e42758e0a/library/std/src/panicking.rs:456:19
16: std::panic::catch_unwind
at /rustc/2a65764f21cf10b7e03c645f1ad0946e42758e0a/library/std/src/panic.rs:137:14
17: std::rt::lang_start_internal
at /rustc/2a65764f21cf10b7e03c645f1ad0946e42758e0a/library/std/src/rt.rs:148:20
18: std::rt::lang_start
at /rustc/2a65764f21cf10b7e03c645f1ad0946e42758e0a/library/std/src/rt.rs:165:17
19: _main
Currently, if I compare the output of backtrace-rs and snafu, they differ in readability and verbosity:
Backtrace-rs:
Snafu:
What I precisly want to change is that after the function should be removed and the paths should be relative to project root, not the filesystem:
currently:
wanted:
Since you're using the backtrace backend I don't see why it behaves like it does, but maybe you could shine a light on this.
In addition (but I doubt that will happen soon) is to reduce the backtrace to the relevant part, e.g. I don't want first two frames to appear (and maybe the last few, that are part of
_start_lang
)