File tree 5 files changed +50
-4
lines changed
test_data/parser/inline/ok
5 files changed +50
-4
lines changed Original file line number Diff line number Diff line change @@ -152,7 +152,7 @@ pub(super) fn atom_expr(
152
152
m. complete ( p, BLOCK_EXPR )
153
153
}
154
154
155
- T ! [ static ] | T ! [ async ] | T ! [ move] | T ! [ |] => closure_expr ( p) ,
155
+ T ! [ const ] | T ! [ static ] | T ! [ async ] | T ! [ move] | T ! [ |] => closure_expr ( p) ,
156
156
T ! [ for ] if la == T ! [ <] => closure_expr ( p) ,
157
157
T ! [ for ] => for_expr ( p, None ) ,
158
158
@@ -255,7 +255,7 @@ fn array_expr(p: &mut Parser<'_>) -> CompletedMarker {
255
255
// }
256
256
fn closure_expr ( p : & mut Parser < ' _ > ) -> CompletedMarker {
257
257
assert ! ( match p. current( ) {
258
- T ![ static ] | T ![ async ] | T ![ move] | T ![ |] => true ,
258
+ T ![ const ] | T ! [ static ] | T ![ async ] | T ![ move] | T ![ |] => true ,
259
259
T ![ for ] => p. nth( 1 ) == T ![ <] ,
260
260
_ => false ,
261
261
} ) ;
@@ -265,7 +265,9 @@ fn closure_expr(p: &mut Parser<'_>) -> CompletedMarker {
265
265
if p. at ( T ! [ for ] ) {
266
266
types:: for_binder ( p) ;
267
267
}
268
-
268
+ // test const_closure
269
+ // fn main() { let cl = const || _ = 0; }
270
+ p. eat ( T ! [ const ] ) ;
269
271
p. eat ( T ! [ static ] ) ;
270
272
p. eat ( T ! [ async ] ) ;
271
273
p. eat ( T ! [ move] ) ;
Original file line number Diff line number Diff line change
1
+ SOURCE_FILE
2
+ FN
3
+ FN_KW "fn"
4
+ WHITESPACE " "
5
+ NAME
6
+ IDENT "main"
7
+ PARAM_LIST
8
+ L_PAREN "("
9
+ R_PAREN ")"
10
+ WHITESPACE " "
11
+ BLOCK_EXPR
12
+ STMT_LIST
13
+ L_CURLY "{"
14
+ WHITESPACE " "
15
+ LET_STMT
16
+ LET_KW "let"
17
+ WHITESPACE " "
18
+ IDENT_PAT
19
+ NAME
20
+ IDENT "cl"
21
+ WHITESPACE " "
22
+ EQ "="
23
+ WHITESPACE " "
24
+ CLOSURE_EXPR
25
+ CONST_KW "const"
26
+ WHITESPACE " "
27
+ PARAM_LIST
28
+ PIPE "|"
29
+ PIPE "|"
30
+ WHITESPACE " "
31
+ BIN_EXPR
32
+ UNDERSCORE_EXPR
33
+ UNDERSCORE "_"
34
+ WHITESPACE " "
35
+ EQ "="
36
+ WHITESPACE " "
37
+ LITERAL
38
+ INT_NUMBER "0"
39
+ SEMICOLON ";"
40
+ WHITESPACE " "
41
+ R_CURLY "}"
42
+ WHITESPACE "\n"
Original file line number Diff line number Diff line change
1
+ fn main ( ) { let cl = const || _ = 0 ; }
Original file line number Diff line number Diff line change @@ -452,7 +452,7 @@ FieldExpr =
452
452
Attr* Expr '.' NameRef
453
453
454
454
ClosureExpr =
455
- Attr* ('for' GenericParamList)? 'static'? 'async'? 'move'? ParamList RetType?
455
+ Attr* ('for' GenericParamList)? 'const'? ' static'? 'async'? 'move'? ParamList RetType?
456
456
body:Expr
457
457
458
458
IfExpr =
Original file line number Diff line number Diff line change @@ -842,6 +842,7 @@ impl ast::HasAttrs for ClosureExpr {}
842
842
impl ClosureExpr {
843
843
pub fn for_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ for ] ) }
844
844
pub fn generic_param_list ( & self ) -> Option < GenericParamList > { support:: child ( & self . syntax ) }
845
+ pub fn const_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ const ] ) }
845
846
pub fn static_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ static ] ) }
846
847
pub fn async_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ async ] ) }
847
848
pub fn move_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ move] ) }
You can’t perform that action at this time.
0 commit comments