Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(libp2p-swarm-test): Add #[track_caller] to SwarmExt methods #5567

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ark0f
Copy link

@ark0f ark0f commented Aug 21, 2024

Description

Add #[track_caller] to SwarmExt methods so we can know exactly where panic occurs

Notes & open questions

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • A changelog entry has been made in the appropriate crates

@jxs
Copy link
Member

jxs commented Aug 22, 2024

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

@ark0f
Copy link
Author

ark0f commented Aug 23, 2024

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. inside fn main()) by default.
  • If you omit #[track_caller], it will print called from src/main.rs:5:32 (e.g. inside fn 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.

@jxs
Copy link
Member

jxs commented Aug 28, 2024

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. inside fn main()) by default.
  • If you omit #[track_caller], it will print called from src/main.rs:5:32 (e.g. inside fn 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.

yeah but that is also achievable setting RUST_BACKTRACE=1 right?
The reason I also asked for the stack trace is because rust-lang/rust#87417 and rust-lang/rust#110011 so it seems this won't work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants