File tree Expand file tree Collapse file tree 4 files changed +38
-0
lines changed
compiler/rustc_parse/src/parser Expand file tree Collapse file tree 4 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -1547,6 +1547,20 @@ impl<'a> Parser<'a> {
15471547 self . expect ( & token:: Not ) ?; // `!`
15481548
15491549 let ident = self . parse_ident ( ) ?;
1550+
1551+ if self . eat ( & token:: Not ) {
1552+ // Handle macro_rules! foo!
1553+ let span = self . prev_token . span ;
1554+ self . struct_span_err ( span, "macro names aren't followed by a `!`" )
1555+ . span_suggestion (
1556+ span,
1557+ "remove the `!`" ,
1558+ "" . to_owned ( ) ,
1559+ Applicability :: MachineApplicable ,
1560+ )
1561+ . emit ( ) ;
1562+ }
1563+
15501564 let body = self . parse_mac_args ( ) ?;
15511565 self . eat_semi_for_macro_if_needed ( & body) ;
15521566 self . complain_if_pub_macro ( vis, true ) ;
Original file line number Diff line number Diff line change 1+ // run-rustfix
2+ #[allow(unused_macros)]
3+
4+ macro_rules! foo { //~ ERROR macro names aren't followed by a `!`
5+ () => {};
6+ }
7+
8+ fn main() {}
Original file line number Diff line number Diff line change 1+ // run-rustfix
2+ #[ allow( unused_macros) ]
3+
4+ macro_rules! foo! { //~ ERROR macro names aren't followed by a `!`
5+ ( ) => { } ;
6+ }
7+
8+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ error: macro names aren't followed by a `!`
2+ --> $DIR/bang-after-name.rs:4:17
3+ |
4+ LL | macro_rules! foo! {
5+ | ^ help: remove the `!`
6+
7+ error: aborting due to previous error
8+
You can’t perform that action at this time.
0 commit comments