@@ -59,8 +59,9 @@ impl PathSegment {
59
59
pub fn param_list ( & self ) -> Option < ParamList > { support:: child ( & self . syntax ) }
60
60
pub fn ret_type ( & self ) -> Option < RetType > { support:: child ( & self . syntax ) }
61
61
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 ) }
63
63
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 ) }
64
65
pub fn r_angle_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ >] ) }
65
66
}
66
67
@@ -1576,14 +1577,6 @@ impl RecordPatField {
1576
1577
pub fn pat ( & self ) -> Option < Pat > { support:: child ( & self . syntax ) }
1577
1578
}
1578
1579
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
-
1587
1580
#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
1588
1581
pub enum Type {
1589
1582
ArrayType ( ArrayType ) ,
@@ -1602,6 +1595,14 @@ pub enum Type {
1602
1595
TupleType ( TupleType ) ,
1603
1596
}
1604
1597
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
+
1605
1606
#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
1606
1607
pub enum Expr {
1607
1608
ArrayExpr ( ArrayExpr ) ,
@@ -3319,41 +3320,6 @@ impl AstNode for RecordPatField {
3319
3320
}
3320
3321
fn syntax ( & self ) -> & SyntaxNode { & self . syntax }
3321
3322
}
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
- }
3357
3323
impl From < ArrayType > for Type {
3358
3324
fn from ( node : ArrayType ) -> Type { Type :: ArrayType ( node) }
3359
3325
}
@@ -3455,6 +3421,41 @@ impl AstNode for Type {
3455
3421
}
3456
3422
}
3457
3423
}
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
+ }
3458
3459
impl From < ArrayExpr > for Expr {
3459
3460
fn from ( node : ArrayExpr ) -> Expr { Expr :: ArrayExpr ( node) }
3460
3461
}
@@ -4340,12 +4341,12 @@ impl AstNode for AnyHasVisibility {
4340
4341
}
4341
4342
fn syntax ( & self ) -> & SyntaxNode { & self . syntax }
4342
4343
}
4343
- impl std:: fmt:: Display for GenericArg {
4344
+ impl std:: fmt:: Display for Type {
4344
4345
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
4345
4346
std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
4346
4347
}
4347
4348
}
4348
- impl std:: fmt:: Display for Type {
4349
+ impl std:: fmt:: Display for GenericArg {
4349
4350
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
4350
4351
std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
4351
4352
}
0 commit comments