Repository: rust-analyzer/rust-analyzer
Pull request #5578 (2020-07-29 22:24:26)

Rename ModuleItem -> Item


bors r+
🤖


Patch:
diff --git a/crates/ra_assists/src/handlers/remove_dbg.rs b/crates/ra_assists/src/handlers/remove_dbg.rs
index 9430ce1b5b..a616cca579 100644
--- a/crates/ra_assists/src/handlers/remove_dbg.rs
+++ b/crates/ra_assists/src/handlers/remove_dbg.rs
@@ -1,6 +1,6 @@
 use ra_syntax::{
     ast::{self, AstNode},
-    TextRange, TextSize, T,
+    TextSize, T,
 };
 
 use crate::{AssistContext, AssistId, AssistKind, Assists};
@@ -27,33 +27,19 @@ pub(crate) fn remove_dbg(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
         return None;
     }
 
-    let is_leaf = macro_call.syntax().next_sibling().is_none();
+    let macro_range = macro_call.syntax().text_range();
 
-    let macro_end = if macro_call.semicolon_token().is_some() {
-        macro_call.syntax().text_range().end() - TextSize::of(';')
-    } else {
-        macro_call.syntax().text_range().end()
-    };
+    let macro_content = {
+        let macro_args = macro_call.token_tree()?.syntax().clone();
 
-    // macro_range determines what will be deleted and replaced with macro_content
-    let macro_range = TextRange::new(macro_call.syntax().text_range().start(), macro_end);
-    let paste_instead_of_dbg = {
-        let text = macro_call.token_tree()?.syntax().text();
-
-        // leafiness determines if we should include the parenthesis or not
-        let slice_index: TextRange = if is_leaf {
-            // leaf means - we can extract the contents of the dbg! in text
-            TextRange::new(TextSize::of('('), text.len() - TextSize::of(')'))
-        } else {
-            // not leaf - means we should keep the parens
-            TextRange::up_to(text.len())
-        };
-        text.slice(slice_index).to_string()
+        let text = macro_args.text();
+        let without_parens = TextSize::of('(')..text.len() - TextSize::of(')');
+        text.slice(without_parens).to_string()
     };
 
     let target = macro_call.syntax().text_range();
     acc.add(AssistId("remove_dbg", AssistKind::Refactor), "Remove dbg!()", target, |builder| {
-        builder.replace(macro_range, paste_instead_of_dbg);
+        builder.replace(macro_range, macro_content);
     })
 }
 
@@ -113,7 +99,6 @@ fn foo(n: usize) {
 ",
         );
     }
