Skip to content

expect(): Track caller - #142

Open
chrysn wants to merge 1 commit into
dalek-cryptography:mainfrom
chrysn-pull-requests:expect-track-caller
Open

expect(): Track caller#142
chrysn wants to merge 1 commit into
dalek-cryptography:mainfrom
chrysn-pull-requests:expect-track-caller

Conversation

@chrysn

Copy link
Copy Markdown

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).

@elichai

Copy link
Copy Markdown

This should also be applied to .unwrap()

@tarcieri

Copy link
Copy Markdown
Contributor

I've opened a PR for this: #152

Sign up for freeto 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.

3 participants

@chrysn@elichai@tarcieri