about summary refs log tree commit diff
path: root/compiler/rustc_builtin_macros
diff options
context:
space:
mode:
authorJack Huey <31162821+jackh726@users.noreply.github.com>2021-02-02 16:01:46 -0500
committerGitHub <noreply@github.com>2021-02-02 16:01:46 -0500
commit7f2eeb10c76c8a6f36fd1a273a99f42b8e5222d4 (patch)
tree0e498d70274abe417e77bdec539376c47c026fe7 /compiler/rustc_builtin_macros
parent86e23cc9f1537a15612810619331953c41dec226 (diff)
parented1de99b4f45032fd049a55bdfae6ee928beecd5 (diff)
downloadrust-7f2eeb10c76c8a6f36fd1a273a99f42b8e5222d4.tar.gz
rust-7f2eeb10c76c8a6f36fd1a273a99f42b8e5222d4.zip
Rollup merge of #81647 - m-ou-se:assert-2021-fix, r=petrochenkov
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.

Also adds tests for the 2021 edition of panic and assert, that would've caught this.
Diffstat (limited to 'compiler/rustc_builtin_macros')
-rw-r--r--compiler/rustc_builtin_macros/src/assert.rs4
1 files changed, 2 insertions, 2 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(),