summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser
diff options
context:
space:
mode:
authorJubilee <46493976+workingjubilee@users.noreply.github.com>2021-09-24 11:40:17 -0700
committerGitHub <noreply@github.com>2021-09-24 11:40:17 -0700
commit6f31fa58fd0c4c045f4dd71170868750739e1135 (patch)
tree249a612e324ee01edef9bdca0e7abb96bd325ef4 /compiler/rustc_parse/src/parser
parent0cd9dd3b3c1aaeb2f2ee6567f6aaaca7d7e5f873 (diff)
parented3b751799b0d9a754846bd754d9b43cf6c7394b (diff)
downloadrust-6f31fa58fd0c4c045f4dd71170868750739e1135.tar.gz
rust-6f31fa58fd0c4c045f4dd71170868750739e1135.zip
Rollup merge of #89221 - aDotInTheVoid:macro-error-1, r=estebank
Give better error for `macro_rules! name!`

r? ``@estebank``

``@rustbot`` modify labels: +A-diagnostics +A-parser
Diffstat (limited to 'compiler/rustc_parse/src/parser')
-rw-r--r--compiler/rustc_parse/src/parser/item.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs
index 0e2222bf840..624390a406f 100644
--- a/compiler/rustc_parse/src/parser/item.rs
+++ b/compiler/rustc_parse/src/parser/item.rs
@@ -1547,6 +1547,20 @@ impl<'a> Parser<'a> {
         self.expect(&token::Not)?; // `!`
 
         let ident = self.parse_ident()?;
+
+        if self.eat(&token::Not) {
+            // Handle macro_rules! foo!
+            let span = self.prev_token.span;
+            self.struct_span_err(span, "macro names aren't followed by a `!`")
+                .span_suggestion(
+                    span,
+                    "remove the `!`",
+                    "".to_owned(),
+                    Applicability::MachineApplicable,
+                )
+                .emit();
+        }
+
         let body = self.parse_mac_args()?;
         self.eat_semi_for_macro_if_needed(&body);
         self.complain_if_pub_macro(vis, true);