aboutsummaryrefslogtreecommitdiff
path: root/crates/libsyntax2/src/ast/generated.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/libsyntax2/src/ast/generated.rs')
-rw-r--r--crates/libsyntax2/src/ast/generated.rs78
1 files changed, 77 insertions, 1 deletions
diff --git a/crates/libsyntax2/src/ast/generated.rs b/crates/libsyntax2/src/ast/generated.rs
index f99d1274a..6181aada8 100644
--- a/crates/libsyntax2/src/ast/generated.rs
+++ b/crates/libsyntax2/src/ast/generated.rs
@@ -439,6 +439,24 @@ impl<'a> ExprStmt<'a> {
439 } 439 }
440} 440}
441 441
442// ExternCrateItem
443#[derive(Debug, Clone, Copy)]
444pub struct ExternCrateItem<'a> {
445 syntax: SyntaxNodeRef<'a>,
446}
447
448impl<'a> AstNode<'a> for ExternCrateItem<'a> {
449 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
450 match syntax.kind() {
451 EXTERN_CRATE_ITEM => Some(ExternCrateItem { syntax }),
452 _ => None,
453 }
454 }
455 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
456}
457
458impl<'a> ExternCrateItem<'a> {}
459
442// FieldExpr 460// FieldExpr
443#[derive(Debug, Clone, Copy)] 461#[derive(Debug, Clone, Copy)]
444pub struct FieldExpr<'a> { 462pub struct FieldExpr<'a> {
@@ -839,11 +857,51 @@ impl<'a> AstNode<'a> for Module<'a> {
839impl<'a> ast::NameOwner<'a> for Module<'a> {} 857impl<'a> ast::NameOwner<'a> for Module<'a> {}
840impl<'a> ast::AttrsOwner<'a> for Module<'a> {} 858impl<'a> ast::AttrsOwner<'a> for Module<'a> {}
841impl<'a> Module<'a> { 859impl<'a> Module<'a> {
842 pub fn modules(self) -> impl Iterator<Item = Module<'a>> + 'a { 860 pub fn items(self) -> impl Iterator<Item = ModuleItem<'a>> + 'a {
843 super::children(self) 861 super::children(self)
844 } 862 }
845} 863}
846 864
865// ModuleItem
866#[derive(Debug, Clone, Copy)]
867pub enum ModuleItem<'a> {
868 StructDef(StructDef<'a>),
869 EnumDef(EnumDef<'a>),
870 FnDef(FnDef<'a>),
871 TraitDef(TraitDef<'a>),
872 ImplItem(ImplItem<'a>),
873 UseItem(UseItem<'a>),
874 ExternCrateItem(ExternCrateItem<'a>),
875}
876
877impl<'a> AstNode<'a> for ModuleItem<'a> {
878 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
879 match syntax.kind() {
880 STRUCT_DEF => Some(ModuleItem::StructDef(StructDef { syntax })),
881 ENUM_DEF => Some(ModuleItem::EnumDef(EnumDef { syntax })),
882 FN_DEF => Some(ModuleItem::FnDef(FnDef { syntax })),
883 TRAIT_DEF => Some(ModuleItem::TraitDef(TraitDef { syntax })),
884 IMPL_ITEM => Some(ModuleItem::ImplItem(ImplItem { syntax })),
885 USE_ITEM => Some(ModuleItem::UseItem(UseItem { syntax })),
886 EXTERN_CRATE_ITEM => Some(ModuleItem::ExternCrateItem(ExternCrateItem { syntax })),
887 _ => None,
888 }
889 }
890 fn syntax(self) -> SyntaxNodeRef<'a> {
891 match self {
892 ModuleItem::StructDef(inner) => inner.syntax(),
893 ModuleItem::EnumDef(inner) => inner.syntax(),
894 ModuleItem::FnDef(inner) => inner.syntax(),
895 ModuleItem::TraitDef(inner) => inner.syntax(),
896 ModuleItem::ImplItem(inner) => inner.syntax(),
897 ModuleItem::UseItem(inner) => inner.syntax(),
898 ModuleItem::ExternCrateItem(inner) => inner.syntax(),
899 }
900 }
901}
902
903impl<'a> ModuleItem<'a> {}
904
847// Name 905// Name
848#[derive(Debug, Clone, Copy)] 906#[derive(Debug, Clone, Copy)]
849pub struct Name<'a> { 907pub struct Name<'a> {
@@ -1762,6 +1820,24 @@ impl<'a> AstNode<'a> for TypeRef<'a> {
1762 1820
1763impl<'a> TypeRef<'a> {} 1821impl<'a> TypeRef<'a> {}
1764 1822
1823// UseItem
1824#[derive(Debug, Clone, Copy)]
1825pub struct UseItem<'a> {
1826 syntax: SyntaxNodeRef<'a>,
1827}
1828
1829impl<'a> AstNode<'a> for UseItem<'a> {
1830 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
1831 match syntax.kind() {
1832 USE_ITEM => Some(UseItem { syntax }),
1833 _ => None,
1834 }
1835 }
1836 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1837}
1838
1839impl<'a> UseItem<'a> {}
1840
1765// WhereClause 1841// WhereClause
1766#[derive(Debug, Clone, Copy)] 1842#[derive(Debug, Clone, Copy)]
1767pub struct WhereClause<'a> { 1843pub struct WhereClause<'a> {