about summary refs log tree commit diff
path: root/compiler/rustc_builtin_macros/src/assert.rs
diff options
context:
space:
mode:
authorMara Bos <m-ou.se@m-ou.se>2021-01-24 14:15:15 +0100
committerMara Bos <m-ou.se@m-ou.se>2021-01-24 14:19:05 +0100
commita730970dffe84711b8be66c38080acf1b1109982 (patch)
tree4f10b3f6759245e6e260b858dc62d2d030020a43 /compiler/rustc_builtin_macros/src/assert.rs
parent8098ac17064ee5a1d34ffe6bc8d35a9574f2bf6e (diff)
downloadrust-a730970dffe84711b8be66c38080acf1b1109982.tar.gz
rust-a730970dffe84711b8be66c38080acf1b1109982.zip
Only call span.rust_2021() when necessary.
Diffstat (limited to 'compiler/rustc_builtin_macros/src/assert.rs')
-rw-r--r--compiler/rustc_builtin_macros/src/assert.rs12
1 files changed, 5 insertions, 7 deletions
diff --git a/compiler/rustc_builtin_macros/src/assert.rs b/compiler/rustc_builtin_macros/src/assert.rs
index 3cffc7a75ee..f82269c4eee 100644
--- a/compiler/rustc_builtin_macros/src/assert.rs
+++ b/compiler/rustc_builtin_macros/src/assert.rs
@@ -12,25 +12,23 @@ use rustc_span::{Span, DUMMY_SP};
 
 pub fn expand_assert<'cx>(
     cx: &'cx mut ExtCtxt<'_>,
-    sp: Span,
+    span: Span,
     tts: TokenStream,
 ) -> Box<dyn MacResult + 'cx> {
-    let Assert { cond_expr, custom_message } = match parse_assert(cx, sp, tts) {
+    let Assert { cond_expr, custom_message } = match parse_assert(cx, span, tts) {
         Ok(assert) => assert,
         Err(mut err) => {
             err.emit();
-            return DummyResult::any(sp);
+            return DummyResult::any(span);
         }
     };
 
-    let is_2021 = sp.rust_2021();
-
     // `core::panic` and `std::panic` are different macros, so we use call-site
     // context to pick up whichever is currently in scope.
-    let sp = cx.with_call_site_ctxt(sp);
+    let sp = cx.with_call_site_ctxt(span);
 
     let panic_call = if let Some(tokens) = custom_message {
-        let path = if is_2021 {
+        let path = if span.rust_2021() {
             // On edition 2021, we always call `$crate::panic!()`.
             Path {
                 span: sp,