about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2019-07-03 23:59:03 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2019-07-11 00:12:08 +0300
commitf92394209455bf14594f279249c2e592809180cd (patch)
treee726e1edca5ed4408424fc31bbd66791b3fc497e
parent8bc187d1047b3680efe2cda53dcc83f45012578b (diff)
downloadrust-f92394209455bf14594f279249c2e592809180cd.tar.gz
rust-f92394209455bf14594f279249c2e592809180cd.zip
resolve: Divide macro path resolution into speculative and error reporting parts
Also move macro stability checking closer to other checks performed on obtained resolutions.
Tighten the stability spans as well, it is an error to *refer* to and unstable entity in any way, not only "call" it.
-rw-r--r--src/librustc_resolve/build_reduced_graph.rs6
-rw-r--r--src/librustc_resolve/macros.rs101
-rw-r--r--src/librustdoc/passes/collect_intra_doc_links.rs4
-rw-r--r--src/test/ui/feature-gates/feature-gate-asm.stderr2
-rw-r--r--src/test/ui/feature-gates/feature-gate-asm2.stderr2
-rw-r--r--src/test/ui/feature-gates/feature-gate-concat_idents.stderr4
-rw-r--r--src/test/ui/feature-gates/feature-gate-concat_idents2.stderr2
-rw-r--r--src/test/ui/feature-gates/feature-gate-concat_idents3.stderr4
-rw-r--r--src/test/ui/feature-gates/feature-gate-format_args_nl.stderr2
-rw-r--r--src/test/ui/feature-gates/feature-gate-global_asm.stderr2
-rw-r--r--src/test/ui/feature-gates/feature-gate-log_syntax.stderr2
-rw-r--r--src/test/ui/feature-gates/feature-gate-log_syntax2.stderr2
-rw-r--r--src/test/ui/feature-gates/feature-gate-trace_macros.stderr2
-rw-r--r--src/test/ui/macros/macro-deprecation.stderr4
-rw-r--r--src/test/ui/macros/macro-stability.stderr10
-rw-r--r--src/test/ui/rust-unstable-column-gated.stderr2
-rw-r--r--src/test/ui/trace_macros-gate.stderr8
17 files changed, 77 insertions, 82 deletions
diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs
index f74d07a3c5e..16fd8cccc89 100644
--- a/src/librustc_resolve/build_reduced_graph.rs
+++ b/src/librustc_resolve/build_reduced_graph.rs
@@ -755,11 +755,7 @@ impl<'a> Resolver<'a> {
         }
     }
 
