From 9178bf2630c84b88529d4ab5649f5126d8ee1187 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Sat, 9 Jan 2021 19:22:02 +0100 Subject: [PATCH] Expand core::panic!() to always include `{ .. }`. std::panic!() always expanded to a `{..}` block, but core::panic!() did not. Because of this subtle difference, the issue-5500-1 test passed for std::panic!(), but not for core::panic!(). This makes them behave the same, and extends that test to also check core::panic!(). --- library/core/src/macros/mod.rs | 12 ++++++------ src/test/ui/issues/issue-5500-1.rs | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs index 1634aff7b4dc9..be980c5f07b71 100644 --- a/library/core/src/macros/mod.rs +++ b/library/core/src/macros/mod.rs @@ -7,15 +7,15 @@ macro_rules! panic { () => ( $crate::panic!("explicit panic") ); - ($msg:literal $(,)?) => ( + ($msg:literal $(,)?) => ({ $crate::panicking::panic($msg) - ); - ($msg:expr $(,)?) => ( + }); + ($msg:expr $(,)?) => ({ $crate::panicking::panic_str($msg) - ); - ($fmt:expr, $($arg:tt)+) => ( + }); + ($fmt:expr, $($arg:tt)+) => ({ $crate::panicking::panic_fmt($crate::format_args!($fmt, $($arg)+)) - ); + }); } /// Asserts that two expressions are equal to each other (using [`PartialEq`]). diff --git a/src/test/ui/issues/issue-5500-1.rs b/src/test/ui/issues/issue-5500-1.rs index 98d6e1a14cb32..c2205c763af2a 100644 --- a/src/test/ui/issues/issue-5500-1.rs +++ b/src/test/ui/issues/issue-5500-1.rs @@ -11,5 +11,6 @@ struct TrieMapIterator<'a> { fn main() { let a = 5; let _iter = TrieMapIterator{node: &a}; - _iter.node = &panic!() + _iter.node = &panic!(); + _iter.node = &core::panic!() }