@@ -24,7 +24,8 @@ impl Attr {
24
24
pub fn l_brack_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ '[' ] ) }
25
25
pub fn path ( & self ) -> Option < Path > { support:: child ( & self . syntax ) }
26
26
pub fn eq_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ =] ) }
27
- pub fn input ( & self ) -> Option < AttrInput > { support:: child ( & self . syntax ) }
27
+ pub fn literal ( & self ) -> Option < Literal > { support:: child ( & self . syntax ) }
28
+ pub fn token_tree ( & self ) -> Option < TokenTree > { support:: child ( & self . syntax ) }
28
29
pub fn r_brack_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ ']' ] ) }
29
30
}
30
31
#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
@@ -321,9 +322,9 @@ pub struct ParamList {
321
322
}
322
323
impl ParamList {
323
324
pub fn l_paren_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ '(' ] ) }
324
- pub fn params ( & self ) -> AstChildren < Param > { support:: children ( & self . syntax ) }
325
325
pub fn self_param ( & self ) -> Option < SelfParam > { support:: child ( & self . syntax ) }
326
326
pub fn comma_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ , ] ) }
327
+ pub fn params ( & self ) -> AstChildren < Param > { support:: children ( & self . syntax ) }
327
328
pub fn r_paren_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ ')' ] ) }
328
329
}
329
330
#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
@@ -356,17 +357,6 @@ impl BlockExpr {
356
357
pub fn r_curly_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ '}' ] ) }
357
358
}
358
359
#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
359
- pub struct Param {
360
- pub ( crate ) syntax : SyntaxNode ,
361
- }
362
- impl ast:: AttrsOwner for Param { }
363
- impl ast:: TypeAscriptionOwner for Param { }
364
- impl Param {
365
- pub fn pat ( & self ) -> Option < Pat > { support:: child ( & self . syntax ) }
366
- pub fn colon_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ : ] ) }
367
- pub fn dotdotdot_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ ...] ) }
368
- }
369
- #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
370
360
pub struct SelfParam {
371
361
pub ( crate ) syntax : SyntaxNode ,
372
362
}
@@ -382,6 +372,17 @@ impl SelfParam {
382
372
pub fn colon_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ : ] ) }
383
373
}
384
374
#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
375
+ pub struct Param {
376
+ pub ( crate ) syntax : SyntaxNode ,
377
+ }
378
+ impl ast:: AttrsOwner for Param { }
379
+ impl ast:: TypeAscriptionOwner for Param { }
380
+ impl Param {
381
+ pub fn pat ( & self ) -> Option < Pat > { support:: child ( & self . syntax ) }
382
+ pub fn colon_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ : ] ) }
383
+ pub fn dotdotdot_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ ...] ) }
384
+ }
385
+ #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
385
386
pub struct TypeBoundList {
386
387
pub ( crate ) syntax : SyntaxNode ,
387
388
}
@@ -1378,11 +1379,6 @@ pub enum GenericParam {
1378
1379
}
1379
1380
impl ast:: AttrsOwner for GenericParam { }
1380
1381
#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
1381
- pub enum AttrInput {
1382
- Literal ( Literal ) ,
1383
- TokenTree ( TokenTree ) ,
1384
- }
1385
- #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
1386
1382
pub enum Stmt {
1387
1383
LetStmt ( LetStmt ) ,
1388
1384
ExprStmt ( ExprStmt ) ,
@@ -1728,8 +1724,8 @@ impl AstNode for BlockExpr {
1728
1724
}
1729
1725
fn syntax ( & self ) -> & SyntaxNode { & self . syntax }
1730
1726
}
1731
- impl AstNode for Param {
1732
- fn can_cast ( kind : SyntaxKind ) -> bool { kind == PARAM }
1727
+ impl AstNode for SelfParam {
1728
+ fn can_cast ( kind : SyntaxKind ) -> bool { kind == SELF_PARAM }
1733
1729
fn cast ( syntax : SyntaxNode ) -> Option < Self > {
1734
1730
if Self :: can_cast ( syntax. kind ( ) ) {
1735
1731
Some ( Self { syntax } )
@@ -1739,8 +1735,8 @@ impl AstNode for Param {
1739
1735
}
1740
1736
fn syntax ( & self ) -> & SyntaxNode { & self . syntax }
1741
1737
}
1742
- impl AstNode for SelfParam {
1743
- fn can_cast ( kind : SyntaxKind ) -> bool { kind == SELF_PARAM }
1738
+ impl AstNode for Param {
1739
+ fn can_cast ( kind : SyntaxKind ) -> bool { kind == PARAM }
1744
1740
fn cast ( syntax : SyntaxNode ) -> Option < Self > {
1745
1741
if Self :: can_cast ( syntax. kind ( ) ) {
1746
1742
Some ( Self { syntax } )
@@ -3342,34 +3338,6 @@ impl AstNode for GenericParam {
3342
3338
}
3343
3339
}
3344
3340
}
3345
- impl From < Literal > for AttrInput {
3346
- fn from ( node : Literal ) -> AttrInput { AttrInput :: Literal ( node) }
3347
- }
3348
- impl From < TokenTree > for AttrInput {
3349
- fn from ( node : TokenTree ) -> AttrInput { AttrInput :: TokenTree ( node) }
3350
- }
3351
- impl AstNode for AttrInput {
3352
- fn can_cast ( kind : SyntaxKind ) -> bool {
3353
- match kind {
3354
- LITERAL | TOKEN_TREE => true ,
3355
- _ => false ,
3356
- }
3357
- }
3358
- fn cast ( syntax : SyntaxNode ) -> Option < Self > {
3359
- let res = match syntax. kind ( ) {
3360
- LITERAL => AttrInput :: Literal ( Literal { syntax } ) ,
3361
- TOKEN_TREE => AttrInput :: TokenTree ( TokenTree { syntax } ) ,
3362
- _ => return None ,
3363
- } ;
3364
- Some ( res)
3365
- }
3366
- fn syntax ( & self ) -> & SyntaxNode {
3367
- match self {
3368
- AttrInput :: Literal ( it) => & it. syntax ,
3369
- AttrInput :: TokenTree ( it) => & it. syntax ,
3370
- }
3371
- }
3372
- }
3373
3341
impl From < LetStmt > for Stmt {
3374
3342
fn from ( node : LetStmt ) -> Stmt { Stmt :: LetStmt ( node) }
3375
3343
}
@@ -3471,11 +3439,6 @@ impl std::fmt::Display for GenericParam {
3471
3439
std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
3472
3440
}
3473
3441
}
3474
- impl std:: fmt:: Display for AttrInput {
3475
- fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
3476
- std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
3477
- }
3478
- }
3479
3442
impl std:: fmt:: Display for Stmt {
3480
3443
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
3481
3444
std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
@@ -3636,12 +3599,12 @@ impl std::fmt::Display for BlockExpr {
3636
3599
std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
3637
3600
}
3638
3601
}
3639
- impl std:: fmt:: Display for Param {
3602
+ impl std:: fmt:: Display for SelfParam {
3640
3603
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
3641
3604
std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
3642
3605
}
3643
3606
}
3644
- impl std:: fmt:: Display for SelfParam {
3607
+ impl std:: fmt:: Display for Param {
3645
3608
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
3646
3609
std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
3647
3610
}
0 commit comments