@@ -624,6 +624,19 @@ impl CastExpr {
624624 pub fn ty ( & self ) -> Option < Type > { support:: child ( & self . syntax ) }
625625}
626626#[ 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 ) ]
627640pub struct ContinueExpr {
628641 pub ( crate ) syntax : SyntaxNode ,
629642}
@@ -690,28 +703,6 @@ impl IndexExpr {
690703 pub fn r_brack_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ ']' ] ) }
691704}
692705#[ 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 ) ]
715706pub struct LoopExpr {
716707 pub ( crate ) syntax : SyntaxNode ,
717708}
@@ -835,6 +826,15 @@ impl WhileExpr {
835826 pub fn condition ( & self ) -> Option < Condition > { support:: child ( & self . syntax ) }
836827}
837828#[ 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 ) ]
838838pub struct RecordExprFieldList {
839839 pub ( crate ) syntax : SyntaxNode ,
840840}
@@ -1337,14 +1337,13 @@ pub enum Expr {
13371337 BreakExpr ( BreakExpr ) ,
13381338 CallExpr ( CallExpr ) ,
13391339 CastExpr ( CastExpr ) ,
1340+ ClosureExpr ( ClosureExpr ) ,
13401341 ContinueExpr ( ContinueExpr ) ,
13411342 EffectExpr ( EffectExpr ) ,
13421343 FieldExpr ( FieldExpr ) ,
13431344 ForExpr ( ForExpr ) ,
13441345 IfExpr ( IfExpr ) ,
13451346 IndexExpr ( IndexExpr ) ,
1346- Label ( Label ) ,
1347- ClosureExpr ( ClosureExpr ) ,
13481347 Literal ( Literal ) ,
13491348 LoopExpr ( LoopExpr ) ,
13501349 MacroCall ( MacroCall ) ,
@@ -2017,6 +2016,17 @@ impl AstNode for CastExpr {
20172016 }
20182017 fn syntax ( & self ) -> & SyntaxNode { & self . syntax }
20192018}
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+ }
20202030impl AstNode for ContinueExpr {
20212031 fn can_cast ( kind : SyntaxKind ) -> bool { kind == CONTINUE_EXPR }
20222032 fn cast ( syntax : SyntaxNode ) -> Option < Self > {
@@ -2083,28 +2093,6 @@ impl AstNode for IndexExpr {
20832093 }
20842094 fn syntax ( & self ) -> & SyntaxNode { & self . syntax }
20852095}
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- }
21082096impl AstNode for LoopExpr {
21092097 fn can_cast ( kind : SyntaxKind ) -> bool { kind == LOOP_EXPR }
21102098 fn cast ( syntax : SyntaxNode ) -> Option < Self > {
@@ -2248,6 +2236,17 @@ impl AstNode for WhileExpr {
22482236 }
22492237 fn syntax ( & self ) -> & SyntaxNode { & self . syntax }
22502238}
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+ }
22512250impl AstNode for RecordExprFieldList {
22522251 fn can_cast ( kind : SyntaxKind ) -> bool { kind == RECORD_EXPR_FIELD_LIST }
22532252 fn cast ( syntax : SyntaxNode ) -> Option < Self > {
@@ -3086,6 +3085,9 @@ impl From<CallExpr> for Expr {
30863085impl From < CastExpr > for Expr {
30873086 fn from ( node : CastExpr ) -> Expr { Expr :: CastExpr ( node) }
30883087}
3088+ impl From < ClosureExpr > for Expr {
3089+ fn from ( node : ClosureExpr ) -> Expr { Expr :: ClosureExpr ( node) }
3090+ }
30893091impl From < ContinueExpr > for Expr {
30903092 fn from ( node : ContinueExpr ) -> Expr { Expr :: ContinueExpr ( node) }
30913093}
@@ -3104,12 +3106,6 @@ impl From<IfExpr> for Expr {
31043106impl From < IndexExpr > for Expr {
31053107 fn from ( node : IndexExpr ) -> Expr { Expr :: IndexExpr ( node) }
31063108}
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- }
31133109impl From < Literal > for Expr {
31143110 fn from ( node : Literal ) -> Expr { Expr :: Literal ( node) }
31153111}
@@ -3159,8 +3155,8 @@ impl AstNode for Expr {
31593155 fn can_cast ( kind : SyntaxKind ) -> bool {
31603156 match kind {
31613157 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
31643160 | METHOD_CALL_EXPR | PAREN_EXPR | PATH_EXPR | PREFIX_EXPR | RANGE_EXPR
31653161 | RECORD_EXPR | REF_EXPR | RETURN_EXPR | TRY_EXPR | TUPLE_EXPR | WHILE_EXPR => true ,
31663162 _ => false ,
@@ -3176,14 +3172,13 @@ impl AstNode for Expr {
31763172 BREAK_EXPR => Expr :: BreakExpr ( BreakExpr { syntax } ) ,
31773173 CALL_EXPR => Expr :: CallExpr ( CallExpr { syntax } ) ,
31783174 CAST_EXPR => Expr :: CastExpr ( CastExpr { syntax } ) ,
3175+ CLOSURE_EXPR => Expr :: ClosureExpr ( ClosureExpr { syntax } ) ,
31793176 CONTINUE_EXPR => Expr :: ContinueExpr ( ContinueExpr { syntax } ) ,
31803177 EFFECT_EXPR => Expr :: EffectExpr ( EffectExpr { syntax } ) ,
31813178 FIELD_EXPR => Expr :: FieldExpr ( FieldExpr { syntax } ) ,
31823179 FOR_EXPR => Expr :: ForExpr ( ForExpr { syntax } ) ,
31833180 IF_EXPR => Expr :: IfExpr ( IfExpr { syntax } ) ,
31843181 INDEX_EXPR => Expr :: IndexExpr ( IndexExpr { syntax } ) ,
3185- LABEL => Expr :: Label ( Label { syntax } ) ,
3186- CLOSURE_EXPR => Expr :: ClosureExpr ( ClosureExpr { syntax } ) ,
31873182 LITERAL => Expr :: Literal ( Literal { syntax } ) ,
31883183 LOOP_EXPR => Expr :: LoopExpr ( LoopExpr { syntax } ) ,
31893184 MACRO_CALL => Expr :: MacroCall ( MacroCall { syntax } ) ,
@@ -3213,14 +3208,13 @@ impl AstNode for Expr {
32133208 Expr :: BreakExpr ( it) => & it. syntax ,
32143209 Expr :: CallExpr ( it) => & it. syntax ,
32153210 Expr :: CastExpr ( it) => & it. syntax ,
3211+ Expr :: ClosureExpr ( it) => & it. syntax ,
32163212 Expr :: ContinueExpr ( it) => & it. syntax ,
32173213 Expr :: EffectExpr ( it) => & it. syntax ,
32183214 Expr :: FieldExpr ( it) => & it. syntax ,
32193215 Expr :: ForExpr ( it) => & it. syntax ,
32203216 Expr :: IfExpr ( it) => & it. syntax ,
32213217 Expr :: IndexExpr ( it) => & it. syntax ,
3222- Expr :: Label ( it) => & it. syntax ,
3223- Expr :: ClosureExpr ( it) => & it. syntax ,
32243218 Expr :: Literal ( it) => & it. syntax ,
32253219 Expr :: LoopExpr ( it) => & it. syntax ,
32263220 Expr :: MacroCall ( it) => & it. syntax ,
@@ -3715,6 +3709,11 @@ impl std::fmt::Display for CastExpr {
37153709 std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
37163710 }
37173711}
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+ }
37183717impl std:: fmt:: Display for ContinueExpr {
37193718 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
37203719 std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
@@ -3745,16 +3744,6 @@ impl std::fmt::Display for IndexExpr {
37453744 std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
37463745 }
37473746}
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- }
37583747impl std:: fmt:: Display for LoopExpr {
37593748 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
37603749 std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
@@ -3820,6 +3809,11 @@ impl std::fmt::Display for WhileExpr {
38203809 std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
38213810 }
38223811}
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+ }
38233817impl std:: fmt:: Display for RecordExprFieldList {
38243818 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
38253819 std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
0 commit comments