chore(libp2p-swarm-test): Add `#[track_caller]` to `SwarmExt` methods
Description
Add #[track_caller] to SwarmExt methods so we can know exactly where panic occurs
Notes & open questions
Change checklist
- [x] I have performed a self-review of my own code
- [x] I have made corresponding changes to the documentation
- [x] I have added tests that prove my fix is effective or that my feature works
- [x] A changelog entry has been made in the appropriate crates
Hi, afaiu this shouldn't be necessary as after Rust 1.42 panic! already do it. Can you elaborate why you think this needs to be added and give an example comparing the stack trace with and without these annotations?
Thanks
Hi.
as after Rust 1.42 panic! already do it.
The example says about the standard library.
The documentation also has minimal example:
- It prints
called from src/main.rs:9:5(e. g. insidefn main()) by default. - If you omit
#[track_caller], it will printcalled from src/main.rs:5:32(e.g. insidefn print_caller()).
So the same applies to SwarmExt methods. You just see a panic somewhere in libp2p-swarm-test crate but you don't see it in your tests without #[track_caller] attribute.
Hi.
as after Rust 1.42 panic! already do it.
The example says about the standard library.
The documentation also has minimal example:
- It prints
called from src/main.rs:9:5(e. g. insidefn main()) by default.- If you omit
#[track_caller], it will printcalled from src/main.rs:5:32(e.g. insidefn print_caller()).So the same applies to
SwarmExtmethods. You just see a panic somewhere inlibp2p-swarm-testcrate but you don't see it in your tests without#[track_caller]attribute.
yeah but that is also achievable setting RUST_BACKTRACE=1 right?
The reason I also asked for the stack trace is because https://github.com/rust-lang/rust/issues/87417 and https://github.com/rust-lang/rust/issues/110011 so it seems this won't work