-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
F-track_caller`#![feature(track_caller)]``#![feature(track_caller)]`T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.This issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.The final comment period is finished for this PR / Issue.
Description
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
anp, mark-i-m and tmandry
Metadata
Metadata
Assignees
Labels
F-track_caller`#![feature(track_caller)]``#![feature(track_caller)]`T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.This issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.The final comment period is finished for this PR / Issue.