-
     #[test]
     fn test_remove_dbg_with_brackets_and_braces() {
         check_assist(remove_dbg, "dbg![<|>1 + 1]", "1 + 1");
@@ -128,7 +113,7 @@ fn foo(n: usize) {
     }
 
     #[test]
-    fn test_remove_dbg_target() {
+    fn remove_dbg_target() {
         check_assist_target(
             remove_dbg,
             "
@@ -141,65 +126,4 @@ fn foo(n: usize) {
             "dbg!(n.checked_sub(4))",
         );
     }
-
-    #[test]
-    fn test_remove_dbg_keep_semicolon() {
-        // https://github.com/rust-analyzer/rust-analyzer/issues/5129#issuecomment-651399779
-        // not quite though
-        // adding a comment at the end of the line makes
-        // the ast::MacroCall to include the semicolon at the end
-        check_assist(
-            remove_dbg,
-            r#"let res = <|>dbg!(1 * 20); // needless comment"#,
-            r#"let res = 1 * 20; // needless comment"#,
-        );
-    }
-
-    #[test]
-    fn test_remove_dbg_keep_expression() {
-        check_assist(
-            remove_dbg,
-            r#"let res = <|>dbg!(a + b).foo();"#,
-            r#"let res = (a + b).foo();"#,
-        );
-    }
-
-    #[test]
-    fn test_remove_dbg_from_inside_fn() {
-        check_assist_target(
-            remove_dbg,
-            r#"
-fn square(x: u32) -> u32 {
-    x * x
-}
-
-fn main() {
-    let x = square(dbg<|>!(5 + 10));
-    println!("{}", x);
-}"#,
-            "dbg!(5 + 10)",
-        );
-
-        check_assist(
-            remove_dbg,
-            r#"
-fn square(x: u32) -> u32 {
-    x * x
-}
-
-fn main() {
-    let x = square(dbg<|>!(5 + 10));
-    println!("{}", x);
-}"#,
-            r#"
-fn square(x: u32) -> u32 {
-    x * x
-}
-
-fn main() {
-    let x = square(5 + 10);
-    println!("{}", x);
-}"#,
-        );
-    }
 }
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs
index c6bc85e2f1..c33b645f31 100644
--- a/crates/ra_hir_def/src/body/lower.rs
+++ b/crates/ra_hir_def/src/body/lower.rs
@@ -627,53 +627,53 @@ impl ExprCollector<'_> {
             .items()
             .filter_map(|item| {
                 let (def, name): (ModuleDefId, Option<ast::Name>) = match item {
-                    ast::ModuleItem::FnDef(def) => {
+                    ast::Item::FnDef(def) => {
                         let id = self.find_inner_item(&def)?;
                         (
                             FunctionLoc { container: container.into(), id }.intern(self.db).into(),
                             def.name(),
                         )
                     }
-                    ast::ModuleItem::TypeAliasDef(def) => {
+                    ast::Item::TypeAliasDef(def) => {
                         let id = self.find_inner_item(&def)?;
                         (
                             TypeAliasLoc { container: container.into(), id }.intern(self.db).into(),
                             def.name(),
                         )
                     }
-                    ast::ModuleItem::ConstDef(def) => {
+                    ast::Item::ConstDef(def) => {
                         let id = self.find_inner_item(&def)?;
                         (
                             ConstLoc { container: container.into(), id }.intern(self.db).into(),
                             def.name(),
                         )
                     }
-                    ast::ModuleItem::StaticDef(def) => {
+                    ast::Item::StaticDef(def) => {
                         let id = self.find_inner_item(&def)?;
                         (StaticLoc { container, id }.intern(self.db).into(), def.name())
                     }
-                    ast::ModuleItem::StructDef(def) => {
+                    ast::Item::StructDef(def) => {
                         let id = self.find_inner_item(&def)?;
                         (StructLoc { container, id }.intern(self.db).into(), def.name())
                     }
-                    ast::ModuleItem::EnumDef(def) => {
+                    ast::Item::EnumDef(def) => {
                         let id = self.find_inner_item(&def)?;
                         (EnumLoc { container, id }.intern(self.db).into(), def.name())
                     }
-                    ast::ModuleItem::UnionDef(def) => {
+                    ast::Item::UnionDef(def) => {
                         let id = self.find_inner_item(&def)?;
                         (UnionLoc { container, id }.intern(self.db).into(), def.name())
                     }
-                    ast::ModuleItem::TraitDef(def) => {
+                    ast::Item::TraitDef(def) => {
                         let id = self.find_inner_item(&def)?;
                         (TraitLoc { container, id }.intern(self.db).into(), def.name())
                     }
-                    ast::ModuleItem::ExternBlock(_) => return None, // FIXME: collect from extern blocks
-                    ast::ModuleItem::ImplDef(_)
-                    | ast::ModuleItem::UseItem(_)
-                    | ast::ModuleItem::ExternCrateItem(_)
-                    | ast::ModuleItem::Module(_)
-                    | ast::ModuleItem::MacroCall(_) => return None,
+                    ast::Item::ExternBlock(_) => return None, // FIXME: collect from extern blocks
+                    ast::Item::ImplDef(_)
+                    | ast::Item::UseItem(_)
+                    | ast::Item::ExternCrateItem(_)
+                    | ast::Item::Module(_)
+                    | ast::Item::MacroCall(_) => return None,
                 };
 
                 Some((def, name))
diff --git a/crates/ra_hir_def/src/item_tree.rs b/crates/ra_hir_def/src/item_tree.rs
index da79d8ffd8..615c1e14ca 100644
--- a/crates/ra_hir_def/src/item_tree.rs
+++ b/crates/ra_hir_def/src/item_tree.rs
@@ -70,7 +70,7 @@ impl GenericParamsId {
 pub struct ItemTree {
     top_level: SmallVec<[ModItem; 1]>,
     attrs: FxHashMap<AttrOwner, Attrs>,
-    inner_items: FxHashMap<FileAstId<ast::ModuleItem>, SmallVec<[ModItem; 1]>>,
+    inner_items: FxHashMap<FileAstId<ast::Item>, SmallVec<[ModItem; 1]>>,
 
     data: Option<Box<ItemTreeData>>,
 }
@@ -187,7 +187,7 @@ impl ItemTree {
     ///
     /// Most AST items are lowered to a single `ModItem`, but some (eg. `use` items) may be lowered
     /// to multiple items in the `ItemTree`.
-    pub fn inner_items(&self, ast: FileAstId<ast::ModuleItem>) -> &[ModItem] {
+    pub fn inner_items(&self, ast: FileAstId<ast::Item>) -> &[ModItem] {
         &self.inner_items[&ast]
     }
 
@@ -310,7 +310,7 @@ from_attrs!(ModItem(ModItem), Variant(Idx<Variant>), Field(Idx<Field>));
 
 /// Trait implemented by all item nodes in the item tree.
 pub trait ItemTreeNode: Clone {
-    type Source: AstNode + Into<ast::ModuleItem>;
+    type Source: AstNode + Into<ast::Item>;
 
     fn ast_id(&self) -> FileAstId<Self::Source>;
 
diff --git a/crates/ra_hir_def/src/item_tree/lower.rs b/crates/ra_hir_def/src/item_tree/lower.rs
index f79b8fca3d..eb1da46320 100644
--- a/crates/ra_hir_def/src/item_tree/lower.rs
+++ b/crates/ra_hir_def/src/item_tree/lower.rs
@@ -70,19 +70,19 @@ impl Ctx {
         self.tree.data_mut()
     }
 
-    fn lower_mod_item(&mut self, item: &ast::ModuleItem, inner: bool) -> Option<ModItems> {
+    fn lower_mod_item(&mut self, item: &ast::Item, inner: bool) -> Option<ModItems> {
         assert!(inner || self.inner_items.is_empty());
 
         // Collect inner items for 1-to-1-lowered items.
         match item {
-            ast::ModuleItem::StructDef(_)
-            | ast::ModuleItem::UnionDef(_)
-            | ast::ModuleItem::EnumDef(_)
-            | ast::ModuleItem::FnDef(_)
-            | ast::ModuleItem::TypeAliasDef(_)
-            | ast::ModuleItem::ConstDef(_)
-            | ast::ModuleItem::StaticDef(_)
-            | ast::ModuleItem::MacroCall(_) => {
+            ast::Item::StructDef(_)
+            | ast::Item::UnionDef(_)
+            | ast::Item::EnumDef(_)
+            | ast::Item::FnDef(_)
+            | ast::Item::TypeAliasDef(_)
+            | ast::Item::ConstDef(_)
+            | ast::Item::StaticDef(_)
+            | ast::Item::MacroCall(_) => {
                 // Skip this if we're already collecting inner items. We'll descend into all nodes
                 // already.
                 if !inner {
@@ -92,34 +92,30 @@ impl Ctx {
 
             // These are handled in their respective `lower_X` method (since we can't just blindly
             // walk them).
-            ast::ModuleItem::TraitDef(_)
-            | ast::ModuleItem::ImplDef(_)
-            | ast::ModuleItem::ExternBlock(_) => {}
+            ast::Item::TraitDef(_) | ast::Item::ImplDef(_) | ast::Item::ExternBlock(_) => {}
 
             // These don't have inner items.
-            ast::ModuleItem::Module(_)
-            | ast::ModuleItem::ExternCrateItem(_)
-            | ast::ModuleItem::UseItem(_) => {}
+            ast::Item::Module(_) | ast::Item::ExternCrateItem(_) | ast::Item::UseItem(_) => {}
         };
 
         let attrs = Attrs::new(item, &self.hygiene);
         let items = match item {
-            ast::ModuleItem::StructDef(ast) => self.lower_struct(ast).map(Into::into),
-            ast::ModuleItem::UnionDef(ast) => self.lower_union(ast).map(Into::into),
-            ast::ModuleItem::EnumDef(ast) => self.lower_enum(ast).map(Into::into),
-            ast::ModuleItem::FnDef(ast) => self.lower_function(ast).map(Into::into),
-            ast::ModuleItem::TypeAliasDef(ast) => self.lower_type_alias(ast).map(Into::into),
-            ast::ModuleItem::StaticDef(ast) => self.lower_static(ast).map(Into::into),
-            ast::ModuleItem::ConstDef(ast) => Some(self.lower_const(ast).into()),
-            ast::ModuleItem::Module(ast) => self.lower_module(ast).map(Into::into),
-            ast::ModuleItem::TraitDef(ast) => self.lower_trait(ast).map(Into::into),
-            ast::ModuleItem::ImplDef(ast) => self.lower_impl(ast).map(Into::into),
-            ast::ModuleItem::UseItem(ast) => Some(ModItems(
+            ast::Item::StructDef(ast) => self.lower_struct(ast).map(Into::into),
+            ast::Item::UnionDef(ast) => self.lower_union(ast).map(Into::into),
+            ast::Item::EnumDef(ast) => self.lower_enum(ast).map(Into::into),
+            ast::Item::FnDef(ast) => self.lower_function(ast).map(Into::into),
+            ast::Item::TypeAliasDef(ast) => self.lower_type_alias(ast).map(Into::into),
+            ast::Item::StaticDef(ast) => self.lower_static(ast).map(Into::into),
+            ast::Item::ConstDef(ast) => Some(self.lower_const(ast).into()),
+            ast::Item::Module(ast) => self.lower_module(ast).map(Into::into),
+            ast::Item::TraitDef(ast) => self.lower_trait(ast).map(Into::into),
+            ast::Item::ImplDef(ast) => self.lower_impl(ast).map(Into::into),
+            ast::Item::UseItem(ast) => Some(ModItems(
                 self.lower_use(ast).into_iter().map(Into::into).collect::<SmallVec<_>>(),
             )),
-            ast::ModuleItem::ExternCrateItem(ast) => self.lower_extern_crate(ast).map(Into::into),
-            ast::ModuleItem::MacroCall(ast) => self.lower_macro_call(ast).map(Into::into),
-            ast::ModuleItem::ExternBlock(ast) => {
+            ast::Item::ExternCrateItem(ast) => self.lower_extern_crate(ast).map(Into::into),
+            ast::Item::MacroCall(ast) => self.lower_macro_call(ast).map(Into::into),
+            ast::Item::ExternBlock(ast) => {
                 Some(ModItems(self.lower_extern_block(ast).into_iter().collect::<SmallVec<_>>()))
             }
         };
@@ -147,22 +143,22 @@ impl Ctx {
     fn collect_inner_items(&mut self, container: &SyntaxNode) {
         let forced_vis = self.forced_visibility.take();
         let mut inner_items = mem::take(&mut self.tree.inner_items);
-        inner_items.extend(
-            container.descendants().skip(1).filter_map(ast::ModuleItem::cast).filter_map(|item| {
+        inner_items.extend(container.descendants().skip(1).filter_map(ast::Item::cast).filter_map(
+            |item| {
                 let ast_id = self.source_ast_id_map.ast_id(&item);
                 Some((ast_id, self.lower_mod_item(&item, true)?.0))
-            }),
-        );
+            },
+        ));
         self.tree.inner_items = inner_items;
         self.forced_visibility = forced_vis;
     }
 
-    fn lower_assoc_item(&mut self, item: &ast::ModuleItem) -> Option<AssocItem> {
+    fn lower_assoc_item(&mut self, item: &ast::Item) -> Option<AssocItem> {
         match item {
-            ast::ModuleItem::FnDef(ast) => self.lower_function(ast).map(Into::into),
-            ast::ModuleItem::TypeAliasDef(ast) => self.lower_type_alias(ast).map(Into::into),
-            ast::ModuleItem::ConstDef(ast) => Some(self.lower_const(ast).into()),
-            ast::ModuleItem::MacroCall(ast) => self.lower_macro_call(ast).map(Into::into),
+            ast::Item::FnDef(ast) => self.lower_function(ast).map(Into::into),
+            ast::Item::TypeAliasDef(ast) => self.lower_type_alias(ast).map(Into::into),
+            ast::Item::ConstDef(ast) => Some(self.lower_const(ast).into()),
+            ast::Item::MacroCall(ast) => self.lower_macro_call(ast).map(Into::into),
             _ => None,
         }
     }
diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs
index 87000fe987..237b1038af 100644
--- a/crates/ra_hir_def/src/lib.rs
+++ b/crates/ra_hir_def/src/lib.rs
@@ -521,7 +521,7 @@ impl AsMacroCall for AstIdWithPath<ast::MacroCall> {
     }
 }
 
-impl AsMacroCall for AstIdWithPath<ast::ModuleItem> {
+impl AsMacroCall for AstIdWithPath<ast::Item> {
     fn as_call_id(
         &self,
         db: &dyn db::DefDatabase,
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs
index a030cab471..28b7a20c55 100644
--- a/crates/ra_hir_def/src/nameres/collector.rs
+++ b/crates/ra_hir_def/src/nameres/collector.rs
@@ -170,7 +170,7 @@ struct MacroDirective {
 #[derive(Clone, Debug, Eq, PartialEq)]
 struct DeriveDirective {
     module_id: LocalModuleId,
-    ast_id: AstIdWithPath<ast::ModuleItem>,
+    ast_id: AstIdWithPath<ast::Item>,
 }
 
 struct DefData<'a> {
@@ -1100,7 +1100,7 @@ impl ModCollector<'_, '_> {
         res
     }
 
-    fn collect_derives(&mut self, attrs: &Attrs, ast_id: FileAstId<ast::ModuleItem>) {
+    fn collect_derives(&mut self, attrs: &Attrs, ast_id: FileAstId<ast::Item>) {
         for derive_subtree in attrs.by_key("derive").tt_values() {
             // for #[derive(Copy, Clone)], `derive_subtree` is the `(Copy, Clone)` subtree
             for tt in &derive_subtree.token_trees {
diff --git a/crates/ra_hir_expand/src/ast_id_map.rs b/crates/ra_hir_expand/src/ast_id_map.rs
index f4d31526a6..8bfe1b4ba7 100644
--- a/crates/ra_hir_expand/src/ast_id_map.rs
+++ b/crates/ra_hir_expand/src/ast_id_map.rs
@@ -73,7 +73,7 @@ impl AstIdMap {
         // change parent's id. This means that, say, adding a new function to a
         // trait does not change ids of top-level items, which helps caching.
         bfs(node, |it| {
-            if let Some(module_item) = ast::ModuleItem::cast(it) {
+            if let Some(module_item) = ast::Item::cast(it) {
                 res.alloc(module_item.syntax());
             }
         });
diff --git a/crates/ra_hir_expand/src/builtin_derive.rs b/crates/ra_hir_expand/src/builtin_derive.rs
index f2d6648638..8f70a35670 100644
--- a/crates/ra_hir_expand/src/builtin_derive.rs
+++ b/crates/ra_hir_expand/src/builtin_derive.rs
@@ -276,7 +276,7 @@ mod tests {
         let file_id = file_pos.file_id;
         let parsed = db.parse(file_id);
         let items: Vec<_> =
-            parsed.syntax_node().descendants().filter_map(ast::ModuleItem::cast).collect();
+            parsed.syntax_node().descendants().filter_map(ast::Item::cast).collect();
 
         let ast_id_map = db.ast_id_map(file_id.into());
 
diff --git a/crates/ra_hir_expand/src/lib.rs b/crates/ra_hir_expand/src/lib.rs
index d9e31ac20b..2e8d636917 100644
--- a/crates/ra_hir_expand/src/lib.rs
+++ b/crates/ra_hir_expand/src/lib.rs
@@ -159,7 +159,7 @@ impl HirFileId {
     }
 
     /// Indicate it is macro file generated for builtin derive
-    pub fn is_builtin_derive(&self, db: &dyn db::AstDatabase) -> Option<InFile<ast::ModuleItem>> {
+    pub fn is_builtin_derive(&self, db: &dyn db::AstDatabase) -> Option<InFile<ast::Item>> {
         match self.0 {
             HirFileIdRepr::FileId(_) => None,
             HirFileIdRepr::MacroFile(macro_file) => {
@@ -174,7 +174,7 @@ impl HirFileId {
                     MacroDefKind::BuiltInDerive(_) => loc.kind.node(db),
                     _ => return None,
                 };
-                Some(item.with_value(ast::ModuleItem::cast(item.value.clone())?))
+                Some(item.with_value(ast::Item::cast(item.value.clone())?))
             }
         }
     }
@@ -258,7 +258,7 @@ pub struct MacroCallLoc {
 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
 pub enum MacroCallKind {
     FnLike(AstId<ast::MacroCall>),
-    Attr(AstId<ast::ModuleItem>, String),
+    Attr(AstId<ast::Item>, String),
 }
 
 impl MacroCallKind {
diff --git a/crates/ra_ide/src/completion/complete_fn_param.rs b/crates/ra_ide/src/completion/complete_fn_param.rs
index db2abb4f13..7a53083f54 100644
--- a/crates/ra_ide/src/completion/complete_fn_param.rs
+++ b/crates/ra_ide/src/completion/complete_fn_param.rs
@@ -28,7 +28,7 @@ pub(super) fn complete_fn_param(acc: &mut Completions, ctx: &CompletionContext)
             }
         };
         for item in items {
-            if let ast::ModuleItem::FnDef(func) = item {
+            if let ast::Item::FnDef(func) = item {
                 if Some(&func) == me.as_ref() {
                     continue;
                 }
diff --git a/crates/ra_ide/src/runnables.rs b/crates/ra_ide/src/runnables.rs
index 45e0a7d853..f612835c2a 100644
--- a/crates/ra_ide/src/runnables.rs
+++ b/crates/ra_ide/src/runnables.rs
@@ -246,12 +246,12 @@ fn has_test_function_or_multiple_test_submodules(module: &ast::Module) -> bool {
 
         for item in item_list.items() {
             match item {
-                ast::ModuleItem::FnDef(f) => {
+                ast::Item::FnDef(f) => {
                     if has_test_related_attribute(&f) {
                         return true;
                     }
                 }
-                ast::ModuleItem::Module(submodule) => {
+                ast::Item::Module(submodule) => {
                     if has_test_function_or_multiple_test_submodules(&submodule) {
                         number_of_test_submodules += 1;
                     }
diff --git a/crates/ra_parser/src/syntax_kind/generated.rs b/crates/ra_parser/src/syntax_kind/generated.rs
index e7404492a8..625f0c8229 100644
--- a/crates/ra_parser/src/syntax_kind/generated.rs
+++ b/crates/ra_parser/src/syntax_kind/generated.rs
@@ -362,4 +362,4 @@ impl SyntaxKind {
     }
 }
 #[macro_export]
-macro_rules ! T { [ ; ] => { $ crate :: SyntaxKind :: SEMICOLON } ; [ , ] => { $ crate :: SyntaxKind :: COMMA } ; [ '(' ] => { $ crate :: SyntaxKind :: L_PAREN } ; [ ')' ] => { $ crate :: SyntaxKind :: R_PAREN } ; [ '{' ] => { $ crate :: SyntaxKind :: L_CURLY } ; [ '}' ] => { $ crate :: SyntaxKind :: R_CURLY } ; [ '[' ] => { $ crate :: SyntaxKind :: L_BRACK } ; [ ']' ] => { $ crate :: SyntaxKind :: R_BRACK } ; [ < ] => { $ crate :: SyntaxKind :: L_ANGLE } ; [ > ] => { $ crate :: SyntaxKind :: R_ANGLE } ; [ @ ] => { $ crate :: SyntaxKind :: AT } ; [ # ] => { $ crate :: SyntaxKind :: POUND } ; [ ~ ] => { $ crate :: SyntaxKind :: TILDE } ; [ ? ] => { $ crate :: SyntaxKind :: QUESTION } ; [ $ ] => { $ crate :: SyntaxKind :: DOLLAR } ; [ & ] => { $ crate :: SyntaxKind :: AMP } ; [ | ] => { $ crate :: SyntaxKind :: PIPE } ; [ + ] => { $ crate :: SyntaxKind :: PLUS } ; [ * ] => { $ crate :: SyntaxKind :: STAR } ; [ / ] => { $ crate :: SyntaxKind :: SLASH } ; [ ^ ] => { $ crate :: SyntaxKind :: CARET } ; [ % ] => { $ crate :: SyntaxKind :: PERCENT } ; [ _ ] => { $ crate :: SyntaxKind :: UNDERSCORE } ; [ . ] => { $ crate :: SyntaxKind :: DOT } ; [ .. ] => { $ crate :: SyntaxKind :: DOT2 } ; [ ... ] => { $ crate :: SyntaxKind :: DOT3 } ; [ ..= ] => { $ crate :: SyntaxKind :: DOT2EQ } ; [ : ] => { $ crate :: SyntaxKind :: COLON } ; [ :: ] => { $ crate :: SyntaxKind :: COLON2 } ; [ = ] => { $ crate :: SyntaxKind :: EQ } ; [ == ] => { $ crate :: SyntaxKind :: EQ2 } ; [ => ] => { $ crate :: SyntaxKind :: FAT_ARROW } ; [ ! ] => { $ crate :: SyntaxKind :: BANG } ; [ != ] => { $ crate :: SyntaxKind :: NEQ } ; [ - ] => { $ crate :: SyntaxKind :: MINUS } ; [ -> ] => { $ crate :: SyntaxKind :: THIN_ARROW } ; [ <= ] => { $ crate :: SyntaxKind :: LTEQ } ; [ >= ] => { $ crate :: SyntaxKind :: GTEQ } ; [ += ] => { $ crate :: SyntaxKind :: PLUSEQ } ; [ -= ] => { $ crate :: SyntaxKind :: MINUSEQ } ; [ |= ] => { $ crate :: SyntaxKind :: PIPEEQ } ; [ &= ] => { $ crate :: SyntaxKind :: AMPEQ } ; [ ^= ] => { $ crate :: SyntaxKind :: CARETEQ } ; [ /= ] => { $ crate :: SyntaxKind :: SLASHEQ } ; [ *= ] => { $ crate :: SyntaxKind :: STAREQ } ; [ %= ] => { $ crate :: SyntaxKind :: PERCENTEQ } ; [ && ] => { $ crate :: SyntaxKind :: AMP2 } ; [ || ] => { $ crate :: SyntaxKind :: PIPE2 } ; [ << ] => { $ crate :: SyntaxKind :: SHL } ; [ >> ] => { $ crate :: SyntaxKind :: SHR } ; [ <<= ] => { $ crate :: SyntaxKind :: SHLEQ } ; [ >>= ] => { $ crate :: SyntaxKind :: SHREQ } ; [ as ] => { $ crate :: SyntaxKind :: AS_KW } ; [ async ] => { $ crate :: SyntaxKind :: ASYNC_KW } ; [ await ] => { $ crate :: SyntaxKind :: AWAIT_KW } ; [ box ] => { $ crate :: SyntaxKind :: BOX_KW } ; [ break ] => { $ crate :: SyntaxKind :: BREAK_KW } ; [ const ] => { $ crate :: SyntaxKind :: CONST_KW } ; [ continue ] => { $ crate :: SyntaxKind :: CONTINUE_KW } ; [ crate ] => { $ crate :: SyntaxKind :: CRATE_KW } ; [ dyn ] => { $ crate :: SyntaxKind :: DYN_KW } ; [ else ] => { $ crate :: SyntaxKind :: ELSE_KW } ; [ enum ] => { $ crate :: SyntaxKind :: ENUM_KW } ; [ extern ] => { $ crate :: SyntaxKind :: EXTERN_KW } ; [ false ] => { $ crate :: SyntaxKind :: FALSE_KW } ; [ fn ] => { $ crate :: SyntaxKind :: FN_KW } ; [ for ] => { $ crate :: SyntaxKind :: FOR_KW } ; [ if ] => { $ crate :: SyntaxKind :: IF_KW } ; [ impl ] => { $ crate :: SyntaxKind :: IMPL_KW } ; [ in ] => { $ crate :: SyntaxKind :: IN_KW } ; [ let ] => { $ crate :: SyntaxKind :: LET_KW } ; [ loop ] => { $ crate :: SyntaxKind :: LOOP_KW } ; [ macro ] => { $ crate :: SyntaxKind :: MACRO_KW } ; [ match ] => { $ crate :: SyntaxKind :: MATCH_KW } ; [ mod ] => { $ crate :: SyntaxKind :: MOD_KW } ; [ move ] => { $ crate :: SyntaxKind :: MOVE_KW } ; [ mut ] => { $ crate :: SyntaxKind :: MUT_KW } ; [ pub ] => { $ crate :: SyntaxKind :: PUB_KW } ; [ ref ] => { $ crate :: SyntaxKind :: REF_KW } ; [ return ] => { $ crate :: SyntaxKind :: RETURN_KW } ; [ self ] => { $ crate :: SyntaxKind :: SELF_KW } ; [ static ] => { $ crate :: SyntaxKind :: STATIC_KW } ; [ struct ] => { $ crate :: SyntaxKind :: STRUCT_KW } ; [ super ] => { $ crate :: SyntaxKind :: SUPER_KW } ; [ trait ] => { $ crate :: SyntaxKind :: TRAIT_KW } ; [ true ] => { $ crate :: SyntaxKind :: TRUE_KW } ; [ try ] => { $ crate :: SyntaxKind :: TRY_KW } ; [ type ] => { $ crate :: SyntaxKind :: TYPE_KW } ; [ unsafe ] => { $ crate :: SyntaxKind :: UNSAFE_KW } ; [ use ] => { $ crate :: SyntaxKind :: USE_KW } ; [ where ] => { $ crate :: SyntaxKind :: WHERE_KW } ; [ while ] => { $ crate :: SyntaxKind :: WHILE_KW } ; [ auto ] => { $ crate :: SyntaxKind :: AUTO_KW } ; [ default ] => { $ crate :: SyntaxKind :: DEFAULT_KW } ; [ existential ] => { $ crate :: SyntaxKind :: EXISTENTIAL_KW } ; [ union ] => { $ crate :: SyntaxKind :: UNION_KW } ; [ raw ] => { $ crate :: SyntaxKind :: RAW_KW } ; [ lifetime ] => { $ crate :: SyntaxKind :: LIFETIME } ; [ ident ] => { $ crate :: SyntaxKind :: IDENT } ; }
+macro_rules ! T { [ ; ] => { $ crate :: SyntaxKind :: SEMICOLON } ; [ , ] => { $ crate :: SyntaxKind :: COMMA } ; [ '(' ] => { $ crate :: SyntaxKind :: L_PAREN } ; [ ')' ] => { $ crate :: SyntaxKind :: R_PAREN } ; [ '{' ] => { $ crate :: SyntaxKind :: L_CURLY } ; [ '}' ] => { $ crate :: SyntaxKind :: R_CURLY } ; [ '[' ] => { $ crate :: SyntaxKind :: L_BRACK } ; [ ']' ] => { $ crate :: SyntaxKind :: R_BRACK } ; [ < ] => { $ crate :: SyntaxKind :: L_ANGLE } ; [ > ] => { $ crate :: SyntaxKind :: R_ANGLE } ; [ @ ] => { $ crate :: SyntaxKind :: AT } ; [ # ] => { $ crate :: SyntaxKind :: POUND } ; [ ~ ] => { $ crate :: SyntaxKind :: TILDE } ; [ ? ] => { $ crate :: SyntaxKind :: QUESTION } ; [ $ ] => { $ crate :: SyntaxKind :: DOLLAR } ; [ & ] => { $ crate :: SyntaxKind :: AMP } ; [ | ] => { $ crate :: SyntaxKind :: PIPE } ; [ + ] => { $ crate :: SyntaxKind :: PLUS } ; [ * ] => { $ crate :: SyntaxKind :: STAR } ; [ / ] => { $ crate :: SyntaxKind :: SLASH } ; [ ^ ] => { $ crate :: SyntaxKind :: CARET } ; [ % ] => { $ crate :: SyntaxKind :: PERCENT } ; [ _ ] => { $ crate :: SyntaxKind :: UNDERSCORE } ; [ . ] => { $ crate :: SyntaxKind :: DOT } ; [ .. ] => { $ crate :: SyntaxKind :: DOT2 } ; [ ... ] => { $ crate :: SyntaxKind :: DOT3 } ; [ ..= ] => { $ crate :: SyntaxKind :: DOT2EQ } ; [ : ] => { $ crate :: SyntaxKind :: COLON } ; [ :: ] => { $ crate :: SyntaxKind :: COLON2 } ; [ = ] => { $ crate :: SyntaxKind :: EQ } ; [ == ] => { $ crate :: SyntaxKind :: EQ2 } ; [ => ] => { $ crate :: SyntaxKind :: FAT_ARROW } ; [ ! ] => { $ crate :: SyntaxKind :: BANG } ; [ != ] => { $ crate :: SyntaxKind :: NEQ } ; [ - ] => { $ crate :: SyntaxKind :: MINUS } ; [ -> ] => { $ crate :: SyntaxKind :: THIN_ARROW } ; [ <= ] => { $ crate :: SyntaxKind :: LTEQ } ; [ >= ] => { $ crate :: SyntaxKind :: GTEQ } ; [ += ] => { $ crate :: SyntaxKind :: PLUSEQ } ; [ -= ] => { $ crate :: SyntaxKind :: MINUSEQ } ; [ |= ] => { $ crate :: SyntaxKind :: PIPEEQ } ; [ &= ] => { $ crate :: SyntaxKind :: AMPEQ } ; [ ^= ] => { $ crate :: SyntaxKind :: CARETEQ } ; [ /= ] => { $ crate :: SyntaxKind :: SLASHEQ } ; [ *= ] => { $ crate :: SyntaxKind :: STAREQ } ; [ %= ] => { $ crate :: SyntaxKind :: PERCENTEQ } ; [ && ] => { $ crate :: SyntaxKind :: AMP2 } ; [ || ] => { $ crate :: SyntaxKind :: PIPE2 } ; [ << ] => { $ crate :: SyntaxKind :: SHL } ; [ >> ] => { $ crate :: SyntaxKind :: SHR } ; [ <<= ] => { $ crate :: SyntaxKind :: SHLEQ } ; [ >>= ] => { $ crate :: SyntaxKind :: SHREQ } ; [ as ] => { $ crate :: SyntaxKind :: AS_KW } ; [ async ] => { $ crate :: SyntaxKind :: ASYNC_KW } ; [ await ] => { $ crate :: SyntaxKind :: AWAIT_KW } ; [ box ] => { $ crate :: SyntaxKind :: BOX_KW } ; [ break ] => { $ crate :: SyntaxKind :: BREAK_KW } ; [ const ] => { $ crate :: SyntaxKind :: CONST_KW } ; [ continue ] => { $ crate :: SyntaxKind :: CONTINUE_KW } ; [ crate ] => { $ crate :: SyntaxKind :: CRATE_KW } ; [ dyn ] => { $ crate :: SyntaxKind :: DYN_KW } ; [ else ] => { $ crate :: SyntaxKind :: ELSE_KW } ; [ enum ] => { $ crate :: SyntaxKind :: ENUM_KW } ; [ extern ] => { $ crate :: SyntaxKind :: EXTERN_KW } ; [ false ] => { $ crate :: SyntaxKind :: FALSE_KW } ; [ fn ] => { $ crate :: SyntaxKind :: FN_KW } ; [ for ] => { $ crate :: SyntaxKind :: FOR_KW } ; [ if ] => { $ crate :: SyntaxKind :: IF_KW } ; [ impl ] => { $ crate :: SyntaxKind :: IMPL_KW } ; [ in ] => { $ crate :: SyntaxKind :: IN_KW } ; [ let ] => { $ crate :: SyntaxKind :: LET_KW } ; [ loop ] => { $ crate :: SyntaxKind :: LOOP_KW } ; [ macro ] => { $ crate :: SyntaxKind :: MACRO_KW } ; [ match ] => { $ crate :: SyntaxKind :: MATCH_KW } ; [ mod ] => { $ crate :: SyntaxKind :: MOD_KW } ; [ move ] => { $ crate :: SyntaxKind :: MOVE_KW } ; [ mut ] => { $ crate :: SyntaxKind :: MUT_KW } ; [ pub ] => { $ crate :: SyntaxKind :: PUB_KW } ; [ ref ] => { $ crate :: SyntaxKind :: REF_KW } ; [ return ] => { $ crate :: SyntaxKind :: RETURN_KW } ; [ self ] => { $ crate :: SyntaxKind :: SELF_KW } ; [ static ] => { $ crate :: SyntaxKind :: STATIC_KW } ; [ struct ] => { $ crate :: SyntaxKind :: STRUCT_KW } ; [ super ] => { $ crate :: SyntaxKind :: SUPER_KW } ; [ trait ] => { $ crate :: SyntaxKind :: TRAIT_KW } ; [ true ] => { $ crate :: SyntaxKind :: TRUE_KW } ; [ try ] => { $ crate :: SyntaxKind :: TRY_KW } ; [ type ] => { $ crate :: SyntaxKind :: TYPE_KW } ; [ unsafe ] => { $ crate :: SyntaxKind :: UNSAFE_KW } ; [ use ] => { $ crate :: SyntaxKind :: USE_KW } ; [ where ] => { $ crate :: SyntaxKind :: WHERE_KW } ; [ while ] => { $ crate :: SyntaxKind :: WHILE_KW } ; [ auto ] => { $ crate :: SyntaxKind :: AUTO_KW } ; [ default ] => { $ crate :: SyntaxKind :: DEFAULT_KW } ; [ existential ] => { $ crate :: SyntaxKind :: EXISTENTIAL_KW } ; [ union ] => { $ crate :: SyntaxKind :: UNION_KW } ; [ raw ] => { $ crate :: SyntaxKind :: RAW_KW } ; [ lifetime ] => { $ crate :: SyntaxKind :: LIFETIME } ; [ ident ] => { $ crate :: SyntaxKind :: IDENT } ; [ shebang ] => { $ crate :: SyntaxKind :: SHEBANG } ; }
diff --git a/crates/ra_ssr/src/parsing.rs b/crates/ra_ssr/src/parsing.rs
index 769720befe..78e03f394b 100644
--- a/crates/ra_ssr/src/parsing.rs
+++ b/crates/ra_ssr/src/parsing.rs
@@ -71,10 +71,7 @@ impl ParsedRule {
         };
         builder.try_add(ast::Expr::parse(&raw_pattern), raw_template.map(ast::Expr::parse));
         builder.try_add(ast::TypeRef::parse(&raw_pattern), raw_template.map(ast::TypeRef::parse));
-        builder.try_add(
-            ast::ModuleItem::parse(&raw_pattern),
-            raw_template.map(ast::ModuleItem::parse),
-        );
+        builder.try_add(ast::Item::parse(&raw_pattern), raw_template.map(ast::Item::parse));
         builder.try_add(ast::Path::parse(&raw_pattern), raw_template.map(ast::Path::parse));
         builder.try_add(ast::Pat::parse(&raw_pattern), raw_template.map(ast::Pat::parse));
         builder.build()
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs
index 04a4d354c2..dfda795502 100644
--- a/crates/ra_syntax/src/ast/generated/nodes.rs
+++ b/crates/ra_syntax/src/ast/generated/nodes.rs
@@ -11,7 +11,9 @@ pub struct SourceFile {
 }
 impl ast::AttrsOwner for SourceFile {}
 impl ast::ModuleItemOwner for SourceFile {}
-impl SourceFile {}
+impl SourceFile {
+    pub fn shebang_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![shebang]) }
+}
 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
 pub struct Attr {
     pub(crate) syntax: SyntaxNode,
@@ -26,6 +28,57 @@ impl Attr {
     pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
 }
 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
+pub struct ConstDef {
+    pub(crate) syntax: SyntaxNode,
+}
+impl ast::AttrsOwner for ConstDef {}
+impl ast::NameOwner for ConstDef {}
+impl ast::VisibilityOwner for ConstDef {}
+impl ast::TypeAscriptionOwner for ConstDef {}
+impl ConstDef {
+    pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
+    pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
+    pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
+    pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
+    pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
+    pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
+}
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+pub struct EnumDef {
+    pub(crate) syntax: SyntaxNode,
+}
+impl ast::AttrsOwner for EnumDef {}
+impl ast::NameOwner for EnumDef {}
+impl ast::VisibilityOwner for EnumDef {}
+impl ast::TypeParamsOwner for EnumDef {}
+impl EnumDef {
+    pub fn enum_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![enum]) }
+    pub fn variant_list(&self) -> Option<EnumVariantList> { support::child(&self.syntax) }
+}
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+pub struct ExternBlock {
+    pub(crate) syntax: SyntaxNode,
+}
+impl ast::AttrsOwner for ExternBlock {}
+impl ExternBlock {
+    pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) }
+    pub fn extern_item_list(&self) -> Option<ExternItemList> { support::child(&self.syntax) }
+}
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+pub struct ExternCrateItem {
+    pub(crate) syntax: SyntaxNode,
+}
+impl ast::AttrsOwner for ExternCrateItem {}
+impl ast::VisibilityOwner for ExternCrateItem {}
+impl ExternCrateItem {
+    pub fn extern_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![extern]) }
+    pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) }
+    pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
+    pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
+    pub fn alias(&self) -> Option<Alias> { support::child(&self.syntax) }
+    pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
+}
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
 pub struct FnDef {
     pub(crate) syntax: SyntaxNode,
 }
@@ -46,6 +99,131 @@ impl FnDef {
     pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
 }
 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
+pub struct ImplDef {
+    pub(crate) syntax: SyntaxNode,
+}
+impl ast::AttrsOwner for ImplDef {}
+impl ast::VisibilityOwner for ImplDef {}
+impl ast::TypeParamsOwner for ImplDef {}
+impl ImplDef {
+    pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
+    pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
+    pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
+    pub fn impl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![impl]) }
+    pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
+    pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) }
+    pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) }
+}
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+pub struct MacroCall {
+    pub(crate) syntax: SyntaxNode,
+}
+impl ast::AttrsOwner for MacroCall {}
+impl ast::NameOwner for MacroCall {}
+impl MacroCall {
+    pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
+    pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
+    pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) }
+    pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
+}
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+pub struct Module {
+    pub(crate) syntax: SyntaxNode,
+}
+impl ast::AttrsOwner for Module {}
+impl ast::NameOwner for Module {}
+impl ast::VisibilityOwner for Module {}
+impl Module {
+    pub fn mod_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mod]) }
+    pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) }
+    pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
+}
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+pub struct StaticDef {
+    pub(crate) syntax: SyntaxNode,
+}
+impl ast::AttrsOwner for StaticDef {}
+impl ast::NameOwner for StaticDef {}
+impl ast::VisibilityOwner for StaticDef {}
+impl ast::TypeAscriptionOwner for StaticDef {}
+impl StaticDef {
+    pub fn static_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![static]) }
+    pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
+    pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
+    pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
+    pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
+    pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
+}
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+pub struct StructDef {
+    pub(crate) syntax: SyntaxNode,
+}
+impl ast::AttrsOwner for StructDef {}
+impl ast::NameOwner for StructDef {}
+impl ast::VisibilityOwner for StructDef {}
+impl ast::TypeParamsOwner for StructDef {}
+impl StructDef {
+    pub fn struct_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![struct]) }
+    pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
+    pub fn field_def_list(&self) -> Option<FieldDefList> { support::child(&self.syntax) }
+}
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+pub struct TraitDef {
+    pub(crate) syntax: SyntaxNode,
+}
+impl ast::AttrsOwner for TraitDef {}
+impl ast::NameOwner for TraitDef {}
+impl ast::VisibilityOwner for TraitDef {}
+impl ast::TypeParamsOwner for TraitDef {}
+impl ast::TypeBoundsOwner for TraitDef {}
+impl TraitDef {
+    pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
+    pub fn auto_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![auto]) }
+    pub fn trait_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![trait]) }
+    pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) }
+}
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+pub struct TypeAliasDef {
+    pub(crate) syntax: SyntaxNode,
+}
+impl ast::AttrsOwner for TypeAliasDef {}
+impl ast::NameOwner for TypeAliasDef {}
+impl ast::VisibilityOwner for TypeAliasDef {}
+impl ast::TypeParamsOwner for TypeAliasDef {}
+impl ast::TypeBoundsOwner for TypeAliasDef {}
+impl TypeAliasDef {
+    pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
+    pub fn type_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![type]) }
+    pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
+    pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
+    pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
+}
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+pub struct UnionDef {
+    pub(crate) syntax: SyntaxNode,
+}
+impl ast::AttrsOwner for UnionDef {}
+impl ast::NameOwner for UnionDef {}
+impl ast::VisibilityOwner for UnionDef {}
+impl ast::TypeParamsOwner for UnionDef {}
+impl UnionDef {
+    pub fn union_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![union]) }
+    pub fn record_field_def_list(&self) -> Option<RecordFieldDefList> {
+        support::child(&self.syntax)
+    }
+}
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+pub struct UseItem {
+    pub(crate) syntax: SyntaxNode,
+}
+impl ast::AttrsOwner for UseItem {}
+impl ast::VisibilityOwner for UseItem {}
+impl UseItem {
+    pub fn use_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![use]) }
+    pub fn use_tree(&self) -> Option<UseTree> { support::child(&self.syntax) }
+    pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
+}
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
 pub struct Visibility {
     pub(crate) syntax: SyntaxNode,
 }
@@ -122,19 +300,6 @@ impl BlockExpr {
     pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
 }
 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub struct StructDef {
-    pub(crate) syntax: SyntaxNode,
-}
-impl ast::AttrsOwner for StructDef {}
-impl ast::NameOwner for StructDef {}
-impl ast::VisibilityOwner for StructDef {}
-impl ast::TypeParamsOwner for StructDef {}
-impl StructDef {
-    pub fn struct_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![struct]) }
-    pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
-    pub fn field_def_list(&self) -> Option<FieldDefList> { support::child(&self.syntax) }
-}
-#[derive(Debug, Clone, PartialEq, Eq, Hash)]
 pub struct RecordFieldDefList {
     pub(crate) syntax: SyntaxNode,
 }
@@ -153,20 +318,6 @@ impl TupleFieldDefList {
     pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
 }
 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub struct UnionDef {
-    pub(crate) syntax: SyntaxNode,
-}
-impl ast::AttrsOwner for UnionDef {}
-impl ast::NameOwner for UnionDef {}
-impl ast::VisibilityOwner for UnionDef {}
-impl ast::TypeParamsOwner for UnionDef {}
-impl UnionDef {
-    pub fn union_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![union]) }
-    pub fn record_field_def_list(&self) -> Option<RecordFieldDefList> {
-        support::child(&self.syntax)
-    }
-}
-#[derive(Debug, Clone, PartialEq, Eq, Hash)]
 pub struct RecordFieldDef {
     pub(crate) syntax: SyntaxNode,
 }
@@ -188,18 +339,6 @@ impl TupleFieldDef {
     pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
 }
 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub struct EnumDef {
-    pub(crate) syntax: SyntaxNode,
-}
-impl ast::AttrsOwner for EnumDef {}
-impl ast::NameOwner for EnumDef {}
-impl ast::VisibilityOwner for EnumDef {}
-impl ast::TypeParamsOwner for EnumDef {}
-impl EnumDef {
-    pub fn enum_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![enum]) }
-    pub fn variant_list(&self) -> Option<EnumVariantList> { support::child(&self.syntax) }
-}
-#[derive(Debug, Clone, PartialEq, Eq, Hash)]
 pub struct EnumVariantList {
     pub(crate) syntax: SyntaxNode,
 }
@@ -221,21 +360,6 @@ impl EnumVariant {
     pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
 }
 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub struct TraitDef {
-    pub(crate) syntax: SyntaxNode,
-}
-impl ast::AttrsOwner for TraitDef {}
-impl ast::NameOwner for TraitDef {}
-impl ast::VisibilityOwner for TraitDef {}
-impl ast::TypeParamsOwner for TraitDef {}
-impl ast::TypeBoundsOwner for TraitDef {}
-impl TraitDef {
-    pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
-    pub fn auto_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![auto]) }
-    pub fn trait_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![trait]) }
-    pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) }
-}
-#[derive(Debug, Clone, PartialEq, Eq, Hash)]
 pub struct TypeBoundList {
     pub(crate) syntax: SyntaxNode,
 }
