Skip to content

Tracking Issue for PanicHookInfo::payload_as_str() #125175

Closed

Description

@m-ou-se

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.

Activity

  1. added
    T-libs-api[DEPRECATED; DO NOT USE]
    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFC
    A-panicArea: Panicking machinery
    on May 16, 2024
  2. m-ou-se commented on Sep 23, 2024

    @m-ou-se
    MemberAuthor

    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

  3. rfcbot commented on Sep 23, 2024

    @rfcbot

    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.

  4. added
    proposed-final-comment-periodProposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off.
    disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.
    final-comment-periodIn the final comment period and will be merged soon unless new substantive objections are raised.
    and removed
    proposed-final-comment-periodProposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off.
    on Sep 23, 2024
  5. rfcbot commented on Sep 23, 2024

    @rfcbot

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

  6. madsmtm commented on Sep 28, 2024

    @madsmtm
    Member

    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?

  7. added
    to-announceAnnounce this issue on triage meeting
    and removed
    final-comment-periodIn the final comment period and will be merged soon unless new substantive objections are raised.
    on Oct 3, 2024
  8. rfcbot commented on Oct 3, 2024

    @rfcbot

    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.

  9. m-ou-se commented on Aug 5, 2025

    @m-ou-se
    MemberAuthor

    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>?

    Yes. It says it is guaranteed to return Some if it contains a &str or String, not that it is guaranteed to return None if it is neither.

  10. added a commit that references this issue on Aug 6, 2025
  11. added a commit that references this issue on Aug 6, 2025
  12. added a commit that references this issue on Aug 7, 2025
  13. added a commit that references this issue on Aug 12, 2025
  14. added this to the 1.91.0 milestone on Sep 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-panicArea: Panicking machineryC-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-api[DEPRECATED; DO NOT USE]disposition-mergeThis 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.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions