-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Change Location<'_>
lifetime to 'static
in Panic[Hook]Info
#146561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
rustbot has assigned @Mark-Simulacrum. Use |
Considering that the only way to construct a location is |
4d90b34
to
e3b8df1
Compare
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
That's a great idea! I've updated accordingly. |
@rfcbot merge |
Team member @Amanieu has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
I'm writing a library that would benefit from being able to store a
&'static str
instead of aString
for the file location of a panic. Currently, the API ofstd::panic::PanicHookInfo::location
andcore::panic::PanicInfo::location
return aLocation<'_>
(and by extension, a file name&str
) whose lifetime is tied to the borrow of thePanic[Hook]Info
.It is my understanding that the
Location
/&str
will always beLocation<'static>
/&'static str
, since the file name is embedded directly into the compiled binary (and I don't see a likely reason/way for that to ever change in the future). Since it seems unlikely to ever need to change, and since making the guarantee that the returned lifetime is'static
has a real benefit (allows users to avoid unnecessary allocations), I think changing to the returnedLocation<'_>
's lifetime to'static
would be a worthwhile change.see also the recent #1320870, which made a similar change to
std::panic::Location