@@ -253,82 +377,6 @@ impl ItemList {
     pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
 }
 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub struct Module {
-    pub(crate) syntax: SyntaxNode,
-}
-impl ast::AttrsOwner for Module {}
-impl ast::NameOwner for Module {}
-impl ast::VisibilityOwner for Module {}
-impl Module {
-    pub fn mod_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mod]) }
-    pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) }
-    pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
-}
-#[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub struct ConstDef {
-    pub(crate) syntax: SyntaxNode,
-}
-impl ast::AttrsOwner for ConstDef {}
-impl ast::NameOwner for ConstDef {}
-impl ast::VisibilityOwner for ConstDef {}
-impl ast::TypeAscriptionOwner for ConstDef {}
-impl ConstDef {
-    pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
-    pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
-    pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
-    pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
-    pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
-    pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
-}
-#[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub struct StaticDef {
-    pub(crate) syntax: SyntaxNode,
-}
-impl ast::AttrsOwner for StaticDef {}
-impl ast::NameOwner for StaticDef {}
-impl ast::VisibilityOwner for StaticDef {}
-impl ast::TypeAscriptionOwner for StaticDef {}
-impl StaticDef {
-    pub fn static_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![static]) }
-    pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
-    pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
-    pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
-    pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
-    pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
-}
-#[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub struct TypeAliasDef {
-    pub(crate) syntax: SyntaxNode,
-}
-impl ast::AttrsOwner for TypeAliasDef {}
-impl ast::NameOwner for TypeAliasDef {}
-impl ast::VisibilityOwner for TypeAliasDef {}
-impl ast::TypeParamsOwner for TypeAliasDef {}
-impl ast::TypeBoundsOwner for TypeAliasDef {}
-impl TypeAliasDef {
-    pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
-    pub fn type_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![type]) }
-    pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
-    pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
-    pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
-}
-#[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub struct ImplDef {
-    pub(crate) syntax: SyntaxNode,
-}
-impl ast::AttrsOwner for ImplDef {}
-impl ast::VisibilityOwner for ImplDef {}
-impl ast::TypeParamsOwner for ImplDef {}
-impl ImplDef {
-    pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
-    pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
-    pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
-    pub fn impl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![impl]) }
-    pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
-    pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) }
-    pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) }
-}
-#[derive(Debug, Clone, PartialEq, Eq, Hash)]
 pub struct ParenType {
     pub(crate) syntax: SyntaxNode,
 }
