File tree Expand file tree Collapse file tree 1 file changed +20
-5
lines changed
compiler/rustc_parse/src/parser Expand file tree Collapse file tree 1 file changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,21 @@ impl<'a> Parser<'a> {
2020 pub fn nonterminal_may_begin_with ( kind : NonterminalKind , token : & Token ) -> bool {
2121 /// Checks whether the non-terminal may contain a single (non-keyword) identifier.
2222 fn may_be_ident ( nt : & token:: Nonterminal ) -> bool {
23- !matches ! ( * nt, NtItem ( _) | NtBlock ( _) | NtVis ( _) | NtLifetime ( _) )
23+ match nt {
24+ NtStmt ( _)
25+ | NtPat ( _)
26+ | NtExpr ( _)
27+ | NtTy ( _)
28+ | NtIdent ( ..)
29+ | NtLiteral ( _) // `true`, `false`
30+ | NtMeta ( _)
31+ | NtPath ( _) => true ,
32+
33+ NtItem ( _)
34+ | NtBlock ( _)
35+ | NtVis ( _)
36+ | NtLifetime ( _) => false ,
37+ }
2438 }
2539
2640 match kind {
@@ -41,10 +55,11 @@ impl<'a> Parser<'a> {
4155 } ,
4256 NonterminalKind :: Block => match & token. kind {
4357 token:: OpenDelim ( Delimiter :: Brace ) => true ,
44- token:: Interpolated ( nt) => !matches ! (
45- * * nt,
46- NtItem ( _) | NtPat ( _) | NtTy ( _) | NtIdent ( ..) | NtMeta ( _) | NtPath ( _) | NtVis ( _)
47- ) ,
58+ token:: Interpolated ( nt) => match * * nt {
59+ NtBlock ( _) | NtLifetime ( _) | NtStmt ( _) | NtExpr ( _) | NtLiteral ( _) => true ,
60+ NtItem ( _) | NtPat ( _) | NtTy ( _) | NtIdent ( ..) | NtMeta ( _) | NtPath ( _)
61+ | NtVis ( _) => false ,
62+ } ,
4863 _ => false ,
4964 } ,
5065 NonterminalKind :: Path | NonterminalKind :: Meta => match & token. kind {
You can’t perform that action at this time.
0 commit comments