-    pub fn get_macro(&mut self, res: Res) -> Lrc<SyntaxExtension> {
-        self.opt_get_macro(res).expect("expected `DefKind::Macro` or `Res::NonMacroAttr`")
-    }
-
-    crate fn opt_get_macro(&mut self, res: Res) -> Option<Lrc<SyntaxExtension>> {
+    pub fn get_macro(&mut self, res: Res) -> Option<Lrc<SyntaxExtension>> {
         let def_id = match res {
             Res::Def(DefKind::Macro(..), def_id) => def_id,
             Res::NonMacroAttr(attr_kind) =>
diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs
index 7cb33ca3ed4..077c126bdee 100644
--- a/src/librustc_resolve/macros.rs
+++ b/src/librustc_resolve/macros.rs
@@ -229,13 +229,10 @@ impl<'a> base::Resolver for Resolver<'a> {
         };
 
         let parent_scope = self.invoc_parent_scope(invoc_id, derives_in_scope);
-        let (res, ext) = self.resolve_macro_to_res(path, kind, &parent_scope, true, force)?;
+        let (ext, res) = self.smart_resolve_macro_path(path, kind, &parent_scope, true, force)?;
 
         let span = invoc.span();
-        let descr = fast_print_path(path);
-        invoc.expansion_data.mark.set_expn_info(ext.expn_info(span, descr));
-
-        self.check_stability_and_deprecation(&ext, descr, span);
+        invoc.expansion_data.mark.set_expn_info(ext.expn_info(span, fast_print_path(path)));
 
         if let Res::Def(_, def_id) = res {
             if after_derive {
@@ -275,47 +272,42 @@ impl<'a> Resolver<'a> {
         }
     }
 
-    fn resolve_macro_to_res(
+    /// Resolve macro path with error reporting and recovery.
+    fn smart_resolve_macro_path(
         &mut self,
         path: &ast::Path,
         kind: MacroKind,
         parent_scope: &ParentScope<'a>,
         trace: bool,
         force: bool,
-    ) -> Result<(Res, Lrc<SyntaxExtension>), Indeterminate> {
-        let res = self.resolve_macro_to_res_inner(path, kind, parent_scope, trace, force);
+    ) -> Result<(Lrc<SyntaxExtension>, Res), Indeterminate> {
+        let (ext, res) = match self.resolve_macro_path(path, kind, parent_scope, trace, force) {
+            Ok((Some(ext), res)) => (ext, res),
+            // Use dummy syntax extensions for unresolved macros for better recovery.
+            Ok((None, res)) => (self.dummy_ext(kind), res),
+            Err(Determinacy::Determined) => (self.dummy_ext(kind), Res::Err),
+            Err(Determinacy::Undetermined) => return Err(Indeterminate),
+        };
 
         // Report errors and enforce feature gates for the resolved macro.
         let features = self.session.features_untracked();
-        if res != Err(Determinacy::Undetermined) {
-            // Do not report duplicated errors on every undetermined resolution.
-            for segment in &path.segments {
-                if let Some(args) = &segment.args {
-                    self.session.span_err(args.span(), "generic arguments in macro path");
-                }
-                if kind == MacroKind::Attr && !features.rustc_attrs &&
-                   segment.ident.as_str().starts_with("rustc") {
-                    let msg = "attributes starting with `rustc` are \
-                               reserved for use by the `rustc` compiler";
-                    emit_feature_err(
-                        &self.session.parse_sess,
-                        sym::rustc_attrs,
-                        segment.ident.span,
-                        GateIssue::Language,
-                        msg,
-                    );
-                }
+        for segment in &path.segments {
+            if let Some(args) = &segment.args {
+                self.session.span_err(args.span(), "generic arguments in macro path");
             }
-        }
-
-        let res = match res {
-            Err(Determinacy::Undetermined) => return Err(Indeterminate),
-            Ok(Res::Err) | Err(Determinacy::Determined) => {
-                // Return dummy syntax extensions for unresolved macros for better recovery.
-                return Ok((Res::Err, self.dummy_ext(kind)));
+            if kind == MacroKind::Attr && !features.rustc_attrs &&
+               segment.ident.as_str().starts_with("rustc") {
+                let msg =
+                    "attributes starting with `rustc` are reserved for use by the `rustc` compiler";
+                emit_feature_err(
+                    &self.session.parse_sess,
+                    sym::rustc_attrs,
+                    segment.ident.span,
+                    GateIssue::Language,
+                    msg,
+                );
             }
-            Ok(res) => res,
-        };
+        }
 
         match res {
             Res::Def(DefKind::Macro(_), def_id) => {
@@ -345,20 +337,22 @@ impl<'a> Resolver<'a> {
                     }
                 }
             }
+            Res::Err => {}
             _ => panic!("expected `DefKind::Macro` or `Res::NonMacroAttr`"),
         };
 
-        let ext = self.get_macro(res);
+        self.check_stability_and_deprecation(&ext, path);
+
         Ok(if ext.macro_kind() != kind {
             let expected = if kind == MacroKind::Attr { "attribute" } else  { kind.descr() };
             let msg = format!("expected {}, found {} `{}`", expected, res.descr(), path);
             self.session.struct_span_err(path.span, &msg)
                         .span_label(path.span, format!("not {} {}", kind.article(), expected))
                         .emit();
-            // Return dummy syntax extensions for unexpected macro kinds for better recovery.
-            (Res::Err, self.dummy_ext(kind))
+            // Use dummy syntax extensions for unexpected macro kinds for better recovery.
+            (self.dummy_ext(kind), Res::Err)
         } else {
-            (res, ext)
+            (ext, res)
         })
     }
 
@@ -416,14 +410,14 @@ impl<'a> Resolver<'a> {
         err.emit();
     }
 
-    pub fn resolve_macro_to_res_inner(
+    pub fn resolve_macro_path(
         &mut self,
         path: &ast::Path,
         kind: MacroKind,
         parent_scope: &ParentScope<'a>,
         trace: bool,
         force: bool,
-    ) -> Result<Res, Determinacy> {
+    ) -> Result<(Option<Lrc<SyntaxExtension>>, Res), Determinacy> {
         let path_span = path.span;
         let mut path = Segment::from_path(path);
 
@@ -435,7 +429,7 @@ impl<'a> Resolver<'a> {
             path.insert(0, Segment::from_ident(root));
         }
 
-        if path.len() > 1 {
+        let res = if path.len() > 1 {
             let res = match self.resolve_path(&path, Some(MacroNS), parent_scope,
                                               false, path_span, CrateLint::No) {
                 PathResult::NonModule(path_res) if path_res.unresolved_segments() == 0 => {
@@ -471,7 +465,9 @@ impl<'a> Resolver<'a> {
             let res = binding.map(|binding| binding.res());
             self.prohibit_imported_non_macro_attrs(binding.ok(), res.ok(), path_span);
             res
-        }
+        };
+
+        res.map(|res| (self.get_macro(res), res))
     }
 
     // Resolve an identifier in lexical scope.
@@ -600,16 +596,18 @@ impl<'a> Resolver<'a> {
                     let mut result = Err(Determinacy::Determined);
                     for derive in &parent_scope.derives {
                         let parent_scope = ParentScope { derives: Vec::new(), ..*parent_scope };
-                        match self.resolve_macro_to_res(derive, MacroKind::Derive,
-                                                        &parent_scope, true, force) {
-                            Ok((_, ext)) => if ext.helper_attrs.contains(&ident.name) {
+                        match self.resolve_macro_path(derive, MacroKind::Derive,
+                                                      &parent_scope, true, force) {
+                            Ok((Some(ext), _)) => if ext.helper_attrs.contains(&ident.name) {
                                 let binding = (Res::NonMacroAttr(NonMacroAttrKind::DeriveHelper),
                                                ty::Visibility::Public, derive.span, Mark::root())
                                                .to_name_binding(self.arenas);
                                 result = Ok((binding, Flags::empty()));
                                 break;
                             }
-                            Err(Indeterminate) => result = Err(Determinacy::Undetermined),
+                            Ok(_) | Err(Determinacy::Determined) => {}
+                            Err(Determinacy::Undetermined) =>
+                                result = Err(Determinacy::Undetermined),
                         }
                     }
                     result
@@ -1004,7 +1002,8 @@ impl<'a> Resolver<'a> {
         }
     }
 
-    fn check_stability_and_deprecation(&self, ext: &SyntaxExtension, descr: Symbol, span: Span) {
+    fn check_stability_and_deprecation(&self, ext: &SyntaxExtension, path: &ast::Path) {
+        let span = path.span;
         if let Some(stability) = &ext.stability {
             if let StabilityLevel::Unstable { reason, issue } = stability.level {
                 let feature = stability.feature;
@@ -1013,14 +1012,14 @@ impl<'a> Resolver<'a> {
                 }
             }
             if let Some(depr) = &stability.rustc_depr {
-                let (message, lint) = stability::rustc_deprecation_message(depr, &descr.as_str());
+                let (message, lint) = stability::rustc_deprecation_message(depr, &path.to_string());
                 stability::early_report_deprecation(
                     self.session, &message, depr.suggestion, lint, span
                 );
             }
         }
         if let Some(depr) = &ext.deprecation {
-            let (message, lint) = stability::deprecation_message(depr, &descr.as_str());
+            let (message, lint) = stability::deprecation_message(depr, &path.to_string());
             stability::early_report_deprecation(self.session, &message, None, lint, span);
         }
     }
@@ -1101,7 +1100,7 @@ impl<'a> Resolver<'a> {
         // Reserve some names that are not quite covered by the general check
         // performed on `Resolver::builtin_attrs`.
         if ident.name == sym::cfg || ident.name == sym::cfg_attr || ident.name == sym::derive {
-            let macro_kind = self.opt_get_macro(res).map(|ext| ext.macro_kind());
+            let macro_kind = self.get_macro(res).map(|ext| ext.macro_kind());
             if macro_kind.is_some() && sub_namespace_match(macro_kind, Some(MacroKind::Attr)) {
                 self.session.span_err(
                     ident.span, &format!("name `{}` is reserved in attribute namespace", ident)
diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs
index acf7a951856..c527ed02bc0 100644
--- a/src/librustdoc/passes/collect_intra_doc_links.rs
+++ b/src/librustdoc/passes/collect_intra_doc_links.rs
@@ -429,10 +429,10 @@ fn macro_resolve(cx: &DocContext<'_>, path_str: &str) -> Option<Res> {
     let segment = ast::PathSegment::from_ident(Ident::from_str(path_str));
     let path = ast::Path { segments: vec![segment], span: DUMMY_SP };
     cx.enter_resolver(|resolver| {
-        if let Ok(res @ Res::Def(DefKind::Macro(_), _)) = resolver.resolve_macro_to_res_inner(
+        if let Ok((Some(ext), res)) = resolver.resolve_macro_path(
             &path, MacroKind::Bang, &resolver.dummy_parent_scope(), false, false
         ) {
-            if let SyntaxExtensionKind::LegacyBang { .. } = resolver.get_macro(res).kind {
+            if let SyntaxExtensionKind::LegacyBang { .. } = ext.kind {
                 return Some(res.map_id(|_| panic!("unexpected id")));
             }
         }
diff --git a/src/test/ui/feature-gates/feature-gate-asm.stderr b/src/test/ui/feature-gates/feature-gate-asm.stderr
index 0d7f8d819ab..ab5cda43bfc 100644
--- a/src/test/ui/feature-gates/feature-gate-asm.stderr
+++ b/src/test/ui/feature-gates/feature-gate-asm.stderr
@@ -2,7 +2,7 @@ error[E0658]: use of unstable library feature 'asm': inline assembly is not stab
   --> $DIR/feature-gate-asm.rs:3:9
    |
 LL |         asm!("");
-   |         ^^^^^^^^^
+   |         ^^^
    |
    = note: for more information, see https://github.com/rust-lang/rust/issues/29722
    = help: add `#![feature(asm)]` to the crate attributes to enable
diff --git a/src/test/ui/feature-gates/feature-gate-asm2.stderr b/src/test/ui/feature-gates/feature-gate-asm2.stderr
index b60a34be434..7519cad9a96 100644
--- a/src/test/ui/feature-gates/feature-gate-asm2.stderr
+++ b/src/test/ui/feature-gates/feature-gate-asm2.stderr
@@ -2,7 +2,7 @@ error[E0658]: use of unstable library feature 'asm': inline assembly is not stab
   --> $DIR/feature-gate-asm2.rs:5:26
    |
 LL |         println!("{:?}", asm!(""));
-   |                          ^^^^^^^^
+   |                          ^^^
    |
    = note: for more information, see https://github.com/rust-lang/rust/issues/29722
    = help: add `#![feature(asm)]` to the crate attributes to enable
diff --git a/src/test/ui/feature-gates/feature-gate-concat_idents.stderr b/src/test/ui/feature-gates/feature-gate-concat_idents.stderr
index 4dc687451df..8639f622cd7 100644
--- a/src/test/ui/feature-gates/feature-gate-concat_idents.stderr
+++ b/src/test/ui/feature-gates/feature-gate-concat_idents.stderr
@@ -2,7 +2,7 @@ error[E0658]: use of unstable library feature 'concat_idents': `concat_idents` i
   --> $DIR/feature-gate-concat_idents.rs:5:13
    |
 LL |     let a = concat_idents!(X, Y_1);
-   |             ^^^^^^^^^^^^^^^^^^^^^^
+   |             ^^^^^^^^^^^^^
    |
    = note: for more information, see https://github.com/rust-lang/rust/issues/29599
    = help: add `#![feature(concat_idents)]` to the crate attributes to enable
@@ -11,7 +11,7 @@ error[E0658]: use of unstable library feature 'concat_idents': `concat_idents` i
   --> $DIR/feature-gate-concat_idents.rs:6:13
    |
 LL |     let b = concat_idents!(X, Y_2);
-   |             ^^^^^^^^^^^^^^^^^^^^^^
+   |             ^^^^^^^^^^^^^
    |
    = note: for more information, see https://github.com/rust-lang/rust/issues/29599
    = help: add `#![feature(concat_idents)]` to the crate attributes to enable
diff --git a/src/test/ui/feature-gates/feature-gate-concat_idents2.stderr b/src/test/ui/feature-gates/feature-gate-concat_idents2.stderr
index 4eb038b4a55..4ae5e3e7308 100644
--- a/src/test/ui/feature-gates/feature-gate-concat_idents2.stderr
+++ b/src/test/ui/feature-gates/feature-gate-concat_idents2.stderr
@@ -2,7 +2,7 @@ error[E0658]: use of unstable library feature 'concat_idents': `concat_idents` i
   --> $DIR/feature-gate-concat_idents2.rs:4:5
    |
 LL |     concat_idents!(a, b);
-   |     ^^^^^^^^^^^^^^^^^^^^^
+   |     ^^^^^^^^^^^^^
    |
    = note: for more information, see https://github.com/rust-lang/rust/issues/29599
    = help: add `#![feature(concat_idents)]` to the crate attributes to enable
diff --git a/src/test/ui/feature-gates/feature-gate-concat_idents3.stderr b/src/test/ui/feature-gates/feature-gate-concat_idents3.stderr
index e96cd4734d8..367638693d7 100644
--- a/src/test/ui/feature-gates/feature-gate-concat_idents3.stderr
+++ b/src/test/ui/feature-gates/feature-gate-concat_idents3.stderr
@@ -2,7 +2,7 @@ error[E0658]: use of unstable library feature 'concat_idents': `concat_idents` i
   --> $DIR/feature-gate-concat_idents3.rs:7:20
    |
 LL |     assert_eq!(10, concat_idents!(X, Y_1));
-   |                    ^^^^^^^^^^^^^^^^^^^^^^
+   |                    ^^^^^^^^^^^^^
    |
    = note: for more information, see https://github.com/rust-lang/rust/issues/29599
    = help: add `#![feature(concat_idents)]` to the crate attributes to enable
@@ -11,7 +11,7 @@ error[E0658]: use of unstable library feature 'concat_idents': `concat_idents` i
   --> $DIR/feature-gate-concat_idents3.rs:8:20
    |
 LL |     assert_eq!(20, concat_idents!(X, Y_2));
-   |                    ^^^^^^^^^^^^^^^^^^^^^^
+   |                    ^^^^^^^^^^^^^
    |
    = note: for more information, see https://github.com/rust-lang/rust/issues/29599
    = help: add `#![feature(concat_idents)]` to the crate attributes to enable
diff --git a/src/test/ui/feature-gates/feature-gate-format_args_nl.stderr b/src/test/ui/feature-gates/feature-gate-format_args_nl.stderr
index b836a508f7b..b211e2f8ed8 100644
--- a/src/test/ui/feature-gates/feature-gate-format_args_nl.stderr
+++ b/src/test/ui/feature-gates/feature-gate-format_args_nl.stderr
@@ -2,7 +2,7 @@ error[E0658]: use of unstable library feature 'format_args_nl': `format_args_nl`
   --> $DIR/feature-gate-format_args_nl.rs:2:5
    |
 LL |     format_args_nl!("");
-   |     ^^^^^^^^^^^^^^^^^^^^
+   |     ^^^^^^^^^^^^^^
    |
    = help: add `#![feature(format_args_nl)]` to the crate attributes to enable
 
diff --git a/src/test/ui/feature-gates/feature-gate-global_asm.stderr b/src/test/ui/feature-gates/feature-gate-global_asm.stderr
index 416078489f1..733b8d08f77 100644
--- a/src/test/ui/feature-gates/feature-gate-global_asm.stderr
+++ b/src/test/ui/feature-gates/feature-gate-global_asm.stderr
@@ -2,7 +2,7 @@ error[E0658]: use of unstable library feature 'global_asm': `global_asm!` is not
   --> $DIR/feature-gate-global_asm.rs:1:1
    |
 LL | global_asm!("");
-   | ^^^^^^^^^^^^^^^^
+   | ^^^^^^^^^^
    |
    = note: for more information, see https://github.com/rust-lang/rust/issues/35119
    = help: add `#![feature(global_asm)]` to the crate attributes to enable
diff --git a/src/test/ui/feature-gates/feature-gate-log_syntax.stderr b/src/test/ui/feature-gates/feature-gate-log_syntax.stderr
index 58f522cf823..fa57c20ecd5 100644
--- a/src/test/ui/feature-gates/feature-gate-log_syntax.stderr
+++ b/src/test/ui/feature-gates/feature-gate-log_syntax.stderr
@@ -2,7 +2,7 @@ error[E0658]: use of unstable library feature 'log_syntax': `log_syntax!` is not
   --> $DIR/feature-gate-log_syntax.rs:2:5
    |
 LL |     log_syntax!()
-   |     ^^^^^^^^^^^^^
+   |     ^^^^^^^^^^
    |
    = note: for more information, see https://github.com/rust-lang/rust/issues/29598
    = help: add `#![feature(log_syntax)]` to the crate attributes to enable
diff --git a/src/test/ui/feature-gates/feature-gate-log_syntax2.stderr b/src/test/ui/feature-gates/feature-gate-log_syntax2.stderr
index 3228b9c3013..0443b988b41 100644
--- a/src/test/ui/feature-gates/feature-gate-log_syntax2.stderr
+++ b/src/test/ui/feature-gates/feature-gate-log_syntax2.stderr
@@ -2,7 +2,7 @@ error[E0658]: use of unstable library feature 'log_syntax': `log_syntax!` is not
   --> $DIR/feature-gate-log_syntax2.rs:4:22
    |
 LL |     println!("{:?}", log_syntax!());
-   |                      ^^^^^^^^^^^^^
+   |                      ^^^^^^^^^^
    |
    = note: for more information, see https://github.com/rust-lang/rust/issues/29598
    = help: add `#![feature(log_syntax)]` to the crate attributes to enable
diff --git a/src/test/ui/feature-gates/feature-gate-trace_macros.stderr b/src/test/ui/feature-gates/feature-gate-trace_macros.stderr
index eb41ee45d22..cca08187527 100644
--- a/src/test/ui/feature-gates/feature-gate-trace_macros.stderr
+++ b/src/test/ui/feature-gates/feature-gate-trace_macros.stderr
@@ -2,7 +2,7 @@ error[E0658]: use of unstable library feature 'trace_macros': `trace_macros` is
   --> $DIR/feature-gate-trace_macros.rs:2:5
    |
 LL |     trace_macros!(true);
-   |     ^^^^^^^^^^^^^^^^^^^^
+   |     ^^^^^^^^^^^^
    |
    = note: for more information, see https://github.com/rust-lang/rust/issues/29598
    = help: add `#![feature(trace_macros)]` to the crate attributes to enable
diff --git a/src/test/ui/macros/macro-deprecation.stderr b/src/test/ui/macros/macro-deprecation.stderr
index e5f4df52237..4c2ad7d2fe9 100644
--- a/src/test/ui/macros/macro-deprecation.stderr
+++ b/src/test/ui/macros/macro-deprecation.stderr
@@ -2,7 +2,7 @@ warning: use of deprecated item 'local_deprecated': local deprecation note
   --> $DIR/macro-deprecation.rs:11:5
    |
 LL |     local_deprecated!();
-   |     ^^^^^^^^^^^^^^^^^^^^
+   |     ^^^^^^^^^^^^^^^^
    |
    = note: #[warn(deprecated)] on by default
 
@@ -10,5 +10,5 @@ warning: use of deprecated item 'deprecated_macro': deprecation note
   --> $DIR/macro-deprecation.rs:12:5
    |
 LL |     deprecated_macro!();
-   |     ^^^^^^^^^^^^^^^^^^^^
+   |     ^^^^^^^^^^^^^^^^
 
diff --git a/src/test/ui/macros/macro-stability.stderr b/src/test/ui/macros/macro-stability.stderr
index 6f84c450a2e..21c48bfe5e7 100644
--- a/src/test/ui/macros/macro-stability.stderr
+++ b/src/test/ui/macros/macro-stability.stderr
@@ -2,7 +2,7 @@ error[E0658]: use of unstable library feature 'local_unstable'
   --> $DIR/macro-stability.rs:19:5
    |
 LL |     local_unstable!();
-   |     ^^^^^^^^^^^^^^^^^^
+   |     ^^^^^^^^^^^^^^
    |
    = help: add `#![feature(local_unstable)]` to the crate attributes to enable
 
@@ -10,7 +10,7 @@ error[E0658]: use of unstable library feature 'local_unstable'
   --> $DIR/macro-stability.rs:20:5
    |
 LL |     local_unstable_modern!();
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^
+   |     ^^^^^^^^^^^^^^^^^^^^^
    |
    = help: add `#![feature(local_unstable)]` to the crate attributes to enable
 
@@ -18,7 +18,7 @@ error[E0658]: use of unstable library feature 'unstable_macros'
   --> $DIR/macro-stability.rs:21:5
    |
 LL |     unstable_macro!();
-   |     ^^^^^^^^^^^^^^^^^^
+   |     ^^^^^^^^^^^^^^
    |
    = help: add `#![feature(unstable_macros)]` to the crate attributes to enable
 
@@ -26,7 +26,7 @@ warning: use of deprecated item 'deprecated_macro': deprecation reason
   --> $DIR/macro-stability.rs:24:5
    |
 LL |     deprecated_macro!();
-   |     ^^^^^^^^^^^^^^^^^^^^
+   |     ^^^^^^^^^^^^^^^^
    |
    = note: #[warn(deprecated)] on by default
 
@@ -34,7 +34,7 @@ warning: use of deprecated item 'local_deprecated': local deprecation reason
   --> $DIR/macro-stability.rs:26:5
    |
 LL |     local_deprecated!();
-   |     ^^^^^^^^^^^^^^^^^^^^
+   |     ^^^^^^^^^^^^^^^^
 
 error: aborting due to 3 previous errors
 
diff --git a/src/test/ui/rust-unstable-column-gated.stderr b/src/test/ui/rust-unstable-column-gated.stderr
index f85122922c8..c581a16dbb0 100644
--- a/src/test/ui/rust-unstable-column-gated.stderr
+++ b/src/test/ui/rust-unstable-column-gated.stderr
@@ -2,7 +2,7 @@ error[E0658]: use of unstable library feature '__rust_unstable_column': internal
   --> $DIR/rust-unstable-column-gated.rs:2:20
    |
 LL |     println!("{}", __rust_unstable_column!());
-   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^
+   |                    ^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: add `#![feature(__rust_unstable_column)]` to the crate attributes to enable
 
diff --git a/src/test/ui/trace_macros-gate.stderr b/src/test/ui/trace_macros-gate.stderr
index adf813c162a..7b954273071 100644
--- a/src/test/ui/trace_macros-gate.stderr
+++ b/src/test/ui/trace_macros-gate.stderr
@@ -2,7 +2,7 @@ error[E0658]: use of unstable library feature 'trace_macros': `trace_macros` is
   --> $DIR/trace_macros-gate.rs:4:5
    |
 LL |     trace_macros!();
-   |     ^^^^^^^^^^^^^^^^
+   |     ^^^^^^^^^^^^
    |
    = note: for more information, see https://github.com/rust-lang/rust/issues/29598
    = help: add `#![feature(trace_macros)]` to the crate attributes to enable
@@ -17,7 +17,7 @@ error[E0658]: use of unstable library feature 'trace_macros': `trace_macros` is
   --> $DIR/trace_macros-gate.rs:6:5
    |
 LL |     trace_macros!(true);
-   |     ^^^^^^^^^^^^^^^^^^^^
+   |     ^^^^^^^^^^^^
    |
    = note: for more information, see https://github.com/rust-lang/rust/issues/29598
    = help: add `#![feature(trace_macros)]` to the crate attributes to enable
@@ -26,7 +26,7 @@ error[E0658]: use of unstable library feature 'trace_macros': `trace_macros` is
   --> $DIR/trace_macros-gate.rs:7:5
    |
 LL |     trace_macros!(false);
-   |     ^^^^^^^^^^^^^^^^^^^^^
+   |     ^^^^^^^^^^^^
    |
    = note: for more information, see https://github.com/rust-lang/rust/issues/29598
    = help: add `#![feature(trace_macros)]` to the crate attributes to enable
@@ -35,7 +35,7 @@ error[E0658]: use of unstable library feature 'trace_macros': `trace_macros` is
   --> $DIR/trace_macros-gate.rs:10:26
    |
 LL |         ($x: ident) => { trace_macros!($x) }
-   |                          ^^^^^^^^^^^^^^^^^
+   |                          ^^^^^^^^^^^^
 ...
 LL |     expando!(true);
    |     --------------- in this macro invocation