@@ -624,6 +624,19 @@ impl CastExpr {
624
624
pub fn ty ( & self ) -> Option < Type > { support:: child ( & self . syntax ) }
625
625
}
626
626
#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
627
+ pub struct ClosureExpr {
628
+ pub ( crate ) syntax : SyntaxNode ,
629
+ }
630
+ impl ast:: AttrsOwner for ClosureExpr { }
631
+ impl ClosureExpr {
632
+ pub fn static_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ static ] ) }
633
+ pub fn async_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ async ] ) }
634
+ pub fn move_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ move] ) }
635
+ pub fn param_list ( & self ) -> Option < ParamList > { support:: child ( & self . syntax ) }
636
+ pub fn ret_type ( & self ) -> Option < RetType > { support:: child ( & self . syntax ) }
637
+ pub fn body ( & self ) -> Option < Expr > { support:: child ( & self . syntax ) }
638
+ }
639
+ #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
627
640
pub struct ContinueExpr {
628
641
pub ( crate ) syntax : SyntaxNode ,
629
642
}
@@ -690,28 +703,6 @@ impl IndexExpr {
690
703
pub fn r_brack_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ ']' ] ) }
691
704
}
692
705
#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
693
- pub struct Label {
694
- pub ( crate ) syntax : SyntaxNode ,
695
- }
696
- impl Label {
697
- pub fn lifetime_token ( & self ) -> Option < SyntaxToken > {
698
- support:: token ( & self . syntax , T ! [ lifetime] )
699
- }
700
- }
701
- #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
702
- pub struct ClosureExpr {
703
- pub ( crate ) syntax : SyntaxNode ,
704
- }
705
- impl ast:: AttrsOwner for ClosureExpr { }
706
- impl ClosureExpr {
707
- pub fn static_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ static ] ) }
708
- pub fn async_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ async ] ) }
709
- pub fn move_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ move] ) }
710
- pub fn param_list ( & self ) -> Option < ParamList > { support:: child ( & self . syntax ) }
711
- pub fn ret_type ( & self ) -> Option < RetType > { support:: child ( & self . syntax ) }
712
- pub fn body ( & self ) -> Option < Expr > { support:: child ( & self . syntax ) }
713
- }
714
- #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
715
706
pub struct LoopExpr {
716
707
pub ( crate ) syntax : SyntaxNode ,
717
708
}
@@ -835,6 +826,15 @@ impl WhileExpr {
835
826
pub fn condition ( & self ) -> Option < Condition > { support:: child ( & self . syntax ) }
836
827
}
837
828
#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
829
+ pub struct Label {
830
+ pub ( crate ) syntax : SyntaxNode ,
831
+ }
832
+ impl Label {
833
+ pub fn lifetime_token ( & self ) -> Option < SyntaxToken > {
834
+ support:: token ( & self . syntax , T ! [ lifetime] )
835
+ }
836
+ }
837
+ #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
838
838
pub struct RecordExprFieldList {
839
839
pub ( crate ) syntax : SyntaxNode ,
840
840
}
@@ -1337,14 +1337,13 @@ pub enum Expr {
1337
1337
BreakExpr ( BreakExpr ) ,
1338
1338
CallExpr ( CallExpr ) ,
1339
1339
CastExpr ( CastExpr ) ,
1340
+ ClosureExpr ( ClosureExpr ) ,
1340
1341
ContinueExpr ( ContinueExpr ) ,
1341
1342
EffectExpr ( EffectExpr ) ,
1342
1343
FieldExpr ( FieldExpr ) ,
1343
1344
ForExpr ( ForExpr ) ,
1344
1345
IfExpr ( IfExpr ) ,
1345
1346
IndexExpr ( IndexExpr ) ,
1346
- Label ( Label ) ,
1347
- ClosureExpr ( ClosureExpr ) ,
1348
1347
Literal ( Literal ) ,
1349
1348
LoopExpr ( LoopExpr ) ,
1350
1349
MacroCall ( MacroCall ) ,
@@ -2017,6 +2016,17 @@ impl AstNode for CastExpr {
2017
2016
}
2018
2017
fn syntax ( & self ) -> & SyntaxNode { & self . syntax }
2019
2018
}
2019
+ impl AstNode for ClosureExpr {
2020
+ fn can_cast ( kind : SyntaxKind ) -> bool { kind == CLOSURE_EXPR }
2021
+ fn cast ( syntax : SyntaxNode ) -> Option < Self > {
2022
+ if Self :: can_cast ( syntax. kind ( ) ) {
2023
+ Some ( Self { syntax } )
2024
+ } else {
2025
+ None
2026
+ }
2027
+ }
2028
+ fn syntax ( & self ) -> & SyntaxNode { & self . syntax }
2029
+ }
2020
2030
impl AstNode for ContinueExpr {
2021
2031
fn can_cast ( kind : SyntaxKind ) -> bool { kind == CONTINUE_EXPR }
2022
2032
fn cast ( syntax : SyntaxNode ) -> Option < Self > {
@@ -2083,28 +2093,6 @@ impl AstNode for IndexExpr {
2083
2093
}
2084
2094
fn syntax ( & self ) -> & SyntaxNode { & self . syntax }
2085
2095
}
2086
- impl AstNode for Label {
2087
- fn can_cast ( kind : SyntaxKind ) -> bool { kind == LABEL }
2088
- fn cast ( syntax : SyntaxNode ) -> Option < Self > {
2089
- if Self :: can_cast ( syntax. kind ( ) ) {
2090
- Some ( Self { syntax } )
2091
- } else {
2092
- None
2093
- }
2094
- }
2095
- fn syntax ( & self ) -> & SyntaxNode { & self . syntax }
2096
- }
2097
- impl AstNode for ClosureExpr {
2098
- fn can_cast ( kind : SyntaxKind ) -> bool { kind == CLOSURE_EXPR }
2099
- fn cast ( syntax : SyntaxNode ) -> Option < Self > {
2100
- if Self :: can_cast ( syntax. kind ( ) ) {
2101
- Some ( Self { syntax } )
2102
- } else {
2103
- None
2104
- }
2105
- }
2106
- fn syntax ( & self ) -> & SyntaxNode { & self . syntax }
2107
- }
2108
2096
impl AstNode for LoopExpr {
2109
2097
fn can_cast ( kind : SyntaxKind ) -> bool { kind == LOOP_EXPR }
2110
2098
fn cast ( syntax : SyntaxNode ) -> Option < Self > {
@@ -2248,6 +2236,17 @@ impl AstNode for WhileExpr {
2248
2236
}
2249
2237
fn syntax ( & self ) -> & SyntaxNode { & self . syntax }
2250
2238
}
2239
+ impl AstNode for Label {
2240
+ fn can_cast ( kind : SyntaxKind ) -> bool { kind == LABEL }
2241
+ fn cast ( syntax : SyntaxNode ) -> Option < Self > {
2242
+ if Self :: can_cast ( syntax. kind ( ) ) {
2243
+ Some ( Self { syntax } )
2244
+ } else {
2245
+ None
2246
+ }
2247
+ }
2248
+ fn syntax ( & self ) -> & SyntaxNode { & self . syntax }
2249
+ }
2251
2250
impl AstNode for RecordExprFieldList {
2252
2251
fn can_cast ( kind : SyntaxKind ) -> bool { kind == RECORD_EXPR_FIELD_LIST }
2253
2252
fn cast ( syntax : SyntaxNode ) -> Option < Self > {
@@ -3086,6 +3085,9 @@ impl From<CallExpr> for Expr {
3086
3085
impl From < CastExpr > for Expr {
3087
3086
fn from ( node : CastExpr ) -> Expr { Expr :: CastExpr ( node) }
3088
3087
}
3088
+ impl From < ClosureExpr > for Expr {
3089
+ fn from ( node : ClosureExpr ) -> Expr { Expr :: ClosureExpr ( node) }
3090
+ }
3089
3091
impl From < ContinueExpr > for Expr {
3090
3092
fn from ( node : ContinueExpr ) -> Expr { Expr :: ContinueExpr ( node) }
3091
3093
}
@@ -3104,12 +3106,6 @@ impl From<IfExpr> for Expr {
3104
3106
impl From < IndexExpr > for Expr {
3105
3107
fn from ( node : IndexExpr ) -> Expr { Expr :: IndexExpr ( node) }
3106
3108
}
3107
- impl From < Label > for Expr {
3108
- fn from ( node : Label ) -> Expr { Expr :: Label ( node) }
3109
- }
3110
- impl From < ClosureExpr > for Expr {
3111
- fn from ( node : ClosureExpr ) -> Expr { Expr :: ClosureExpr ( node) }
3112
- }
3113
3109
impl From < Literal > for Expr {
3114
3110
fn from ( node : Literal ) -> Expr { Expr :: Literal ( node) }
3115
3111
}
@@ -3159,8 +3155,8 @@ impl AstNode for Expr {
3159
3155
fn can_cast ( kind : SyntaxKind ) -> bool {
3160
3156
match kind {
3161
3157
ARRAY_EXPR | AWAIT_EXPR | BIN_EXPR | BLOCK_EXPR | BOX_EXPR | BREAK_EXPR | CALL_EXPR
3162
- | CAST_EXPR | CONTINUE_EXPR | EFFECT_EXPR | FIELD_EXPR | FOR_EXPR | IF_EXPR
3163
- | INDEX_EXPR | LABEL | CLOSURE_EXPR | LITERAL | LOOP_EXPR | MACRO_CALL | MATCH_EXPR
3158
+ | CAST_EXPR | CLOSURE_EXPR | CONTINUE_EXPR | EFFECT_EXPR | FIELD_EXPR | FOR_EXPR
3159
+ | IF_EXPR | INDEX_EXPR | LITERAL | LOOP_EXPR | MACRO_CALL | MATCH_EXPR
3164
3160
| METHOD_CALL_EXPR | PAREN_EXPR | PATH_EXPR | PREFIX_EXPR | RANGE_EXPR
3165
3161
| RECORD_EXPR | REF_EXPR | RETURN_EXPR | TRY_EXPR | TUPLE_EXPR | WHILE_EXPR => true ,
3166
3162
_ => false ,
@@ -3176,14 +3172,13 @@ impl AstNode for Expr {
3176
3172
BREAK_EXPR => Expr :: BreakExpr ( BreakExpr { syntax } ) ,
3177
3173
CALL_EXPR => Expr :: CallExpr ( CallExpr { syntax } ) ,
3178
3174
CAST_EXPR => Expr :: CastExpr ( CastExpr { syntax } ) ,
3175
+ CLOSURE_EXPR => Expr :: ClosureExpr ( ClosureExpr { syntax } ) ,
3179
3176
CONTINUE_EXPR => Expr :: ContinueExpr ( ContinueExpr { syntax } ) ,
3180
3177
EFFECT_EXPR => Expr :: EffectExpr ( EffectExpr { syntax } ) ,
3181
3178
FIELD_EXPR => Expr :: FieldExpr ( FieldExpr { syntax } ) ,
3182
3179
FOR_EXPR => Expr :: ForExpr ( ForExpr { syntax } ) ,
3183
3180
IF_EXPR => Expr :: IfExpr ( IfExpr { syntax } ) ,
3184
3181
INDEX_EXPR => Expr :: IndexExpr ( IndexExpr { syntax } ) ,
3185
- LABEL => Expr :: Label ( Label { syntax } ) ,
3186
- CLOSURE_EXPR => Expr :: ClosureExpr ( ClosureExpr { syntax } ) ,
3187
3182
LITERAL => Expr :: Literal ( Literal { syntax } ) ,
3188
3183
LOOP_EXPR => Expr :: LoopExpr ( LoopExpr { syntax } ) ,
3189
3184
MACRO_CALL => Expr :: MacroCall ( MacroCall { syntax } ) ,
@@ -3213,14 +3208,13 @@ impl AstNode for Expr {
3213
3208
Expr :: BreakExpr ( it) => & it. syntax ,
3214
3209
Expr :: CallExpr ( it) => & it. syntax ,
3215
3210
Expr :: CastExpr ( it) => & it. syntax ,
3211
+ Expr :: ClosureExpr ( it) => & it. syntax ,
3216
3212
Expr :: ContinueExpr ( it) => & it. syntax ,
3217
3213
Expr :: EffectExpr ( it) => & it. syntax ,
3218
3214
Expr :: FieldExpr ( it) => & it. syntax ,
3219
3215
Expr :: ForExpr ( it) => & it. syntax ,
3220
3216
Expr :: IfExpr ( it) => & it. syntax ,
3221
3217
Expr :: IndexExpr ( it) => & it. syntax ,
3222
- Expr :: Label ( it) => & it. syntax ,
3223
- Expr :: ClosureExpr ( it) => & it. syntax ,
3224
3218
Expr :: Literal ( it) => & it. syntax ,
3225
3219
Expr :: LoopExpr ( it) => & it. syntax ,
3226
3220
Expr :: MacroCall ( it) => & it. syntax ,
@@ -3715,6 +3709,11 @@ impl std::fmt::Display for CastExpr {
3715
3709
std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
3716
3710
}
3717
3711
}
3712
+ impl std:: fmt:: Display for ClosureExpr {
3713
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
3714
+ std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
3715
+ }
3716
+ }
3718
3717
impl std:: fmt:: Display for ContinueExpr {
3719
3718
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
3720
3719
std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
@@ -3745,16 +3744,6 @@ impl std::fmt::Display for IndexExpr {
3745
3744
std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
3746
3745
}
3747
3746
}
3748
- impl std:: fmt:: Display for Label {
3749
- fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
3750
- std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
3751
- }
3752
- }
3753
- impl std:: fmt:: Display for ClosureExpr {
3754
- fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
3755
- std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
3756
- }
3757
- }
3758
3747
impl std:: fmt:: Display for LoopExpr {
3759
3748
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
3760
3749
std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
@@ -3820,6 +3809,11 @@ impl std::fmt::Display for WhileExpr {
3820
3809
std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
3821
3810
}
3822
3811
}
3812
+ impl std:: fmt:: Display for Label {
3813
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
3814
+ std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
3815
+ }
3816
+ }
3823
3817
impl std:: fmt:: Display for RecordExprFieldList {
3824
3818
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
3825
3819
std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
0 commit comments