Skip to content

Commit d9d89fd

Browse files
committed
Auto merge of rust-lang#119807 - Emilgardis:track_caller_from_impl_into, r=Nilstrieb
Add `#[track_caller]` to the "From implies Into" impl This pr implements what was mentioned in rust-lang#77474 (comment) This follows from my URLO https://users.rust-lang.org/t/104497 ```rust #![allow(warnings)] fn main() { // Gives a good location let _: Result<(), Loc> = dbg!(Err::<(), _>(()).map_err(|e| e.into())); // still doesn't work, gives location of `FnOnce::call_once()` let _: Result<(), Loc> = dbg!(Err::<(), _>(()).map_err(Into::into)); } #[derive(Debug)] pub struct Loc { pub l: &'static std::panic::Location<'static>, } impl From<()> for Loc { #[track_caller] fn from(_: ()) -> Self { Loc { l: std::panic::Location::caller(), } } } ```
2 parents fa40433 + 075f2e0 commit d9d89fd

File tree

1 file changed

+1
-0
lines changed
  • library/core/src/convert

1 file changed

+1
-0
lines changed

library/core/src/convert/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,7 @@ where
753753
/// That is, this conversion is whatever the implementation of
754754
/// <code>[From]&lt;T&gt; for U</code> chooses to do.
755755
#[inline]
756+
#[track_caller]
756757
fn into(self) -> U {
757758
U::from(self)
758759
}

0 commit comments

Comments
 (0)