@@ -920,18 +968,6 @@ impl MacroPat {
     pub fn macro_call(&self) -> Option<MacroCall> { support::child(&self.syntax) }
 }
 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub struct MacroCall {
-    pub(crate) syntax: SyntaxNode,
-}
-impl ast::AttrsOwner for MacroCall {}
-impl ast::NameOwner for MacroCall {}
-impl MacroCall {
-    pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
-    pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
-    pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) }
-    pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
-}
-#[derive(Debug, Clone, PartialEq, Eq, Hash)]
 pub struct RecordPat {
     pub(crate) syntax: SyntaxNode,
 }
@@ -1125,17 +1161,6 @@ impl Param {
     pub fn dotdotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![...]) }
 }
 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub struct UseItem {
-    pub(crate) syntax: SyntaxNode,
-}
-impl ast::AttrsOwner for UseItem {}
-impl ast::VisibilityOwner for UseItem {}
-impl UseItem {
-    pub fn use_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![use]) }
-    pub fn use_tree(&self) -> Option<UseTree> { support::child(&self.syntax) }
-    pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
-}
-#[derive(Debug, Clone, PartialEq, Eq, Hash)]
 pub struct UseTree {
     pub(crate) syntax: SyntaxNode,
 }
@@ -1164,20 +1189,6 @@ impl Alias {
     pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) }
 }
 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub struct ExternCrateItem {
-    pub(crate) syntax: SyntaxNode,
-}
-impl ast::AttrsOwner for ExternCrateItem {}
-impl ast::VisibilityOwner for ExternCrateItem {}
-impl ExternCrateItem {
-    pub fn extern_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![extern]) }
-    pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) }
-    pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
-    pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
-    pub fn alias(&self) -> Option<Alias> { support::child(&self.syntax) }
-    pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
-}
-#[derive(Debug, Clone, PartialEq, Eq, Hash)]
 pub struct PathSegment {
     pub(crate) syntax: SyntaxNode,
 }
