Skip to content
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

Tracking Issue for PanicHookInfo::payload_as_str() #125175

Open
1 of 3 tasks
m-ou-se opened this issue May 16, 2024 · 5 comments
Open
1 of 3 tasks

Tracking Issue for PanicHookInfo::payload_as_str() #125175

m-ou-se opened this issue May 16, 2024 · 5 comments
Labels
A-panic Area: Panicking machinery C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@m-ou-se
Copy link
Member

m-ou-se commented May 16, 2024

Feature gate: #![feature(panic_payload_as_str)]

This is a tracking issue for PanicHookInfo::payload_as_str()

Public API

// std::panic

impl PanicHookInfo {
    pub fn payload_as_str(&self) -> Option<&str>;
}

Documentation: https://doc.rust-lang.org/nightly/std/panic/struct.PanicHookInfo.html#method.payload_as_str

Steps / History

Unresolved Questions

  • None yet.
@m-ou-se m-ou-se added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. A-panic Area: Panicking machinery labels May 16, 2024
@m-ou-se
Copy link
Member Author

m-ou-se commented Sep 23, 2024

PanicHookInfo (as a separate type from PanicInfo) has been stablized. Time to stabilize PanicHookInfo::payload_as_str(). :)

This replaces the 'try to cast to str otherwise try to cast to String' pattern that basically every user of PanicHookInfo is doing today.

@rfcbot merge

@rfcbot
Copy link

rfcbot commented Sep 23, 2024

Team member @m-ou-se 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.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. labels Sep 23, 2024
@rfcbot
Copy link

rfcbot commented Sep 23, 2024

🔔 This is now entering its final comment period, as per the review above. 🔔

@madsmtm
Copy link
Contributor

madsmtm commented Sep 28, 2024

The documentation on payload_as_str is reproduced here:

Returns the payload associated with the panic, if it is a string.

This returns the payload if it is of type &'static str or String.

A invocation of the panic!() macro in Rust 2021 or later will always result in a panic payload where payload_as_str returns Some.

Only an invocation of panic_any (or, in Rust 2018 and earlier, panic!(x) where x is something other than a string) can result in a panic payload where payload_as_str returns None.

I'm unsure, would you say that it is written in such a way that we could allow changing it to also internally also cast e.g. Box<str> or Cow<'static, str>, or perhaps even dyn AsRef<str>? If not, then I think perhaps that should be changed before stabilization?

@rfcbot rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. to-announce Announce this issue on triage meeting and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels Oct 3, 2024
@rfcbot
Copy link

rfcbot commented Oct 3, 2024

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

This will be merged soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-panic Area: Panicking machinery C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants