@@ -407,7 +407,21 @@ impl Trait {
407
407
pub fn auto_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ auto] ) }
408
408
pub fn trait_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ trait ] ) }
409
409
pub fn assoc_item_list ( & self ) -> Option < AssocItemList > { support:: child ( & self . syntax ) }
410
+ }
411
+
412
+ #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
413
+ pub struct TraitAlias {
414
+ pub ( crate ) syntax : SyntaxNode ,
415
+ }
416
+ impl ast:: HasAttrs for TraitAlias { }
417
+ impl ast:: HasName for TraitAlias { }
418
+ impl ast:: HasVisibility for TraitAlias { }
419
+ impl ast:: HasGenericParams for TraitAlias { }
420
+ impl ast:: HasDocComments for TraitAlias { }
421
+ impl TraitAlias {
422
+ pub fn trait_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ trait ] ) }
410
423
pub fn eq_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ =] ) }
424
+ pub fn type_bound_list ( & self ) -> Option < TypeBoundList > { support:: child ( & self . syntax ) }
411
425
pub fn semicolon_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ ; ] ) }
412
426
}
413
427
@@ -1573,6 +1587,7 @@ pub enum Item {
1573
1587
Static ( Static ) ,
1574
1588
Struct ( Struct ) ,
1575
1589
Trait ( Trait ) ,
1590
+ TraitAlias ( TraitAlias ) ,
1576
1591
TypeAlias ( TypeAlias ) ,
1577
1592
Union ( Union ) ,
1578
1593
Use ( Use ) ,
@@ -2058,6 +2073,17 @@ impl AstNode for Trait {
2058
2073
}
2059
2074
fn syntax ( & self ) -> & SyntaxNode { & self . syntax }
2060
2075
}
2076
+ impl AstNode for TraitAlias {
2077
+ fn can_cast ( kind : SyntaxKind ) -> bool { kind == TRAIT_ALIAS }
2078
+ fn cast ( syntax : SyntaxNode ) -> Option < Self > {
2079
+ if Self :: can_cast ( syntax. kind ( ) ) {
2080
+ Some ( Self { syntax } )
2081
+ } else {
2082
+ None
2083
+ }
2084
+ }
2085
+ fn syntax ( & self ) -> & SyntaxNode { & self . syntax }
2086
+ }
2061
2087
impl AstNode for TypeAlias {
2062
2088
fn can_cast ( kind : SyntaxKind ) -> bool { kind == TYPE_ALIAS }
2063
2089
fn cast ( syntax : SyntaxNode ) -> Option < Self > {
@@ -3570,6 +3596,9 @@ impl From<Struct> for Item {
3570
3596
impl From < Trait > for Item {
3571
3597
fn from ( node : Trait ) -> Item { Item :: Trait ( node) }
3572
3598
}
3599
+ impl From < TraitAlias > for Item {
3600
+ fn from ( node : TraitAlias ) -> Item { Item :: TraitAlias ( node) }
3601
+ }
3573
3602
impl From < TypeAlias > for Item {
3574
3603
fn from ( node : TypeAlias ) -> Item { Item :: TypeAlias ( node) }
3575
3604
}
@@ -3596,6 +3625,7 @@ impl AstNode for Item {
3596
3625
| STATIC
3597
3626
| STRUCT
3598
3627
| TRAIT
3628
+ | TRAIT_ALIAS
3599
3629
| TYPE_ALIAS
3600
3630
| UNION
3601
3631
| USE
@@ -3616,6 +3646,7 @@ impl AstNode for Item {
3616
3646
STATIC => Item :: Static ( Static { syntax } ) ,
3617
3647
STRUCT => Item :: Struct ( Struct { syntax } ) ,
3618
3648
TRAIT => Item :: Trait ( Trait { syntax } ) ,
3649
+ TRAIT_ALIAS => Item :: TraitAlias ( TraitAlias { syntax } ) ,
3619
3650
TYPE_ALIAS => Item :: TypeAlias ( TypeAlias { syntax } ) ,
3620
3651
UNION => Item :: Union ( Union { syntax } ) ,
3621
3652
USE => Item :: Use ( Use { syntax } ) ,
@@ -3638,6 +3669,7 @@ impl AstNode for Item {
3638
3669
Item :: Static ( it) => & it. syntax ,
3639
3670
Item :: Struct ( it) => & it. syntax ,
3640
3671
Item :: Trait ( it) => & it. syntax ,
3672
+ Item :: TraitAlias ( it) => & it. syntax ,
3641
3673
Item :: TypeAlias ( it) => & it. syntax ,
3642
3674
Item :: Union ( it) => & it. syntax ,
3643
3675
Item :: Use ( it) => & it. syntax ,
@@ -3950,6 +3982,7 @@ impl AstNode for AnyHasAttrs {
3950
3982
| STATIC
3951
3983
| STRUCT
3952
3984
| TRAIT
3985
+ | TRAIT_ALIAS
3953
3986
| TYPE_ALIAS
3954
3987
| UNION
3955
3988
| USE
@@ -4035,6 +4068,7 @@ impl AstNode for AnyHasDocComments {
4035
4068
| STATIC
4036
4069
| STRUCT
4037
4070
| TRAIT
4071
+ | TRAIT_ALIAS
4038
4072
| TYPE_ALIAS
4039
4073
| UNION
4040
4074
| USE
@@ -4056,7 +4090,7 @@ impl AnyHasGenericParams {
4056
4090
}
4057
4091
impl AstNode for AnyHasGenericParams {
4058
4092
fn can_cast ( kind : SyntaxKind ) -> bool {
4059
- matches ! ( kind, ENUM | FN | IMPL | STRUCT | TRAIT | TYPE_ALIAS | UNION )
4093
+ matches ! ( kind, ENUM | FN | IMPL | STRUCT | TRAIT | TRAIT_ALIAS | TYPE_ALIAS | UNION )
4060
4094
}
4061
4095
fn cast ( syntax : SyntaxNode ) -> Option < Self > {
4062
4096
Self :: can_cast ( syntax. kind ( ) ) . then_some ( AnyHasGenericParams { syntax } )
@@ -4108,6 +4142,7 @@ impl AstNode for AnyHasName {
4108
4142
| STATIC
4109
4143
| STRUCT
4110
4144
| TRAIT
4145
+ | TRAIT_ALIAS
4111
4146
| TYPE_ALIAS
4112
4147
| UNION
4113
4148
| RENAME
@@ -4163,6 +4198,7 @@ impl AstNode for AnyHasVisibility {
4163
4198
| STATIC
4164
4199
| STRUCT
4165
4200
| TRAIT
4201
+ | TRAIT_ALIAS
4166
4202
| TYPE_ALIAS
4167
4203
| UNION
4168
4204
| USE
@@ -4391,6 +4427,11 @@ impl std::fmt::Display for Trait {
4391
4427
std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
4392
4428
}
4393
4429
}
4430
+ impl std:: fmt:: Display for TraitAlias {
4431
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
4432
+ std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
4433
+ }
4434
+ }
4394
4435
impl std:: fmt:: Display for TypeAlias {
4395
4436
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
4396
4437
std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
0 commit comments