@@ -1229,15 +1240,6 @@ impl ConstArg {
     pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) }
 }
 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub struct ExternBlock {
-    pub(crate) syntax: SyntaxNode,
-}
-impl ast::AttrsOwner for ExternBlock {}
-impl ExternBlock {
-    pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) }
-    pub fn extern_item_list(&self) -> Option<ExternItemList> { support::child(&self.syntax) }
-}
-#[derive(Debug, Clone, PartialEq, Eq, Hash)]
 pub struct ExternItemList {
     pub(crate) syntax: SyntaxNode,
 }
@@ -1257,23 +1259,23 @@ impl MetaItem {
     pub fn nested_meta_items(&self) -> AstChildren<MetaItem> { support::children(&self.syntax) }
 }
 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub enum ModuleItem {
-    StructDef(StructDef),
-    UnionDef(UnionDef),
+pub enum Item {
+    ConstDef(ConstDef),
     EnumDef(EnumDef),
+    ExternBlock(ExternBlock),
+    ExternCrateItem(ExternCrateItem),
     FnDef(FnDef),
+    ImplDef(ImplDef),
+    MacroCall(MacroCall),
+    Module(Module),
+    StaticDef(StaticDef),
+    StructDef(StructDef),
     TraitDef(TraitDef),
     TypeAliasDef(TypeAliasDef),
-    ImplDef(ImplDef),
+    UnionDef(UnionDef),
     UseItem(UseItem),
-    ExternCrateItem(ExternCrateItem),
-    ConstDef(ConstDef),
-    StaticDef(StaticDef),
-    Module(Module),
-    MacroCall(MacroCall),
-    ExternBlock(ExternBlock),
 }
-impl ast::AttrsOwner for ModuleItem {}
+impl ast::AttrsOwner for Item {}
 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
 pub enum TypeRef {
     ParenType(ParenType),
@@ -1381,12 +1383,45 @@ pub enum AdtDef {
     EnumDef(EnumDef),
     UnionDef(UnionDef),
 }
-impl ast::AttrsOwner for AdtDef {}
-impl ast::NameOwner for AdtDef {}
-impl ast::TypeParamsOwner for AdtDef {}
-impl ast::VisibilityOwner for AdtDef {}
-impl AstNode for SourceFile {
-    fn can_cast(kind: SyntaxKind) -> bool { kind == SOURCE_FILE }
+impl ast::AttrsOwner for AdtDef {}
+impl ast::NameOwner for AdtDef {}
+impl ast::TypeParamsOwner for AdtDef {}
+impl ast::VisibilityOwner for AdtDef {}
+impl AstNode for SourceFile {
+    fn can_cast(kind: SyntaxKind) -> bool { kind == SOURCE_FILE }
+    fn cast(syntax: SyntaxNode) -> Option<Self> {
+        if Self::can_cast(syntax.kind()) {
+            Some(Self { syntax })
+        } else {
+            None
+        }
+    }
+    fn syntax(&self) -> &SyntaxNode { &self.syntax }
+}
+impl AstNode for Attr {
+    fn can_cast(kind: SyntaxKind) -> bool { kind == ATTR }
+    fn cast(syntax: SyntaxNode) -> Option<Self> {
+        if Self::can_cast(syntax.kind()) {
+            Some(Self { syntax })
+        } else {
+            None
+        }
+    }
+    fn syntax(&self) -> &SyntaxNode { &self.syntax }
+}
+impl AstNode for ConstDef {
+    fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_DEF }
+    fn cast(syntax: SyntaxNode) -> Option<Self> {
+        if Self::can_cast(syntax.kind()) {
+            Some(Self { syntax })
+        } else {
+            None
+        }
+    }
+    fn syntax(&self) -> &SyntaxNode { &self.syntax }
+}
+impl AstNode for EnumDef {
+    fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_DEF }
     fn cast(syntax: SyntaxNode) -> Option<Self> {
         if Self::can_cast(syntax.kind()) {
             Some(Self { syntax })
@@ -1396,8 +1431,19 @@ impl AstNode for SourceFile {
     }
     fn syntax(&self) -> &SyntaxNode { &self.syntax }
 }
-impl AstNode for Attr {
-    fn can_cast(kind: SyntaxKind) -> bool { kind == ATTR }
+impl AstNode for ExternBlock {
+    fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_BLOCK }
+    fn cast(syntax: SyntaxNode) -> Option<Self> {
+        if Self::can_cast(syntax.kind()) {
+            Some(Self { syntax })
+        } else {
+            None
+        }
+    }
+    fn syntax(&self) -> &SyntaxNode { &self.syntax }
+}
+impl AstNode for ExternCrateItem {
+    fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_CRATE_ITEM }
     fn cast(syntax: SyntaxNode) -> Option<Self> {
         if Self::can_cast(syntax.kind()) {
             Some(Self { syntax })
@@ -1418,8 +1464,8 @@ impl AstNode for FnDef {
     }
     fn syntax(&self) -> &SyntaxNode { &self.syntax }
 }
-impl AstNode for Visibility {
-    fn can_cast(kind: SyntaxKind) -> bool { kind == VISIBILITY }
+impl AstNode for ImplDef {
+    fn can_cast(kind: SyntaxKind) -> bool { kind == IMPL_DEF }
     fn cast(syntax: SyntaxNode) -> Option<Self> {
         if Self::can_cast(syntax.kind()) {
             Some(Self { syntax })
@@ -1429,8 +1475,8 @@ impl AstNode for Visibility {
     }
     fn syntax(&self) -> &SyntaxNode { &self.syntax }
 }
-impl AstNode for Abi {
-    fn can_cast(kind: SyntaxKind) -> bool { kind == ABI }
+impl AstNode for MacroCall {
+    fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_CALL }
     fn cast(syntax: SyntaxNode) -> Option<Self> {
         if Self::can_cast(syntax.kind()) {
             Some(Self { syntax })
@@ -1440,8 +1486,8 @@ impl AstNode for Abi {
     }
     fn syntax(&self) -> &SyntaxNode { &self.syntax }
 }
-impl AstNode for Name {
-    fn can_cast(kind: SyntaxKind) -> bool { kind == NAME }
+impl AstNode for Module {
+    fn can_cast(kind: SyntaxKind) -> bool { kind == MODULE }
     fn cast(syntax: SyntaxNode) -> Option<Self> {
         if Self::can_cast(syntax.kind()) {
             Some(Self { syntax })
@@ -1451,8 +1497,8 @@ impl AstNode for Name {
     }
     fn syntax(&self) -> &SyntaxNode { &self.syntax }
 }
-impl AstNode for TypeParamList {
-    fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_PARAM_LIST }
+impl AstNode for StaticDef {
+    fn can_cast(kind: SyntaxKind) -> bool { kind == STATIC_DEF }
     fn cast(syntax: SyntaxNode) -> Option<Self> {
         if Self::can_cast(syntax.kind()) {
             Some(Self { syntax })
@@ -1462,8 +1508,8 @@ impl AstNode for TypeParamList {
     }
     fn syntax(&self) -> &SyntaxNode { &self.syntax }
 }
-impl AstNode for ParamList {
-    fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM_LIST }
+impl AstNode for StructDef {
+    fn can_cast(kind: SyntaxKind) -> bool { kind == STRUCT_DEF }
     fn cast(syntax: SyntaxNode) -> Option<Self> {
         if Self::can_cast(syntax.kind()) {
             Some(Self { syntax })
@@ -1473,8 +1519,8 @@ impl AstNode for ParamList {
     }
     fn syntax(&self) -> &SyntaxNode { &self.syntax }
 }
-impl AstNode for RetType {
-    fn can_cast(kind: SyntaxKind) -> bool { kind == RET_TYPE }
+impl AstNode for TraitDef {
+    fn can_cast(kind: SyntaxKind) -> bool { kind == TRAIT_DEF }
     fn cast(syntax: SyntaxNode) -> Option<Self> {
         if Self::can_cast(syntax.kind()) {
             Some(Self { syntax })
@@ -1484,8 +1530,8 @@ impl AstNode for RetType {
     }
     fn syntax(&self) -> &SyntaxNode { &self.syntax }
 }
-impl AstNode for WhereClause {
-    fn can_cast(kind: SyntaxKind) -> bool { kind == WHERE_CLAUSE }
+impl AstNode for TypeAliasDef {
+    fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ALIAS_DEF }
     fn cast(syntax: SyntaxNode) -> Option<Self> {
         if Self::can_cast(syntax.kind()) {
             Some(Self { syntax })
@@ -1495,8 +1541,8 @@ impl AstNode for WhereClause {
     }
     fn syntax(&self) -> &SyntaxNode { &self.syntax }
 }
-impl AstNode for BlockExpr {
-    fn can_cast(kind: SyntaxKind) -> bool { kind == BLOCK_EXPR }
+impl AstNode for UnionDef {
+    fn can_cast(kind: SyntaxKind) -> bool { kind == UNION_DEF }
     fn cast(syntax: SyntaxNode) -> Option<Self> {
         if Self::can_cast(syntax.kind()) {
             Some(Self { syntax })
@@ -1506,8 +1552,8 @@ impl AstNode for BlockExpr {
     }
     fn syntax(&self) -> &SyntaxNode { &self.syntax }
 }
-impl AstNode for StructDef {
-    fn can_cast(kind: SyntaxKind) -> bool { kind == STRUCT_DEF }
+impl AstNode for UseItem {
+    fn can_cast(kind: SyntaxKind) -> bool { kind == USE_ITEM }
     fn cast(syntax: SyntaxNode) -> Option<Self> {
         if Self::can_cast(syntax.kind()) {
             Some(Self { syntax })
@@ -1517,8 +1563,8 @@ impl AstNode for StructDef {
     }
     fn syntax(&self) -> &SyntaxNode { &self.syntax }
 }
-impl AstNode for RecordFieldDefList {
-    fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_DEF_LIST }
+impl AstNode for Visibility {
+    fn can_cast(kind: SyntaxKind) -> bool { kind == VISIBILITY }
     fn cast(syntax: SyntaxNode) -> Option<Self> {
         if Self::can_cast(syntax.kind()) {
             Some(Self { syntax })
@@ -1528,8 +1574,8 @@ impl AstNode for RecordFieldDefList {
     }
     fn syntax(&self) -> &SyntaxNode { &self.syntax }
 }
-impl AstNode for TupleFieldDefList {
-    fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_FIELD_DEF_LIST }
+impl AstNode for Abi {
+    fn can_cast(kind: SyntaxKind) -> bool { kind == ABI }
     fn cast(syntax: SyntaxNode) -> Option<Self> {
         if Self::can_cast(syntax.kind()) {
             Some(Self { syntax })
@@ -1539,8 +1585,8 @@ impl AstNode for TupleFieldDefList {
     }
     fn syntax(&self) -> &SyntaxNode { &self.syntax }
 }
-impl AstNode for UnionDef {
-    fn can_cast(kind: SyntaxKind) -> bool { kind == UNION_DEF }
+impl AstNode for Name {
+    fn can_cast(kind: SyntaxKind) -> bool { kind == NAME }
     fn cast(syntax: SyntaxNode) -> Option<Self> {
         if Self::can_cast(syntax.kind()) {
             Some(Self { syntax })
@@ -1550,8 +1596,8 @@ impl AstNode for UnionDef {
     }
     fn syntax(&self) -> &SyntaxNode { &self.syntax }
 }
-impl AstNode for RecordFieldDef {
-    fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_DEF }
+impl AstNode for TypeParamList {
+    fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_PARAM_LIST }
     fn cast(syntax: SyntaxNode) -> Option<Self> {
         if Self::can_cast(syntax.kind()) {
             Some(Self { syntax })
@@ -1561,8 +1607,8 @@ impl AstNode for RecordFieldDef {
     }
     fn syntax(&self) -> &SyntaxNode { &self.syntax }
 }
-impl AstNode for TupleFieldDef {
-    fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_FIELD_DEF }
+impl AstNode for ParamList {
+    fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM_LIST }
     fn cast(syntax: SyntaxNode) -> Option<Self> {
         if Self::can_cast(syntax.kind()) {
             Some(Self { syntax })
@@ -1572,8 +1618,8 @@ impl AstNode for TupleFieldDef {
     }
     fn syntax(&self) -> &SyntaxNode { &self.syntax }
 }
-impl AstNode for EnumDef {
-    fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_DEF }
+impl AstNode for RetType {
+    fn can_cast(kind: SyntaxKind) -> bool { kind == RET_TYPE }
     fn cast(syntax: SyntaxNode) -> Option<Self> {
         if Self::can_cast(syntax.kind()) {
             Some(Self { syntax })
@@ -1583,8 +1629,8 @@ impl AstNode for EnumDef {
     }
     fn syntax(&self) -> &SyntaxNode { &self.syntax }
 }
-impl AstNode for EnumVariantList {
-    fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_VARIANT_LIST }
+impl AstNode for WhereClause {
+    fn can_cast(kind: SyntaxKind) -> bool { kind == WHERE_CLAUSE }
     fn cast(syntax: SyntaxNode) -> Option<Self> {
         if Self::can_cast(syntax.kind()) {
             Some(Self { syntax })
@@ -1594,8 +1640,8 @@ impl AstNode for EnumVariantList {
     }
     fn syntax(&self) -> &SyntaxNode { &self.syntax }
 }
-impl AstNode for EnumVariant {
-    fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_VARIANT }
+impl AstNode for BlockExpr {
+    fn can_cast(kind: SyntaxKind) -> bool { kind == BLOCK_EXPR }
     fn cast(syntax: SyntaxNode) -> Option<Self> {
         if Self::can_cast(syntax.kind()) {
             Some(Self { syntax })
@@ -1605,8 +1651,8 @@ impl AstNode for EnumVariant {
     }
     fn syntax(&self) -> &SyntaxNode { &self.syntax }
 }
-impl AstNode for TraitDef {
-    fn can_cast(kind: SyntaxKind) -> bool { kind == TRAIT_DEF }
+impl AstNode for RecordFieldDefList {
+    fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_DEF_LIST }
     fn cast(syntax: SyntaxNode) -> Option<Self> {
         if Self::can_cast(syntax.kind()) {
             Some(Self { syntax })
@@ -1616,8 +1662,8 @@ impl AstNode for TraitDef {
     }
     fn syntax(&self) -> &SyntaxNode { &self.syntax }
 }
-impl AstNode for TypeBoundList {
-    fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND_LIST }
+impl AstNode for TupleFieldDefList {
+    fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_FIELD_DEF_LIST }
     fn cast(syntax: SyntaxNode) -> Option<Self> {
         if Self::can_cast(syntax.kind()) {
             Some(Self { syntax })
@@ -1627,8 +1673,8 @@ impl AstNode for TypeBoundList {
     }
     fn syntax(&self) -> &SyntaxNode { &self.syntax }
 }
-impl AstNode for ItemList {
-    fn can_cast(kind: SyntaxKind) -> bool { kind == ITEM_LIST }
+impl AstNode for RecordFieldDef {
+    fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_DEF }
     fn cast(syntax: SyntaxNode) -> Option<Self> {
         if Self::can_cast(syntax.kind()) {
             Some(Self { syntax })
@@ -1638,8 +1684,8 @@ impl AstNode for ItemList {
     }
     fn syntax(&self) -> &SyntaxNode { &self.syntax }
 }
-impl AstNode for Module {
-    fn can_cast(kind: SyntaxKind) -> bool { kind == MODULE }
+impl AstNode for TupleFieldDef {
+    fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_FIELD_DEF }
     fn cast(syntax: SyntaxNode) -> Option<Self> {
         if Self::can_cast(syntax.kind()) {
             Some(Self { syntax })
@@ -1649,8 +1695,8 @@ impl AstNode for Module {
     }
     fn syntax(&self) -> &SyntaxNode { &self.syntax }
 }
-impl AstNode for ConstDef {
-    fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_DEF }
+impl AstNode for EnumVariantList {
+    fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_VARIANT_LIST }
     fn cast(syntax: SyntaxNode) -> Option<Self> {
         if Self::can_cast(syntax.kind()) {
             Some(Self { syntax })
@@ -1660,8 +1706,8 @@ impl AstNode for ConstDef {
     }
     fn syntax(&self) -> &SyntaxNode { &self.syntax }
 }
-impl AstNode for StaticDef {
-    fn can_cast(kind: SyntaxKind) -> bool { kind == STATIC_DEF }
+impl AstNode for EnumVariant {
+    fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_VARIANT }
     fn cast(syntax: SyntaxNode) -> Option<Self> {
         if Self::can_cast(syntax.kind()) {
             Some(Self { syntax })
@@ -1671,8 +1717,8 @@ impl AstNode for StaticDef {
     }
     fn syntax(&self) -> &SyntaxNode { &self.syntax }
 }
-impl AstNode for TypeAliasDef {
-    fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ALIAS_DEF }
+impl AstNode for TypeBoundList {
+    fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND_LIST }
     fn cast(syntax: SyntaxNode) -> Option<Self> {
         if Self::can_cast(syntax.kind()) {
             Some(Self { syntax })
@@ -1682,8 +1728,8 @@ impl AstNode for TypeAliasDef {
     }
     fn syntax(&self) -> &SyntaxNode { &self.syntax }
 }
-impl AstNode for ImplDef {
-    fn can_cast(kind: SyntaxKind) -> bool { kind == IMPL_DEF }
+impl AstNode for ItemList {
+    fn can_cast(kind: SyntaxKind) -> bool { kind == ITEM_LIST }
     fn cast(syntax: SyntaxNode) -> Option<Self> {
         if Self::can_cast(syntax.kind()) {
             Some(Self { syntax })
@@ -2397,17 +2443,6 @@ impl AstNode for MacroPat {
     }
     fn syntax(&self) -> &SyntaxNode { &self.syntax }
 }
-impl AstNode for MacroCall {
-    fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_CALL }
-    fn cast(syntax: SyntaxNode) -> Option<Self> {
-        if Self::can_cast(syntax.kind()) {
-            Some(Self { syntax })
-        } else {
-            None
-        }
-    }
-    fn syntax(&self) -> &SyntaxNode { &self.syntax }
-}
 impl AstNode for RecordPat {
     fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_PAT }
     fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2606,17 +2641,6 @@ impl AstNode for Param {
     }
     fn syntax(&self) -> &SyntaxNode { &self.syntax }
 }
-impl AstNode for UseItem {
-    fn can_cast(kind: SyntaxKind) -> bool { kind == USE_ITEM }
-    fn cast(syntax: SyntaxNode) -> Option<Self> {
-        if Self::can_cast(syntax.kind()) {
-            Some(Self { syntax })
-        } else {
-            None
-        }
-    }
-    fn syntax(&self) -> &SyntaxNode { &self.syntax }
-}
 impl AstNode for UseTree {
     fn can_cast(kind: SyntaxKind) -> bool { kind == USE_TREE }
     fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2650,17 +2674,6 @@ impl AstNode for Alias {
     }
     fn syntax(&self) -> &SyntaxNode { &self.syntax }
 }
-impl AstNode for ExternCrateItem {
-    fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_CRATE_ITEM }
-    fn cast(syntax: SyntaxNode) -> Option<Self> {
-        if Self::can_cast(syntax.kind()) {
-            Some(Self { syntax })
-        } else {
-            None
-        }
-    }
-    fn syntax(&self) -> &SyntaxNode { &self.syntax }
-}
 impl AstNode for PathSegment {
     fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_SEGMENT }
     fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2716,17 +2729,6 @@ impl AstNode for ConstArg {
     }
     fn syntax(&self) -> &SyntaxNode { &self.syntax }
 }
-impl AstNode for ExternBlock {
-    fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_BLOCK }
-    fn cast(syntax: SyntaxNode) -> Option<Self> {
-        if Self::can_cast(syntax.kind()) {
-            Some(Self { syntax })
-        } else {
-            None
-        }
-    }
-    fn syntax(&self) -> &SyntaxNode { &self.syntax }
-}
 impl AstNode for ExternItemList {
     fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_ITEM_LIST }
     fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2749,93 +2751,93 @@ impl AstNode for MetaItem {
     }
     fn syntax(&self) -> &SyntaxNode { &self.syntax }
 }
-impl From<StructDef> for ModuleItem {
-    fn from(node: StructDef) -> ModuleItem { ModuleItem::StructDef(node) }
+impl From<ConstDef> for Item {
+    fn from(node: ConstDef) -> Item { Item::ConstDef(node) }
 }
-impl From<UnionDef> for ModuleItem {
-    fn from(node: UnionDef) -> ModuleItem { ModuleItem::UnionDef(node) }
+impl From<EnumDef> for Item {
+    fn from(node: EnumDef) -> Item { Item::EnumDef(node) }
 }
-impl From<EnumDef> for ModuleItem {
-    fn from(node: EnumDef) -> ModuleItem { ModuleItem::EnumDef(node) }
+impl From<ExternBlock> for Item {
+    fn from(node: ExternBlock) -> Item { Item::ExternBlock(node) }
 }
-impl From<FnDef> for ModuleItem {
-    fn from(node: FnDef) -> ModuleItem { ModuleItem::FnDef(node) }
+impl From<ExternCrateItem> for Item {
+    fn from(node: ExternCrateItem) -> Item { Item::ExternCrateItem(node) }
 }
-impl From<TraitDef> for ModuleItem {
-    fn from(node: TraitDef) -> ModuleItem { ModuleItem::TraitDef(node) }
+impl From<FnDef> for Item {
+    fn from(node: FnDef) -> Item { Item::FnDef(node) }
 }
-impl From<TypeAliasDef> for ModuleItem {
-    fn from(node: TypeAliasDef) -> ModuleItem { ModuleItem::TypeAliasDef(node) }
+impl From<ImplDef> for Item {
+    fn from(node: ImplDef) -> Item { Item::ImplDef(node) }
 }
-impl From<ImplDef> for ModuleItem {
-    fn from(node: ImplDef) -> ModuleItem { ModuleItem::ImplDef(node) }
+impl From<MacroCall> for Item {
+    fn from(node: MacroCall) -> Item { Item::MacroCall(node) }
 }
-impl From<UseItem> for ModuleItem {
-    fn from(node: UseItem) -> ModuleItem { ModuleItem::UseItem(node) }
+impl From<Module> for Item {
+    fn from(node: Module) -> Item { Item::Module(node) }
 }
-impl From<ExternCrateItem> for ModuleItem {
-    fn from(node: ExternCrateItem) -> ModuleItem { ModuleItem::ExternCrateItem(node) }
+impl From<StaticDef> for Item {
+    fn from(node: StaticDef) -> Item { Item::StaticDef(node) }
 }
-impl From<ConstDef> for ModuleItem {
-    fn from(node: ConstDef) -> ModuleItem { ModuleItem::ConstDef(node) }
+impl From<StructDef> for Item {
+    fn from(node: StructDef) -> Item { Item::StructDef(node) }
 }
-impl From<StaticDef> for ModuleItem {
-    fn from(node: StaticDef) -> ModuleItem { ModuleItem::StaticDef(node) }
+impl From<TraitDef> for Item {
+    fn from(node: TraitDef) -> Item { Item::TraitDef(node) }
 }
-impl From<Module> for ModuleItem {
-    fn from(node: Module) -> ModuleItem { ModuleItem::Module(node) }
+impl From<TypeAliasDef> for Item {
+    fn from(node: TypeAliasDef) -> Item { Item::TypeAliasDef(node) }
 }
-impl From<MacroCall> for ModuleItem {
-    fn from(node: MacroCall) -> ModuleItem { ModuleItem::MacroCall(node) }
+impl From<UnionDef> for Item {
+    fn from(node: UnionDef) -> Item { Item::UnionDef(node) }
 }
-impl From<ExternBlock> for ModuleItem {
-    fn from(node: ExternBlock) -> ModuleItem { ModuleItem::ExternBlock(node) }
+impl From<UseItem> for Item {
+    fn from(node: UseItem) -> Item { Item::UseItem(node) }
 }
-impl AstNode for ModuleItem {
+impl AstNode for Item {
     fn can_cast(kind: SyntaxKind) -> bool {
         match kind {
-            STRUCT_DEF | UNION_DEF | ENUM_DEF | FN_DEF | TRAIT_DEF | TYPE_ALIAS_DEF | IMPL_DEF
-            | USE_ITEM | EXTERN_CRATE_ITEM | CONST_DEF | STATIC_DEF | MODULE | MACRO_CALL
-            | EXTERN_BLOCK => true,
+            CONST_DEF | ENUM_DEF | EXTERN_BLOCK | EXTERN_CRATE_ITEM | FN_DEF | IMPL_DEF
+            | MACRO_CALL | MODULE | STATIC_DEF | STRUCT_DEF | TRAIT_DEF | TYPE_ALIAS_DEF
+            | UNION_DEF | USE_ITEM => true,
             _ => false,
         }
     }
     fn cast(syntax: SyntaxNode) -> Option<Self> {
         let res = match syntax.kind() {
-            STRUCT_DEF => ModuleItem::StructDef(StructDef { syntax }),
-            UNION_DEF => ModuleItem::UnionDef(UnionDef { syntax }),
-            ENUM_DEF => ModuleItem::EnumDef(EnumDef { syntax }),
-            FN_DEF => ModuleItem::FnDef(FnDef { syntax }),
-            TRAIT_DEF => ModuleItem::TraitDef(TraitDef { syntax }),
-            TYPE_ALIAS_DEF => ModuleItem::TypeAliasDef(TypeAliasDef { syntax }),
-            IMPL_DEF => ModuleItem::ImplDef(ImplDef { syntax }),
-            USE_ITEM => ModuleItem::UseItem(UseItem { syntax }),
-            EXTERN_CRATE_ITEM => ModuleItem::ExternCrateItem(ExternCrateItem { syntax }),
-            CONST_DEF => ModuleItem::ConstDef(ConstDef { syntax }),
-            STATIC_DEF => ModuleItem::StaticDef(StaticDef { syntax }),
-            MODULE => ModuleItem::Module(Module { syntax }),
-            MACRO_CALL => ModuleItem::MacroCall(MacroCall { syntax }),
-            EXTERN_BLOCK => ModuleItem::ExternBlock(ExternBlock { syntax }),
+            CONST_DEF => Item::ConstDef(ConstDef { syntax }),
+            ENUM_DEF => Item::EnumDef(EnumDef { syntax }),
+            EXTERN_BLOCK => Item::ExternBlock(ExternBlock { syntax }),
+            EXTERN_CRATE_ITEM => Item::ExternCrateItem(ExternCrateItem { syntax }),
+            FN_DEF => Item::FnDef(FnDef { syntax }),
+            IMPL_DEF => Item::ImplDef(ImplDef { syntax }),
+            MACRO_CALL => Item::MacroCall(MacroCall { syntax }),
+            MODULE => Item::Module(Module { syntax }),
+            STATIC_DEF => Item::StaticDef(StaticDef { syntax }),
+            STRUCT_DEF => Item::StructDef(StructDef { syntax }),
+            TRAIT_DEF => Item::TraitDef(TraitDef { syntax }),
+            TYPE_ALIAS_DEF => Item::TypeAliasDef(TypeAliasDef { syntax }),
+            UNION_DEF => Item::UnionDef(UnionDef { syntax }),
+            USE_ITEM => Item::UseItem(UseItem { syntax }),
             _ => return None,
         };
         Some(res)
     }
     fn syntax(&self) -> &SyntaxNode {
         match self {
-            ModuleItem::StructDef(it) => &it.syntax,
-            ModuleItem::UnionDef(it) => &it.syntax,
-            ModuleItem::EnumDef(it) => &it.syntax,
-            ModuleItem::FnDef(it) => &it.syntax,
-            ModuleItem::TraitDef(it) => &it.syntax,
-            ModuleItem::TypeAliasDef(it) => &it.syntax,
-            ModuleItem::ImplDef(it) => &it.syntax,
-            ModuleItem::UseItem(it) => &it.syntax,
-            ModuleItem::ExternCrateItem(it) => &it.syntax,
-            ModuleItem::ConstDef(it) => &it.syntax,
-            ModuleItem::StaticDef(it) => &it.syntax,
-            ModuleItem::Module(it) => &it.syntax,
-            ModuleItem::MacroCall(it) => &it.syntax,
-            ModuleItem::ExternBlock(it) => &it.syntax,
+            Item::ConstDef(it) => &it.syntax,
+            Item::EnumDef(it) => &it.syntax,
+            Item::ExternBlock(it) => &it.syntax,
+            Item::ExternCrateItem(it) => &it.syntax,
+            Item::FnDef(it) => &it.syntax,
+            Item::ImplDef(it) => &it.syntax,
+            Item::MacroCall(it) => &it.syntax,
+            Item::Module(it) => &it.syntax,
+            Item::StaticDef(it) => &it.syntax,
+            Item::StructDef(it) => &it.syntax,
+            Item::TraitDef(it) => &it.syntax,
+            Item::TypeAliasDef(it) => &it.syntax,
+            Item::UnionDef(it) => &it.syntax,
+            Item::UseItem(it) => &it.syntax,
         }
     }
 }
@@ -3378,7 +3380,7 @@ impl AstNode for AdtDef {
         }
     }
 }
-impl std::fmt::Display for ModuleItem {
+impl std::fmt::Display for Item {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         std::fmt::Display::fmt(self.syntax(), f)
     }
@@ -3438,47 +3440,47 @@ impl std::fmt::Display for Attr {
         std::fmt::Display::fmt(self.syntax(), f)
     }
 }
-impl std::fmt::Display for FnDef {
+impl std::fmt::Display for ConstDef {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         std::fmt::Display::fmt(self.syntax(), f)
     }
 }
-impl std::fmt::Display for Visibility {
+impl std::fmt::Display for EnumDef {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         std::fmt::Display::fmt(self.syntax(), f)
     }
 }
-impl std::fmt::Display for Abi {
+impl std::fmt::Display for ExternBlock {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         std::fmt::Display::fmt(self.syntax(), f)
     }
 }
-impl std::fmt::Display for Name {
+impl std::fmt::Display for ExternCrateItem {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         std::fmt::Display::fmt(self.syntax(), f)
     }
 }
-impl std::fmt::Display for TypeParamList {
+impl std::fmt::Display for FnDef {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         std::fmt::Display::fmt(self.syntax(), f)
     }
 }
-impl std::fmt::Display for ParamList {
+impl std::fmt::Display for ImplDef {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         std::fmt::Display::fmt(self.syntax(), f)
     }
 }
-impl std::fmt::Display for RetType {
+impl std::fmt::Display for MacroCall {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         std::fmt::Display::fmt(self.syntax(), f)
     }
 }
-impl std::fmt::Display for WhereClause {
+impl std::fmt::Display for Module {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         std::fmt::Display::fmt(self.syntax(), f)
     }
 }
-impl std::fmt::Display for BlockExpr {
+impl std::fmt::Display for StaticDef {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         std::fmt::Display::fmt(self.syntax(), f)
     }
@@ -3488,12 +3490,12 @@ impl std::fmt::Display for StructDef {
         std::fmt::Display::fmt(self.syntax(), f)
     }
 }
-impl std::fmt::Display for RecordFieldDefList {
+impl std::fmt::Display for TraitDef {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         std::fmt::Display::fmt(self.syntax(), f)
     }
 }
-impl std::fmt::Display for TupleFieldDefList {
+impl std::fmt::Display for TypeAliasDef {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         std::fmt::Display::fmt(self.syntax(), f)
     }
@@ -3503,67 +3505,87 @@ impl std::fmt::Display for UnionDef {
         std::fmt::Display::fmt(self.syntax(), f)
     }
 }
-impl std::fmt::Display for RecordFieldDef {
+impl std::fmt::Display for UseItem {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         std::fmt::Display::fmt(self.syntax(), f)
     }
 }
-impl std::fmt::Display for TupleFieldDef {
+impl std::fmt::Display for Visibility {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         std::fmt::Display::fmt(self.syntax(), f)
     }
 }
-impl std::fmt::Display for EnumDef {
+impl std::fmt::Display for Abi {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         std::fmt::Display::fmt(self.syntax(), f)
     }
 }
-impl std::fmt::Display for EnumVariantList {
+impl std::fmt::Display for Name {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         std::fmt::Display::fmt(self.syntax(), f)
     }
 }
-impl std::fmt::Display for EnumVariant {
+impl std::fmt::Display for TypeParamList {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         std::fmt::Display::fmt(self.syntax(), f)
     }
 }
-impl std::fmt::Display for TraitDef {
+impl std::fmt::Display for ParamList {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         std::fmt::Display::fmt(self.syntax(), f)
     }
 }
-impl std::fmt::Display for TypeBoundList {
+impl std::fmt::Display for RetType {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         std::fmt::Display::fmt(self.syntax(), f)
     }
 }
-impl std::fmt::Display for ItemList {
+impl std::fmt::Display for WhereClause {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         std::fmt::Display::fmt(self.syntax(), f)
     }
 }
-impl std::fmt::Display for Module {
+impl std::fmt::Display for BlockExpr {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         std::fmt::Display::fmt(self.syntax(), f)
     }
 }
-impl std::fmt::Display for ConstDef {
+impl std::fmt::Display for RecordFieldDefList {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         std::fmt::Display::fmt(self.syntax(), f)
     }
 }
-impl std::fmt::Display for StaticDef {
+impl std::fmt::Display for TupleFieldDefList {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         std::fmt::Display::fmt(self.syntax(), f)
     }
 }
-impl std::fmt::Display for TypeAliasDef {
+impl std::fmt::Display for RecordFieldDef {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         std::fmt::Display::fmt(self.syntax(), f)
     }
 }
-impl std::fmt::Display for ImplDef {
+impl std::fmt::Display for TupleFieldDef {
+    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+        std::fmt::Display::fmt(self.syntax(), f)
+    }
+}
+impl std::fmt::Display for EnumVariantList {
+    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+        std::fmt::Display::fmt(self.syntax(), f)
+    }
+}
+impl std::fmt::Display for EnumVariant {
+    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+        std::fmt::Display::fmt(self.syntax(), f)
+    }
+}
+impl std::fmt::Display for TypeBoundList {
+    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+        std::fmt::Display::fmt(self.syntax(), f)
+    }
+}
+impl std::fmt::Display for ItemList {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         std::fmt::Display::fmt(self.syntax(), f)
     }
@@ -3888,11 +3910,6 @@ impl std::fmt::Display for MacroPat {
         std::fmt::Display::fmt(self.syntax(), f)
     }
 }
-impl std::fmt::Display for MacroCall {
-    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
-        std::fmt::Display::fmt(self.syntax(), f)
-    }
-}
 impl std::fmt::Display for RecordPat {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         std::fmt::Display::fmt(self.syntax(), f)
@@ -3983,11 +4000,6 @@ impl std::fmt::Display for Param {
         std::fmt::Display::fmt(self.syntax(), f)
     }
 }
-impl std::fmt::Display for UseItem {
-    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
-        std::fmt::Display::fmt(self.syntax(), f)
-    }
-}
 impl std::fmt::Display for UseTree {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         std::fmt::Display::fmt(self.syntax(), f)
@@ -4003,11 +4015,6 @@ impl std::fmt::Display for Alias {
         std::fmt::Display::fmt(self.syntax(), f)
     }
 }
-impl std::fmt::Display for ExternCrateItem {
-    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
-        std::fmt::Display::fmt(self.syntax(), f)
-    }
-}
 impl std::fmt::Display for PathSegment {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         std::fmt::Display::fmt(self.syntax(), f)
@@ -4033,11 +4040,6 @@ impl std::fmt::Display for ConstArg {
         std::fmt::Display::fmt(self.syntax(), f)
     }
 }
-impl std::fmt::Display for ExternBlock {
-    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
-        std::fmt::Display::fmt(self.syntax(), f)
-    }
-}
 impl std::fmt::Display for ExternItemList {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         std::fmt::Display::fmt(self.syntax(), f)
diff --git a/crates/ra_syntax/src/ast/traits.rs b/crates/ra_syntax/src/ast/traits.rs
index a8f2454fd9..9fe0b93c1e 100644
--- a/crates/ra_syntax/src/ast/traits.rs
+++ b/crates/ra_syntax/src/ast/traits.rs
@@ -44,7 +44,7 @@ pub trait ArgListOwner: AstNode {
 }
 
 pub trait ModuleItemOwner: AstNode {
-    fn items(&self) -> AstChildren<ast::ModuleItem> {
+    fn items(&self) -> AstChildren<ast::Item> {
         support::children(self.syntax())
     }
 }
diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs
index ac59455e74..219dd0b077 100644
--- a/crates/ra_syntax/src/lib.rs
+++ b/crates/ra_syntax/src/lib.rs
@@ -187,7 +187,7 @@ impl ast::Expr {
     }
 }
 
-impl ast::ModuleItem {
+impl ast::Item {
     /// Returns `text`, parsed as an item, but only if it has no errors.
     pub fn parse(text: &str) -> Result<Self, ()> {
         parsing::parse_text_fragment(text, ra_parser::FragmentKind::Item)
@@ -255,7 +255,7 @@ fn api_walkthrough() {
     let mut func = None;
     for item in file.items() {
         match item {
-            ast::ModuleItem::FnDef(f) => func = Some(f),
+            ast::Item::FnDef(f) => func = Some(f),
             _ => unreachable!(),
         }
     }
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs
index 87a1367ac2..1350bd4002 100644
--- a/crates/rust-analyzer/src/handlers.rs
+++ b/crates/rust-analyzer/src/handlers.rs
@@ -469,12 +469,12 @@ pub(crate) fn handle_runnables(
         res.push(runnable);
     }
 
-    // Add `cargo check` and `cargo test` for all targets of the whole package
+    // Add `cargo check` and `cargo test` for the whole package
     match cargo_spec {
         Some(spec) => {
             for &cmd in ["check", "test"].iter() {
                 res.push(lsp_ext::Runnable {
-                    label: format!("cargo {} -p {} --all-targets", cmd, spec.package),
+                    label: format!("cargo {} -p {}", cmd, spec.package),
                     location: None,
                     kind: lsp_ext::RunnableKind::Cargo,
                     args: lsp_ext::CargoRunnable {
@@ -483,7 +483,6 @@ pub(crate) fn handle_runnables(
                             cmd.to_string(),
                             "--package".to_string(),
                             spec.package.clone(),
-                            "--all-targets".to_string(),
                         ],
                         executable_args: Vec::new(),
                         expect_test: None,
diff --git a/xtask/src/codegen/gen_syntax.rs b/xtask/src/codegen/gen_syntax.rs
index 24e8be1fbc..9b49712c13 100644
--- a/xtask/src/codegen/gen_syntax.rs
+++ b/xtask/src/codegen/gen_syntax.rs
@@ -374,6 +374,7 @@ fn generate_syntax_kinds(grammar: KindsSrc<'_>) -> Result<String> {
             #([#all_keywords_idents] => { $crate::SyntaxKind::#all_keywords };)*
             [lifetime] => { $crate::SyntaxKind::LIFETIME };
             [ident] => { $crate::SyntaxKind::IDENT };
+            [shebang] => { $crate::SyntaxKind::SHEBANG };
         }
     };
 
@@ -595,7 +596,6 @@ fn lower_rule(acc: &mut Vec<Field>, grammar: &Grammar, rule: &Rule) {
 }
 
 fn deduplicate_fields(ast: &mut AstSrc) {
-    eprintln!();
     for node in &mut ast.nodes {
         let mut i = 0;
         'outer: while i < node.fields.len() {
diff --git a/xtask/src/codegen/rust.ungram b/xtask/src/codegen/rust.ungram
index b6ec5d5e78..a93cb38158 100644
--- a/xtask/src/codegen/rust.ungram
+++ b/xtask/src/codegen/rust.ungram
@@ -1,6 +1,23 @@
 SourceFile =
+  'shebang'?
   Attr*
-  items:ModuleItem*
+  Item*
+
+Item =
+  ConstDef
+| EnumDef
+| ExternBlock
+| ExternCrateItem
+| FnDef
+| ImplDef
+| MacroCall
+| Module
+| StaticDef
+| StructDef
+| TraitDef
+| TypeAliasDef
+| UnionDef
+| UseItem
 
 FnDef =
  Attr* Visibility? Abi? 'const' 'default' 'async' 'unsafe' 'fn' Name TypeParamList?
@@ -59,7 +76,7 @@ Module =
 ItemList =
   '{'
     AssocItem*
-    items:ModuleItem*
+    Item*
   '}'
 
 ConstDef =
@@ -168,7 +185,7 @@ Label =
 BlockExpr =
   Attr* Label
   '{'
-    items:ModuleItem*
+    Item*
     statements:Stmt*
     Expr?
   '}'
@@ -316,7 +333,7 @@ TokenTree =
   '(' ')' | '{' '}' | '[' ']'
 
 MacroItems =
-  items:ModuleItem*
+  Item*
 
 MacroStmts =
   statements:Stmt*
@@ -454,22 +471,6 @@ AssocItem =
 ExternItem =
   FnDef | StaticDef
 
-ModuleItem =
-  StructDef
-| UnionDef
-| EnumDef
-| FnDef
-| TraitDef
-| TypeAliasDef
-| ImplDef
-| UseItem
-| ExternCrateItem
-| ConstDef
-| StaticDef
-| Module
-| MacroCall
-| ExternBlock
-
 AttrInput =
   Literal
 | TokenTree


Test patch:
diff --git a/crates/ra_hir_def/src/item_tree/tests.rs b/crates/ra_hir_def/src/item_tree/tests.rs
index f26982985f..a6057ceab5 100644
--- a/crates/ra_hir_def/src/item_tree/tests.rs
+++ b/crates/ra_hir_def/src/item_tree/tests.rs
@@ -21,7 +21,7 @@ fn test_inner_items(ra_fixture: &str) {
     let mut outer_items = FxHashSet::default();
     let mut worklist = tree.top_level_items().to_vec();
     while let Some(item) = worklist.pop() {
-        let node: ast::ModuleItem = match item {
+        let node: ast::Item = match item {
             ModItem::Import(it) => tree.source(&db, InFile::new(file_id, it)).into(),
             ModItem::ExternCrate(it) => tree.source(&db, InFile::new(file_id, it)).into(),
             ModItem::Function(it) => tree.source(&db, InFile::new(file_id, it)).into(),
@@ -53,7 +53,7 @@ fn test_inner_items(ra_fixture: &str) {
 
     // Now descend the root node and check that all `ast::ModuleItem`s are either recorded above, or
     // registered as inner items.
-    for item in root.descendants().skip(1).filter_map(ast::ModuleItem::cast) {
+    for item in root.descendants().skip(1).filter_map(ast::Item::cast) {
         if outer_items.contains(&item) {
             continue;
         }
@@ -279,7 +279,7 @@ fn simple_inner_items() {
 
             inner items:
 
-            for AST FileAstId::<ra_syntax::ast::generated::nodes::ModuleItem>(2):
+            for AST FileAstId::<ra_syntax::ast::generated::nodes::Item>(2):
             Function { name: Name(Text("end")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(1), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(2) }
 
         "#]],
@@ -412,7 +412,7 @@ fn inner_item_attrs() {
 
             inner items:
 
-            for AST FileAstId::<ra_syntax::ast::generated::nodes::ModuleItem>(1):
+            for AST FileAstId::<ra_syntax::ast::generated::nodes::Item>(1):
             #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("on_inner"))] }, input: None }]) }]
             Function { name: Name(Text("inner")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(1) }
 
diff --git a/crates/ra_syntax/src/tests.rs b/crates/ra_syntax/src/tests.rs
index 8447dcad70..68cee89149 100644
--- a/crates/ra_syntax/src/tests.rs
+++ b/crates/ra_syntax/src/tests.rs
@@ -89,7 +89,7 @@ fn item_parser_tests() {
     fragment_parser_dir_test(
         &["parser/fragments/item/ok"],
         &["parser/fragments/item/err"],
-        crate::ast::ModuleItem::parse,
+        crate::ast::Item::parse,
     );
 }
 
diff --git a/crates/rust-analyzer/tests/heavy_tests/main.rs b/crates/rust-analyzer/tests/heavy_tests/main.rs
index 7370505f8b..28e8966487 100644
--- a/crates/rust-analyzer/tests/heavy_tests/main.rs
+++ b/crates/rust-analyzer/tests/heavy_tests/main.rs
@@ -115,21 +115,21 @@ fn main() {}
           },
           {
             "args": {
-              "cargoArgs": ["check", "--package", "foo", "--all-targets"],
+              "cargoArgs": ["check", "--package", "foo"],
               "executableArgs": [],
               "workspaceRoot": server.path().join("foo")
             },
             "kind": "cargo",
-            "label": "cargo check -p foo --all-targets"
+            "label": "cargo check -p foo"
           },
           {
             "args": {
-              "cargoArgs": ["test", "--package", "foo", "--all-targets"],
+              "cargoArgs": ["test", "--package", "foo"],
               "executableArgs": [],
               "workspaceRoot": server.path().join("foo")
             },
             "kind": "cargo",
-            "label": "cargo test -p foo --all-targets"
+            "label": "cargo test -p foo"
           }
         ]),
     );