diff options
| author | Mara Bos <m-ou.se@m-ou.se> | 2021-02-01 23:08:22 +0100 |
|---|---|---|
| committer | Mara Bos <m-ou.se@m-ou.se> | 2021-02-01 23:23:27 +0100 |
| commit | ed1de99b4f45032fd049a55bdfae6ee928beecd5 (patch) | |
| tree | 0c57b31271e526900cbf1b6e8accea20ef99747a | |
| parent | 5022ad0127a4685a65d11b7ddd1f16fe9ee085a9 (diff) | |
| download | rust-ed1de99b4f45032fd049a55bdfae6ee928beecd5.tar.gz rust-ed1de99b4f45032fd049a55bdfae6ee928beecd5.zip | |
Fix bug with assert!() calling the wrong edition of panic!().
The span of `panic!` produced by the `assert` macro did not carry the right edition. This changes `assert` to call the right version.
| -rw-r--r-- | compiler/rustc_builtin_macros/src/assert.rs | 4 | ||||
| -rw-r--r-- | library/core/src/macros/mod.rs | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/compiler/rustc_builtin_macros/src/assert.rs b/compiler/rustc_builtin_macros/src/assert.rs index f82269c4eee..93ba54da342 100644 --- a/compiler/rustc_builtin_macros/src/assert.rs +++ b/compiler/rustc_builtin_macros/src/assert.rs @@ -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(), diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs index 10d30609aca..6a7e4b2ba25 100644 --- a/library/core/src/macros/mod.rs +++ b/library/core/src/macros/mod.rs @@ -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 */ }}; |
