Skip to content

Commit

Permalink
Fix bug with assert!() calling the wrong edition of panic!().
Browse files Browse the repository at this point in the history
The span of `panic!` produced by the `assert` macro did not carry the
right edition. This changes `assert` to call the right version.
  • Loading branch information
m-ou-se committed Feb 1, 2021
1 parent 5022ad0 commit ed1de99
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_builtin_macros/src/assert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ pub fn expand_assert<'cx>(

let panic_call = if let Some(tokens) = custom_message {
let path = if span.rust_2021() {
// On edition 2021, we always call `$crate::panic!()`.
// On edition 2021, we always call `$crate::panic::panic_2021!()`.
Path {
span: sp,
segments: cx
.std_path(&[sym::panic])
.std_path(&[sym::panic, sym::panic_2021])
.into_iter()
.map(|ident| PathSegment::from_ident(ident))
.collect(),
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/macros/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1234,7 +1234,7 @@ pub(crate) mod builtin {
#[rustc_builtin_macro]
#[macro_export]
#[rustc_diagnostic_item = "assert_macro"]
#[allow_internal_unstable(core_panic)]
#[allow_internal_unstable(core_panic, edition_panic)]
macro_rules! assert {
($cond:expr $(,)?) => {{ /* compiler built-in */ }};
($cond:expr, $($arg:tt)+) => {{ /* compiler built-in */ }};
Expand Down

0 comments on commit ed1de99

Please sign in to comment.