Rollup merge of #80135 - camelid:const-macro-nt, r=petrochenkov
Don't allow `const` to begin a nonterminal Fixes #79908. Thanks to Vadim Petrochenkov who [told me what the fix was][z]! [z]: https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/finding.20which.20macro.20rule.20to.20use/near/220240422 r? ``@petrochenkov``
This commit is contained in:
commit
926999513e
@ -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(),
|
||||
|
20
src/test/ui/inline-const/macro-with-const.rs
Normal file
20
src/test/ui/inline-const/macro-with-const.rs
Normal file
@ -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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user