@@ -453,12 +453,23 @@ impl Variant {
453453pub struct AssocItemList {
454454 pub ( crate ) syntax : SyntaxNode ,
455455}
456+ impl ast:: AttrsOwner for AssocItemList { }
456457impl AssocItemList {
457458 pub fn l_curly_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ '{' ] ) }
458459 pub fn assoc_items ( & self ) -> AstChildren < AssocItem > { support:: children ( & self . syntax ) }
459460 pub fn r_curly_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ '}' ] ) }
460461}
461462#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
463+ pub struct ExternItemList {
464+ pub ( crate ) syntax : SyntaxNode ,
465+ }
466+ impl ast:: AttrsOwner for ExternItemList { }
467+ impl ExternItemList {
468+ pub fn l_curly_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ '{' ] ) }
469+ pub fn extern_items ( & self ) -> AstChildren < ExternItem > { support:: children ( & self . syntax ) }
470+ pub fn r_curly_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ '}' ] ) }
471+ }
472+ #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
462473pub struct ParenType {
463474 pub ( crate ) syntax : SyntaxNode ,
464475}
@@ -1254,15 +1265,6 @@ impl ConstArg {
12541265 pub fn block_expr ( & self ) -> Option < BlockExpr > { support:: child ( & self . syntax ) }
12551266}
12561267#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
1257- pub struct ExternItemList {
1258- pub ( crate ) syntax : SyntaxNode ,
1259- }
1260- impl ExternItemList {
1261- pub fn l_curly_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ '{' ] ) }
1262- pub fn extern_items ( & self ) -> AstChildren < ExternItem > { support:: children ( & self . syntax ) }
1263- pub fn r_curly_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ '}' ] ) }
1264- }
1265- #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
12661268pub struct MetaItem {
12671269 pub ( crate ) syntax : SyntaxNode ,
12681270}
@@ -1373,6 +1375,14 @@ pub enum AssocItem {
13731375impl ast:: AttrsOwner for AssocItem { }
13741376impl ast:: NameOwner for AssocItem { }
13751377#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
1378+ pub enum ExternItem {
1379+ Fn ( Fn ) ,
1380+ Static ( Static ) ,
1381+ MacroCall ( MacroCall ) ,
1382+ }
1383+ impl ast:: AttrsOwner for ExternItem { }
1384+ impl ast:: NameOwner for ExternItem { }
1385+ #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
13761386pub enum Stmt {
13771387 LetStmt ( LetStmt ) ,
13781388 ExprStmt ( ExprStmt ) ,
@@ -1384,14 +1394,6 @@ pub enum AttrInput {
13841394 TokenTree ( TokenTree ) ,
13851395}
13861396#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
1387- pub enum ExternItem {
1388- Fn ( Fn ) ,
1389- Static ( Static ) ,
1390- }
1391- impl ast:: AttrsOwner for ExternItem { }
1392- impl ast:: NameOwner for ExternItem { }
1393- impl ast:: VisibilityOwner for ExternItem { }
1394- #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
13951397pub enum AdtDef {
13961398 Struct ( Struct ) ,
13971399 Enum ( Enum ) ,
@@ -1841,6 +1843,17 @@ impl AstNode for AssocItemList {
18411843 }
18421844 fn syntax ( & self ) -> & SyntaxNode { & self . syntax }
18431845}
1846+ impl AstNode for ExternItemList {
1847+ fn can_cast ( kind : SyntaxKind ) -> bool { kind == EXTERN_ITEM_LIST }
1848+ fn cast ( syntax : SyntaxNode ) -> Option < Self > {
1849+ if Self :: can_cast ( syntax. kind ( ) ) {
1850+ Some ( Self { syntax } )
1851+ } else {
1852+ None
1853+ }
1854+ }
1855+ fn syntax ( & self ) -> & SyntaxNode { & self . syntax }
1856+ }
18441857impl AstNode for ParenType {
18451858 fn can_cast ( kind : SyntaxKind ) -> bool { kind == PAREN_TYPE }
18461859 fn cast ( syntax : SyntaxNode ) -> Option < Self > {
@@ -2754,17 +2767,6 @@ impl AstNode for ConstArg {
27542767 }
27552768 fn syntax ( & self ) -> & SyntaxNode { & self . syntax }
27562769}
2757- impl AstNode for ExternItemList {
2758- fn can_cast ( kind : SyntaxKind ) -> bool { kind == EXTERN_ITEM_LIST }
2759- fn cast ( syntax : SyntaxNode ) -> Option < Self > {
2760- if Self :: can_cast ( syntax. kind ( ) ) {
2761- Some ( Self { syntax } )
2762- } else {
2763- None
2764- }
2765- }
2766- fn syntax ( & self ) -> & SyntaxNode { & self . syntax }
2767- }
27682770impl AstNode for MetaItem {
27692771 fn can_cast ( kind : SyntaxKind ) -> bool { kind == META_ITEM }
27702772 fn cast ( syntax : SyntaxNode ) -> Option < Self > {
@@ -3290,6 +3292,39 @@ impl AstNode for AssocItem {
32903292 }
32913293 }
32923294}
3295+ impl From < Fn > for ExternItem {
3296+ fn from ( node : Fn ) -> ExternItem { ExternItem :: Fn ( node) }
3297+ }
3298+ impl From < Static > for ExternItem {
3299+ fn from ( node : Static ) -> ExternItem { ExternItem :: Static ( node) }
3300+ }
3301+ impl From < MacroCall > for ExternItem {
3302+ fn from ( node : MacroCall ) -> ExternItem { ExternItem :: MacroCall ( node) }
3303+ }
3304+ impl AstNode for ExternItem {
3305+ fn can_cast ( kind : SyntaxKind ) -> bool {
3306+ match kind {
3307+ FN | STATIC | MACRO_CALL => true ,
3308+ _ => false ,
3309+ }
3310+ }
3311+ fn cast ( syntax : SyntaxNode ) -> Option < Self > {
3312+ let res = match syntax. kind ( ) {
3313+ FN => ExternItem :: Fn ( Fn { syntax } ) ,
3314+ STATIC => ExternItem :: Static ( Static { syntax } ) ,
3315+ MACRO_CALL => ExternItem :: MacroCall ( MacroCall { syntax } ) ,
3316+ _ => return None ,
3317+ } ;
3318+ Some ( res)
3319+ }
3320+ fn syntax ( & self ) -> & SyntaxNode {
3321+ match self {
3322+ ExternItem :: Fn ( it) => & it. syntax ,
3323+ ExternItem :: Static ( it) => & it. syntax ,
3324+ ExternItem :: MacroCall ( it) => & it. syntax ,
3325+ }
3326+ }
3327+ }
32933328impl From < LetStmt > for Stmt {
32943329 fn from ( node : LetStmt ) -> Stmt { Stmt :: LetStmt ( node) }
32953330}
@@ -3346,34 +3381,6 @@ impl AstNode for AttrInput {
33463381 }
33473382 }
33483383}
3349- impl From < Fn > for ExternItem {
3350- fn from ( node : Fn ) -> ExternItem { ExternItem :: Fn ( node) }
3351- }
3352- impl From < Static > for ExternItem {
3353- fn from ( node : Static ) -> ExternItem { ExternItem :: Static ( node) }
3354- }
3355- impl AstNode for ExternItem {
3356- fn can_cast ( kind : SyntaxKind ) -> bool {
3357- match kind {
3358- FN | STATIC => true ,
3359- _ => false ,
3360- }
3361- }
3362- fn cast ( syntax : SyntaxNode ) -> Option < Self > {
3363- let res = match syntax. kind ( ) {
3364- FN => ExternItem :: Fn ( Fn { syntax } ) ,
3365- STATIC => ExternItem :: Static ( Static { syntax } ) ,
3366- _ => return None ,
3367- } ;
3368- Some ( res)
3369- }
3370- fn syntax ( & self ) -> & SyntaxNode {
3371- match self {
3372- ExternItem :: Fn ( it) => & it. syntax ,
3373- ExternItem :: Static ( it) => & it. syntax ,
3374- }
3375- }
3376- }
33773384impl From < Struct > for AdtDef {
33783385 fn from ( node : Struct ) -> AdtDef { AdtDef :: Struct ( node) }
33793386}
@@ -3437,17 +3444,17 @@ impl std::fmt::Display for AssocItem {
34373444 std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
34383445 }
34393446}
3440- impl std:: fmt:: Display for Stmt {
3447+ impl std:: fmt:: Display for ExternItem {
34413448 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
34423449 std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
34433450 }
34443451}
3445- impl std:: fmt:: Display for AttrInput {
3452+ impl std:: fmt:: Display for Stmt {
34463453 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
34473454 std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
34483455 }
34493456}
3450- impl std:: fmt:: Display for ExternItem {
3457+ impl std:: fmt:: Display for AttrInput {
34513458 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
34523459 std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
34533460 }
@@ -3657,6 +3664,11 @@ impl std::fmt::Display for AssocItemList {
36573664 std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
36583665 }
36593666}
3667+ impl std:: fmt:: Display for ExternItemList {
3668+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
3669+ std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
3670+ }
3671+ }
36603672impl std:: fmt:: Display for ParenType {
36613673 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
36623674 std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
@@ -4072,11 +4084,6 @@ impl std::fmt::Display for ConstArg {
40724084 std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
40734085 }
40744086}
4075- impl std:: fmt:: Display for ExternItemList {
4076- fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
4077- std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
4078- }
4079- }
40804087impl std:: fmt:: Display for MetaItem {
40814088 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
40824089 std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
0 commit comments