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> {
20
20
pub fn nonterminal_may_begin_with ( kind : NonterminalKind , token : & Token ) -> bool {
21
21
/// Checks whether the non-terminal may contain a single (non-keyword) identifier.
22
22
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
+ }
24
38
}
25
39
26
40
match kind {
@@ -41,10 +55,11 @@ impl<'a> Parser<'a> {
41
55
} ,
42
56
NonterminalKind :: Block => match & token. kind {
43
57
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
+ } ,
48
63
_ => false ,
49
64
} ,
50
65
NonterminalKind :: Path | NonterminalKind :: Meta => match & token. kind {
You can’t perform that action at this time.
0 commit comments