-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Added #[track_caller]
and Improved Debug message for unwrap_throw()
#2995
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
Added #[track_caller]
and Improved Debug message for unwrap_throw()
#2995
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea! expect_throw
should probably show the call site as well.
Should it? Happy to include it, but my initial thinking was custom messages probably already indicate where in the code it was called from. Will get on to those other fixes ASAP. Tks for the review. EDIT: @Liamolucko, I've addressed those other points, feel free to leave any others otherwise lets get this merged in :). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The purpose of unwrap_throw
was originally to be very small on codegen, so specifically not having features like this (or the usage of format!
). I think for this you'd instead want to use .unwrap()
which has all the features baked in.
For me (on Edge and Firefox Fedora/Silverblue), Perhaps this can be extracted to an optional feature or a separate function? I personally think it would be highly useful, but I understand why it potentially shouldn't be baked in. EDIT: I realise even using |
Yes - you need |
Thanks for that Liam, that does work for me, not sure if that's documented somewhere and I missed it somehow.
Perhaps my altered |
For the record, I think it would be really useful if |
2ed76e7
to
4391dbb
Compare
After some productive discussion in this PR, it seems sensible to me to at least get some further explanation why this change couldn't be pushed through. I've added debug assertions as I agree that's a sensible change. |
Sorry to ping, @alexcrichton, do you have any further thoughts on having the filename tracking only when compiling with Also just following up on the discussion around I'm not sure about the majority of WASM crates but without PR'ing to the ones that do use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think gating this behind debug_assertions
is reasonable, yeah.
I've made those changes you've suggested there @alexcrichton, how does it look? Is
This doesn't seem to be mentioned in the guide, perhaps I should draft another PR and add in some documentation on this for the guide? |
No, it should be |
Do the track caller attrs have to remain then as before ( Or is the full guard Won't that mean there will have to be two functions like before? |
No, they should be |
Perfect, thanks Liam, I had a bit of a brain fart and conflated those two changes Alex suggested. Should be working now. |
Any further work required on this? |
29dc206
to
85fa6b4
Compare
Tested on firefox and edge (on fedora) with my own trait on top locally, I could not get it to run off a path dep due to
Help would be appreciated.
#[track_caller]
core::panic::location
to retreive called file, line, col locations