-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Closed
Labels
A-error-handlingArea: Error handlingArea: Error handlingC-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.F-track_caller`#![feature(track_caller)]``#![feature(track_caller)]`PG-error-handlingProject group: Error handling (https://github.com/rust-lang/project-error-handling)Project group: Error handling (https://github.com/rust-lang/project-error-handling)
Description
Right now if you construct an error via its Into
implementation as provided by the blanket implementation in std
it gives the following location.
Location:
/home/jlusby/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/convert/mod.rs:545
We should add #[track_caller]
to this trait and possibily some of the Try
trait implementations so that errors that attempt to track their construction point can correctly point to user code.
cc @anp
estebank, unneon and trevyn
Metadata
Metadata
Assignees
Labels
A-error-handlingArea: Error handlingArea: Error handlingC-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.F-track_caller`#![feature(track_caller)]``#![feature(track_caller)]`PG-error-handlingProject group: Error handling (https://github.com/rust-lang/project-error-handling)Project group: Error handling (https://github.com/rust-lang/project-error-handling)
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
BGR360 commentedon Aug 27, 2021
For reference this idea was mentioned also in #87401 (comment)
c410-f3r commentedon Mar 20, 2022
Is there anything preventing this addition? If not, then I can create a PR
BGR360 commentedon Mar 21, 2022
@c410-f3r Since my last comment in August, there has been further discussion about this in various places. IIRC, @yaahc resolved to add
#[track_caller]
to something, I think it wasInto
? That change might already be in. I'll go hunting in my notification history to see if I can find what I'm talking about.BGR360 commentedon Mar 21, 2022
It was to
from_residual
and it has been merged: #91752Unless it has been since removed again, I think that means this issue can be closed?
c410-f3r commentedon Mar 21, 2022
Thanks @BGR360
Unfortunately, such change did not prevent an error I am currently facing that also points stuff to
... library/core/src/convert/mod.rs
.But this can be reported in another issue with an appropriated reproducible snippet
yaahc commentedon Mar 21, 2022
I was worried it would still be broken, I remember in the past it losing the location when it went through
Into
and I thought I remembered?
desugaring to useInto
but it looks like it usesFrom
, so it seems to work fine for my small snippet using eyre.It might be that original issue I was referring to was just about explicitly calling
into
in which case you can still reproduce the issue and I get:Which might be worth fixing, I'm not really sure. It would be a one line change and we'd need to perf test it but I'm not confident it would pass or be something we'd want to merge.
👍 @c410-f3r for opening a new issue for this specific issue. I'm gonna go ahead and close this one for now.
#[track_caller]
to the "From implies Into" impl #119807Auto merge of rust-lang#119807 - Emilgardis:track_caller_from_impl_in…
Auto merge of rust-lang#119807 - Emilgardis:track_caller_from_impl_in…
Auto merge of #119807 - Emilgardis:track_caller_from_impl_into, r=Nil…
Auto merge of #119807 - Emilgardis:track_caller_from_impl_into, r=Nil…
Auto merge of #119807 - Emilgardis:track_caller_from_impl_into, r=Nil…