From cb109a672d161ee305d21c98edb84ef50c6f997b Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Mon, 7 Nov 2022 13:23:16 -0800 Subject: Shorten lifetime of panic temporaries in panic_fmt case --- library/std/src/panic.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'library/std/src') diff --git a/library/std/src/panic.rs b/library/std/src/panic.rs index 345d72ef867..a2ffd8b1e7e 100644 --- a/library/std/src/panic.rs +++ b/library/std/src/panic.rs @@ -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)+)); }), } -- cgit 1.4.1-3-g733a5