The lang FCP for #[track_caller] is happening in #72445. This is a libs FCP for https://doc.rust-lang.org/nightly/std/panic/struct.Location.html#method.caller which is under the same feature gate and required for making use of #[track_caller] in library code.
Refer to @anp's stabilization report and the method's example code.
In particular:
-
The return type is &'static Location<'static> which resembles the return type of std::panic::PanicInfo::location (Option<&'a Location<'a>>) but static and non-optional.
-
The location points to the outermost call site not inside of a #[track_caller] function.
#[track_caller]
fn f() -> &'static Location<'static> {
Location::caller()
}
fn g() -> &'static Location<'static> {
f() /*
^ calling g() gives a location whose file()/line()/column() point to here
*/
}
@rust-lang/libs
The lang FCP for
#[track_caller]is happening in #72445. This is a libs FCP for https://doc.rust-lang.org/nightly/std/panic/struct.Location.html#method.caller which is under the same feature gate and required for making use of#[track_caller]in library code.Refer to @anp's stabilization report and the method's example code.
In particular:
The return type is
&'static Location<'static>which resembles the return type of std::panic::PanicInfo::location (Option<&'a Location<'a>>) but static and non-optional.The location points to the outermost call site not inside of a
#[track_caller]function.@rust-lang/libs