Skip to content

Commit 9178bf2

Browse files
committed
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!().
1 parent 1f9dc9a commit 9178bf2

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

library/core/src/macros/mod.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ macro_rules! panic {
77
() => (
88
$crate::panic!("explicit panic")
99
);
10-
($msg:literal $(,)?) => (
10+
($msg:literal $(,)?) => ({
1111
$crate::panicking::panic($msg)
12-
);
13-
($msg:expr $(,)?) => (
12+
});
13+
($msg:expr $(,)?) => ({
1414
$crate::panicking::panic_str($msg)
15-
);
16-
($fmt:expr, $($arg:tt)+) => (
15+
});
16+
($fmt:expr, $($arg:tt)+) => ({
1717
$crate::panicking::panic_fmt($crate::format_args!($fmt, $($arg)+))
18-
);
18+
});
1919
}
2020

2121
/// Asserts that two expressions are equal to each other (using [`PartialEq`]).

src/test/ui/issues/issue-5500-1.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ struct TrieMapIterator<'a> {
1111
fn main() {
1212
let a = 5;
1313
let _iter = TrieMapIterator{node: &a};
14-
_iter.node = &panic!()
14+
_iter.node = &panic!();
15+
_iter.node = &core::panic!()
1516
}

0 commit comments

Comments
 (0)