Shorten lifetime of panic temporaries in panic_fmt case

This commit is contained in:
David Tolnay
2022-11-07 13:23:16 -08:00
parent cbee2a1ec4
commit cb109a672d
5 changed files with 24 additions and 45 deletions

View File

@@ -26,7 +26,9 @@ pub macro panic_2015 {
$crate::rt::panic_display(&$arg)
}),
($fmt:expr, $($arg:tt)+) => ({
$crate::rt::panic_fmt($crate::const_format_args!($fmt, $($arg)+))
// Semicolon to prevent temporaries inside the formatting machinery from
// being considered alive in the caller after the panic_fmt call.
$crate::rt::panic_fmt($crate::const_format_args!($fmt, $($arg)+));
}),
}