diff --git a/compiler/rustc_parse/src/parser/nonterminal.rs b/compiler/rustc_parse/src/parser/nonterminal.rs index c007f96a798..76ad5acd530 100644 --- a/compiler/rustc_parse/src/parser/nonterminal.rs +++ b/compiler/rustc_parse/src/parser/nonterminal.rs @@ -27,6 +27,8 @@ impl<'a> Parser<'a> { token.can_begin_expr() // This exception is here for backwards compatibility. && !token.is_keyword(kw::Let) + // This exception is here for backwards compatibility. + && !token.is_keyword(kw::Const) } NonterminalKind::Ty => token.can_begin_type(), NonterminalKind::Ident => get_macro_ident(token).is_some(), diff --git a/src/test/ui/inline-const/macro-with-const.rs b/src/test/ui/inline-const/macro-with-const.rs new file mode 100644 index 00000000000..e7393166d8d --- /dev/null +++ b/src/test/ui/inline-const/macro-with-const.rs @@ -0,0 +1,20 @@ +// check-pass + +macro_rules! exp { + (const $n:expr) => { + $n + }; +} + +macro_rules! stmt { + (exp $e:expr) => { + $e + }; + (exp $($t:tt)+) => { + exp!($($t)+) + }; +} + +fn main() { + stmt!(exp const 1); +}