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

expect(): Track caller #142

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

chrysn
Copy link

@chrysn chrysn commented Nov 26, 2024

The panic location printed by a panicking .expect() call is not helpful -- it points to subtle instead of the code that had the expectation.

I was lucky that the error message was usable in the message I got:

thread '<unnamed>' panicked at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/subtle-2.6.1/src/lib.rs:692:9:
assertion `left == right` failed: Public key is not a good point
  left: 0
 right: 1

but still had to look around a bit for where that came from precisely. With the annotation added in this PR, the compiler will make an effort to produce a more helpful location: the one expect()'s caller.

(Most other functions on this type are #[inline], and I don't know whether or not inline also has that effect, but at any rate, this function is the one that describes a panic, and that's where track_caller is needed the most).

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.

1 participant