@@ -142,6 +142,18 @@ impl ConstArg {
142142 pub fn expr ( & self ) -> Option < Expr > { support:: child ( & self . syntax ) }
143143}
144144
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+
145157#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
146158pub struct TypeBoundList {
147159 pub ( crate ) syntax : SyntaxNode ,
@@ -1516,6 +1528,7 @@ pub enum GenericArg {
15161528 AssocTypeArg ( AssocTypeArg ) ,
15171529 LifetimeArg ( LifetimeArg ) ,
15181530 ConstArg ( ConstArg ) ,
1531+ ReturnTypeArg ( ReturnTypeArg ) ,
15191532}
15201533
15211534#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
@@ -1865,6 +1878,17 @@ impl AstNode for ConstArg {
18651878 }
18661879 fn syntax ( & self ) -> & SyntaxNode { & self . syntax }
18671880}
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+ }
18681892impl AstNode for TypeBoundList {
18691893 fn can_cast ( kind : SyntaxKind ) -> bool { kind == TYPE_BOUND_LIST }
18701894 fn cast ( syntax : SyntaxNode ) -> Option < Self > {
@@ -3219,16 +3243,20 @@ impl From<LifetimeArg> for GenericArg {
32193243impl From < ConstArg > for GenericArg {
32203244 fn from ( node : ConstArg ) -> GenericArg { GenericArg :: ConstArg ( node) }
32213245}
3246+ impl From < ReturnTypeArg > for GenericArg {
3247+ fn from ( node : ReturnTypeArg ) -> GenericArg { GenericArg :: ReturnTypeArg ( node) }
3248+ }
32223249impl AstNode for GenericArg {
32233250 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 )
32253252 }
32263253 fn cast ( syntax : SyntaxNode ) -> Option < Self > {
32273254 let res = match syntax. kind ( ) {
32283255 TYPE_ARG => GenericArg :: TypeArg ( TypeArg { syntax } ) ,
32293256 ASSOC_TYPE_ARG => GenericArg :: AssocTypeArg ( AssocTypeArg { syntax } ) ,
32303257 LIFETIME_ARG => GenericArg :: LifetimeArg ( LifetimeArg { syntax } ) ,
32313258 CONST_ARG => GenericArg :: ConstArg ( ConstArg { syntax } ) ,
3259+ RETURN_TYPE_ARG => GenericArg :: ReturnTypeArg ( ReturnTypeArg { syntax } ) ,
32323260 _ => return None ,
32333261 } ;
32343262 Some ( res)
@@ -3239,6 +3267,7 @@ impl AstNode for GenericArg {
32393267 GenericArg :: AssocTypeArg ( it) => & it. syntax ,
32403268 GenericArg :: LifetimeArg ( it) => & it. syntax ,
32413269 GenericArg :: ConstArg ( it) => & it. syntax ,
3270+ GenericArg :: ReturnTypeArg ( it) => & it. syntax ,
32423271 }
32433272 }
32443273}
@@ -4170,7 +4199,13 @@ impl AstNode for AnyHasTypeBounds {
41704199 fn can_cast ( kind : SyntaxKind ) -> bool {
41714200 matches ! (
41724201 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
41744209 )
41754210 }
41764211 fn cast ( syntax : SyntaxNode ) -> Option < Self > {
@@ -4333,6 +4368,11 @@ impl std::fmt::Display for ConstArg {
43334368 std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
43344369 }
43354370}
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+ }
43364376impl std:: fmt:: Display for TypeBoundList {
43374377 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
43384378 std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
0 commit comments