Skip to content

Commit 2f5d993

Browse files
committed
Shorten lifetime of even more panic temporaries
1 parent 0ebb5cb commit 2f5d993

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

Diff for: library/core/src/panic.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ pub macro panic_2015 {
2828
$crate::panicking::panic($msg)
2929
),
3030
// Use `panic_str` instead of `panic_display::<&str>` for non_fmt_panic lint.
31-
($msg:expr $(,)?) => (
32-
$crate::panicking::panic_str($msg)
33-
),
31+
($msg:expr $(,)?) => ({
32+
$crate::panicking::panic_str($msg);
33+
}),
3434
// Special-case the single-argument case for const_panic.
35-
("{}", $arg:expr $(,)?) => (
36-
$crate::panicking::panic_display(&$arg)
37-
),
35+
("{}", $arg:expr $(,)?) => ({
36+
$crate::panicking::panic_display(&$arg);
37+
}),
3838
($fmt:expr, $($arg:tt)+) => ({
3939
// Semicolon to prevent temporaries inside the formatting machinery from
4040
// being considered alive in the caller after the panic_fmt call.
@@ -52,9 +52,9 @@ pub macro panic_2021 {
5252
$crate::panicking::panic("explicit panic")
5353
),
5454
// Special-case the single-argument case for const_panic.
55-
("{}", $arg:expr $(,)?) => (
56-
$crate::panicking::panic_display(&$arg)
57-
),
55+
("{}", $arg:expr $(,)?) => ({
56+
$crate::panicking::panic_display(&$arg);
57+
}),
5858
($($t:tt)+) => ({
5959
// Semicolon to prevent temporaries inside the formatting machinery from
6060
// being considered alive in the caller after the panic_fmt call.
@@ -73,9 +73,9 @@ pub macro unreachable_2015 {
7373
),
7474
// Use of `unreachable_display` for non_fmt_panic lint.
7575
// NOTE: the message ("internal error ...") is embedded directly in unreachable_display
76-
($msg:expr $(,)?) => (
77-
$crate::panicking::unreachable_display(&$msg)
78-
),
76+
($msg:expr $(,)?) => ({
77+
$crate::panicking::unreachable_display(&$msg);
78+
}),
7979
($fmt:expr, $($arg:tt)*) => (
8080
$crate::panic!($crate::concat!("internal error: entered unreachable code: ", $fmt), $($arg)*)
8181
),

Diff for: library/std/src/panic.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ pub macro panic_2015 {
1919
$crate::rt::begin_panic("explicit panic")
2020
}),
2121
($msg:expr $(,)?) => ({
22-
$crate::rt::begin_panic($msg)
22+
$crate::rt::begin_panic($msg);
2323
}),
2424
// Special-case the single-argument case for const_panic.
2525
("{}", $arg:expr $(,)?) => ({
26-
$crate::rt::panic_display(&$arg)
26+
$crate::rt::panic_display(&$arg);
2727
}),
2828
($fmt:expr, $($arg:tt)+) => ({
2929
// Semicolon to prevent temporaries inside the formatting machinery from

0 commit comments

Comments
 (0)