@@ -59,8 +59,9 @@ impl PathSegment {
5959 pub fn param_list ( & self ) -> Option < ParamList > { support:: child ( & self . syntax ) }
6060 pub fn ret_type ( & self ) -> Option < RetType > { support:: child ( & self . syntax ) }
6161 pub fn l_angle_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ <] ) }
62- pub fn path_type ( & self ) -> Option < PathType > { support:: child ( & self . syntax ) }
62+ pub fn ty ( & self ) -> Option < Type > { support:: child ( & self . syntax ) }
6363 pub fn as_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ as ] ) }
64+ pub fn path_type ( & self ) -> Option < PathType > { support:: child ( & self . syntax ) }
6465 pub fn r_angle_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ >] ) }
6566}
6667
@@ -1576,14 +1577,6 @@ impl RecordPatField {
15761577 pub fn pat ( & self ) -> Option < Pat > { support:: child ( & self . syntax ) }
15771578}
15781579
1579- #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
1580- pub enum GenericArg {
1581- TypeArg ( TypeArg ) ,
1582- AssocTypeArg ( AssocTypeArg ) ,
1583- LifetimeArg ( LifetimeArg ) ,
1584- ConstArg ( ConstArg ) ,
1585- }
1586-
15871580#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
15881581pub enum Type {
15891582 ArrayType ( ArrayType ) ,
@@ -1602,6 +1595,14 @@ pub enum Type {
16021595 TupleType ( TupleType ) ,
16031596}
16041597
1598+ #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
1599+ pub enum GenericArg {
1600+ TypeArg ( TypeArg ) ,
1601+ AssocTypeArg ( AssocTypeArg ) ,
1602+ LifetimeArg ( LifetimeArg ) ,
1603+ ConstArg ( ConstArg ) ,
1604+ }
1605+
16051606#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
16061607pub enum Expr {
16071608 ArrayExpr ( ArrayExpr ) ,
@@ -3319,41 +3320,6 @@ impl AstNode for RecordPatField {
33193320 }
33203321 fn syntax ( & self ) -> & SyntaxNode { & self . syntax }
33213322}
3322- impl From < TypeArg > for GenericArg {
3323- fn from ( node : TypeArg ) -> GenericArg { GenericArg :: TypeArg ( node) }
3324- }
3325- impl From < AssocTypeArg > for GenericArg {
3326- fn from ( node : AssocTypeArg ) -> GenericArg { GenericArg :: AssocTypeArg ( node) }
3327- }
3328- impl From < LifetimeArg > for GenericArg {
3329- fn from ( node : LifetimeArg ) -> GenericArg { GenericArg :: LifetimeArg ( node) }
3330- }
3331- impl From < ConstArg > for GenericArg {
3332- fn from ( node : ConstArg ) -> GenericArg { GenericArg :: ConstArg ( node) }
3333- }
3334- impl AstNode for GenericArg {
3335- fn can_cast ( kind : SyntaxKind ) -> bool {
3336- matches ! ( kind, TYPE_ARG | ASSOC_TYPE_ARG | LIFETIME_ARG | CONST_ARG )
3337- }
3338- fn cast ( syntax : SyntaxNode ) -> Option < Self > {
3339- let res = match syntax. kind ( ) {
3340- TYPE_ARG => GenericArg :: TypeArg ( TypeArg { syntax } ) ,
3341- ASSOC_TYPE_ARG => GenericArg :: AssocTypeArg ( AssocTypeArg { syntax } ) ,
3342- LIFETIME_ARG => GenericArg :: LifetimeArg ( LifetimeArg { syntax } ) ,
3343- CONST_ARG => GenericArg :: ConstArg ( ConstArg { syntax } ) ,
3344- _ => return None ,
3345- } ;
3346- Some ( res)
3347- }
3348- fn syntax ( & self ) -> & SyntaxNode {
3349- match self {
3350- GenericArg :: TypeArg ( it) => & it. syntax ,
3351- GenericArg :: AssocTypeArg ( it) => & it. syntax ,
3352- GenericArg :: LifetimeArg ( it) => & it. syntax ,
3353- GenericArg :: ConstArg ( it) => & it. syntax ,
3354- }
3355- }
3356- }
33573323impl From < ArrayType > for Type {
33583324 fn from ( node : ArrayType ) -> Type { Type :: ArrayType ( node) }
33593325}
@@ -3455,6 +3421,41 @@ impl AstNode for Type {
34553421 }
34563422 }
34573423}
3424+ impl From < TypeArg > for GenericArg {
3425+ fn from ( node : TypeArg ) -> GenericArg { GenericArg :: TypeArg ( node) }
3426+ }
3427+ impl From < AssocTypeArg > for GenericArg {
3428+ fn from ( node : AssocTypeArg ) -> GenericArg { GenericArg :: AssocTypeArg ( node) }
3429+ }
3430+ impl From < LifetimeArg > for GenericArg {
3431+ fn from ( node : LifetimeArg ) -> GenericArg { GenericArg :: LifetimeArg ( node) }
3432+ }
3433+ impl From < ConstArg > for GenericArg {
3434+ fn from ( node : ConstArg ) -> GenericArg { GenericArg :: ConstArg ( node) }
3435+ }
3436+ impl AstNode for GenericArg {
3437+ fn can_cast ( kind : SyntaxKind ) -> bool {
3438+ matches ! ( kind, TYPE_ARG | ASSOC_TYPE_ARG | LIFETIME_ARG | CONST_ARG )
3439+ }
3440+ fn cast ( syntax : SyntaxNode ) -> Option < Self > {
3441+ let res = match syntax. kind ( ) {
3442+ TYPE_ARG => GenericArg :: TypeArg ( TypeArg { syntax } ) ,
3443+ ASSOC_TYPE_ARG => GenericArg :: AssocTypeArg ( AssocTypeArg { syntax } ) ,
3444+ LIFETIME_ARG => GenericArg :: LifetimeArg ( LifetimeArg { syntax } ) ,
3445+ CONST_ARG => GenericArg :: ConstArg ( ConstArg { syntax } ) ,
3446+ _ => return None ,
3447+ } ;
3448+ Some ( res)
3449+ }
3450+ fn syntax ( & self ) -> & SyntaxNode {
3451+ match self {
3452+ GenericArg :: TypeArg ( it) => & it. syntax ,
3453+ GenericArg :: AssocTypeArg ( it) => & it. syntax ,
3454+ GenericArg :: LifetimeArg ( it) => & it. syntax ,
3455+ GenericArg :: ConstArg ( it) => & it. syntax ,
3456+ }
3457+ }
3458+ }
34583459impl From < ArrayExpr > for Expr {
34593460 fn from ( node : ArrayExpr ) -> Expr { Expr :: ArrayExpr ( node) }
34603461}
@@ -4340,12 +4341,12 @@ impl AstNode for AnyHasVisibility {
43404341 }
43414342 fn syntax ( & self ) -> & SyntaxNode { & self . syntax }
43424343}
4343- impl std:: fmt:: Display for GenericArg {
4344+ impl std:: fmt:: Display for Type {
43444345 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
43454346 std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
43464347 }
43474348}
4348- impl std:: fmt:: Display for Type {
4349+ impl std:: fmt:: Display for GenericArg {
43494350 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
43504351 std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
43514352 }
0 commit comments