Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions library/core/src/panic/panic_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::panic::Location;
#[derive(Debug)]
pub struct PanicInfo<'a> {
message: &'a fmt::Arguments<'a>,
location: &'a Location<'a>,
location: &'static Location<'static>,
can_unwind: bool,
force_no_backtrace: bool,
}
Expand All @@ -33,7 +33,7 @@ impl<'a> PanicInfo<'a> {
#[inline]
pub(crate) fn new(
message: &'a fmt::Arguments<'a>,
location: &'a Location<'a>,
location: &'static Location<'static>,
can_unwind: bool,
force_no_backtrace: bool,
) -> Self {
Expand Down Expand Up @@ -88,10 +88,10 @@ impl<'a> PanicInfo<'a> {
/// ```
#[must_use]
#[stable(feature = "panic_hooks", since = "1.10.0")]
pub fn location(&self) -> Option<&Location<'_>> {
pub fn location(&self) -> Option<&'static Location<'static>> {
// NOTE: If this is changed to sometimes return None,
// deal with that case in std::panicking::default_hook and core::panicking::panic_fmt.
Some(&self.location)
Some(self.location)
}

/// Returns the payload associated with the panic.
Expand Down
8 changes: 4 additions & 4 deletions library/std/src/panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ pub type PanicInfo<'a> = PanicHookInfo<'a>;
#[derive(Debug)]
pub struct PanicHookInfo<'a> {
payload: &'a (dyn Any + Send),
location: &'a Location<'a>,
location: &'static Location<'static>,
can_unwind: bool,
force_no_backtrace: bool,
}

impl<'a> PanicHookInfo<'a> {
#[inline]
pub(crate) fn new(
location: &'a Location<'a>,
location: &'static Location<'static>,
payload: &'a (dyn Any + Send),
can_unwind: bool,
force_no_backtrace: bool,
Expand Down Expand Up @@ -160,10 +160,10 @@ impl<'a> PanicHookInfo<'a> {
#[must_use]
#[inline]
#[stable(feature = "panic_hooks", since = "1.10.0")]
pub fn location(&self) -> Option<&Location<'_>> {
pub fn location(&self) -> Option<&'static Location<'static>> {
// NOTE: If this is changed to sometimes return None,
// deal with that case in std::panicking::default_hook and core::panicking::panic_fmt.
Some(&self.location)
Some(self.location)
}

/// Returns whether the panic handler is allowed to unwind the stack from
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/panicking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ fn payload_as_str(payload: &dyn Any) -> &str {
#[optimize(size)]
fn panic_with_hook(
payload: &mut dyn PanicPayload,
location: &Location<'_>,
location: &'static Location<'static>,
can_unwind: bool,
force_no_backtrace: bool,
) -> ! {
Expand Down
Loading