mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
d9d89fd53d
Add `#[track_caller]` to the "From implies Into" impl This pr implements what was mentioned in https://github.com/rust-lang/rust/issues/77474#issuecomment-1074480790 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(), } } } ``` |
||
---|---|---|
.. | ||
benches | ||
src | ||
tests | ||
Cargo.toml |