@@ -142,6 +142,18 @@ impl ConstArg {
142
142
pub fn expr ( & self ) -> Option < Expr > { support:: child ( & self . syntax ) }
143
143
}
144
144
145
+ #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
146
+ pub struct ReturnTypeArg {
147
+ pub ( crate ) syntax : SyntaxNode ,
148
+ }
149
+ impl ast:: HasTypeBounds for ReturnTypeArg { }
150
+ impl ReturnTypeArg {
151
+ pub fn name_ref ( & self ) -> Option < NameRef > { support:: child ( & self . syntax ) }
152
+ pub fn l_paren_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ '(' ] ) }
153
+ pub fn dotdot_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ ..] ) }
154
+ pub fn r_paren_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ ')' ] ) }
155
+ }
156
+
145
157
#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
146
158
pub struct TypeBoundList {
147
159
pub ( crate ) syntax : SyntaxNode ,
@@ -1516,6 +1528,7 @@ pub enum GenericArg {
1516
1528
AssocTypeArg ( AssocTypeArg ) ,
1517
1529
LifetimeArg ( LifetimeArg ) ,
1518
1530
ConstArg ( ConstArg ) ,
1531
+ ReturnTypeArg ( ReturnTypeArg ) ,
1519
1532
}
1520
1533
1521
1534
#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
@@ -1865,6 +1878,17 @@ impl AstNode for ConstArg {
1865
1878
}
1866
1879
fn syntax ( & self ) -> & SyntaxNode { & self . syntax }
1867
1880
}
1881
+ impl AstNode for ReturnTypeArg {
1882
+ fn can_cast ( kind : SyntaxKind ) -> bool { kind == RETURN_TYPE_ARG }
1883
+ fn cast ( syntax : SyntaxNode ) -> Option < Self > {
1884
+ if Self :: can_cast ( syntax. kind ( ) ) {
1885
+ Some ( Self { syntax } )
1886
+ } else {
1887
+ None
1888
+ }
1889
+ }
1890
+ fn syntax ( & self ) -> & SyntaxNode { & self . syntax }
1891
+ }
1868
1892
impl AstNode for TypeBoundList {
1869
1893
fn can_cast ( kind : SyntaxKind ) -> bool { kind == TYPE_BOUND_LIST }
1870
1894
fn cast ( syntax : SyntaxNode ) -> Option < Self > {
@@ -3219,16 +3243,20 @@ impl From<LifetimeArg> for GenericArg {
3219
3243
impl From < ConstArg > for GenericArg {
3220
3244
fn from ( node : ConstArg ) -> GenericArg { GenericArg :: ConstArg ( node) }
3221
3245
}
3246
+ impl From < ReturnTypeArg > for GenericArg {
3247
+ fn from ( node : ReturnTypeArg ) -> GenericArg { GenericArg :: ReturnTypeArg ( node) }
3248
+ }
3222
3249
impl AstNode for GenericArg {
3223
3250
fn can_cast ( kind : SyntaxKind ) -> bool {
3224
- matches ! ( kind, TYPE_ARG | ASSOC_TYPE_ARG | LIFETIME_ARG | CONST_ARG )
3251
+ matches ! ( kind, TYPE_ARG | ASSOC_TYPE_ARG | LIFETIME_ARG | CONST_ARG | RETURN_TYPE_ARG )
3225
3252
}
3226
3253
fn cast ( syntax : SyntaxNode ) -> Option < Self > {
3227
3254
let res = match syntax. kind ( ) {
3228
3255
TYPE_ARG => GenericArg :: TypeArg ( TypeArg { syntax } ) ,
3229
3256
ASSOC_TYPE_ARG => GenericArg :: AssocTypeArg ( AssocTypeArg { syntax } ) ,
3230
3257
LIFETIME_ARG => GenericArg :: LifetimeArg ( LifetimeArg { syntax } ) ,
3231
3258
CONST_ARG => GenericArg :: ConstArg ( ConstArg { syntax } ) ,
3259
+ RETURN_TYPE_ARG => GenericArg :: ReturnTypeArg ( ReturnTypeArg { syntax } ) ,
3232
3260
_ => return None ,
3233
3261
} ;
3234
3262
Some ( res)
@@ -3239,6 +3267,7 @@ impl AstNode for GenericArg {
3239
3267
GenericArg :: AssocTypeArg ( it) => & it. syntax ,
3240
3268
GenericArg :: LifetimeArg ( it) => & it. syntax ,
3241
3269
GenericArg :: ConstArg ( it) => & it. syntax ,
3270
+ GenericArg :: ReturnTypeArg ( it) => & it. syntax ,
3242
3271
}
3243
3272
}
3244
3273
}
@@ -4170,7 +4199,13 @@ impl AstNode for AnyHasTypeBounds {
4170
4199
fn can_cast ( kind : SyntaxKind ) -> bool {
4171
4200
matches ! (
4172
4201
kind,
4173
- ASSOC_TYPE_ARG | TRAIT | TYPE_ALIAS | LIFETIME_PARAM | TYPE_PARAM | WHERE_PRED
4202
+ ASSOC_TYPE_ARG
4203
+ | RETURN_TYPE_ARG
4204
+ | TRAIT
4205
+ | TYPE_ALIAS
4206
+ | LIFETIME_PARAM
4207
+ | TYPE_PARAM
4208
+ | WHERE_PRED
4174
4209
)
4175
4210
}
4176
4211
fn cast ( syntax : SyntaxNode ) -> Option < Self > {
@@ -4333,6 +4368,11 @@ impl std::fmt::Display for ConstArg {
4333
4368
std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
4334
4369
}
4335
4370
}
4371
+ impl std:: fmt:: Display for ReturnTypeArg {
4372
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
4373
+ std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
4374
+ }
4375
+ }
4336
4376
impl std:: fmt:: Display for TypeBoundList {
4337
4377
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
4338
4378
std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
0 commit comments