diff options
26 files changed, 584 insertions, 512 deletions
diff --git a/Cargo.lock b/Cargo.lock index c656f846d..3e685b7f1 100644 --- a/Cargo.lock +++ b/Cargo.lock | |||
@@ -102,13 +102,12 @@ checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" | |||
102 | 102 | ||
103 | [[package]] | 103 | [[package]] |
104 | name = "cargo_metadata" | 104 | name = "cargo_metadata" |
105 | version = "0.10.0" | 105 | version = "0.11.1" |
106 | source = "registry+https://github.com/rust-lang/crates.io-index" | 106 | source = "registry+https://github.com/rust-lang/crates.io-index" |
107 | checksum = "b8de60b887edf6d74370fc8eb177040da4847d971d6234c7b13a6da324ef0caf" | 107 | checksum = "89fec17b16f1ac67908af82e47d0a90a7afd0e1827b181cd77504323d3263d35" |
108 | dependencies = [ | 108 | dependencies = [ |
109 | "semver", | 109 | "semver", |
110 | "serde", | 110 | "serde", |
111 | "serde_derive", | ||
112 | "serde_json", | 111 | "serde_json", |
113 | ] | 112 | ] |
114 | 113 | ||
@@ -319,9 +318,9 @@ dependencies = [ | |||
319 | 318 | ||
320 | [[package]] | 319 | [[package]] |
321 | name = "filetime" | 320 | name = "filetime" |
322 | version = "0.2.10" | 321 | version = "0.2.11" |
323 | source = "registry+https://github.com/rust-lang/crates.io-index" | 322 | source = "registry+https://github.com/rust-lang/crates.io-index" |
324 | checksum = "affc17579b132fc2461adf7c575cc6e8b134ebca52c51f5411388965227dc695" | 323 | checksum = "e500da2fab70bdc43f8f0e0b350a227f31c72311c56aba48f01d5cd62bb0345b" |
325 | dependencies = [ | 324 | dependencies = [ |
326 | "cfg-if", | 325 | "cfg-if", |
327 | "libc", | 326 | "libc", |
@@ -554,9 +553,9 @@ checksum = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" | |||
554 | 553 | ||
555 | [[package]] | 554 | [[package]] |
556 | name = "libc" | 555 | name = "libc" |
557 | version = "0.2.73" | 556 | version = "0.2.74" |
558 | source = "registry+https://github.com/rust-lang/crates.io-index" | 557 | source = "registry+https://github.com/rust-lang/crates.io-index" |
559 | checksum = "bd7d4bd64732af4bf3a67f367c27df8520ad7e230c5817b8ff485864d80242b9" | 558 | checksum = "a2f02823cf78b754822df5f7f268fb59822e7296276d3e069d8e8cb26a14bd10" |
560 | 559 | ||
561 | [[package]] | 560 | [[package]] |
562 | name = "libloading" | 561 | name = "libloading" |
@@ -1422,9 +1421,9 @@ dependencies = [ | |||
1422 | 1421 | ||
1423 | [[package]] | 1422 | [[package]] |
1424 | name = "semver" | 1423 | name = "semver" |
1425 | version = "0.9.0" | 1424 | version = "0.10.0" |
1426 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1425 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1427 | checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" | 1426 | checksum = "394cec28fa623e00903caf7ba4fa6fb9a0e260280bb8cdbbba029611108a0190" |
1428 | dependencies = [ | 1427 | dependencies = [ |
1429 | "semver-parser", | 1428 | "semver-parser", |
1430 | "serde", | 1429 | "serde", |
diff --git a/crates/flycheck/Cargo.toml b/crates/flycheck/Cargo.toml index bea485694..ff8a1e568 100644 --- a/crates/flycheck/Cargo.toml +++ b/crates/flycheck/Cargo.toml | |||
@@ -11,7 +11,7 @@ doctest = false | |||
11 | [dependencies] | 11 | [dependencies] |
12 | crossbeam-channel = "0.4.0" | 12 | crossbeam-channel = "0.4.0" |
13 | log = "0.4.8" | 13 | log = "0.4.8" |
14 | cargo_metadata = "0.10.0" | 14 | cargo_metadata = "0.11.1" |
15 | serde_json = "1.0.48" | 15 | serde_json = "1.0.48" |
16 | jod-thread = "0.1.1" | 16 | jod-thread = "0.1.1" |
17 | ra_toolchain = { path = "../ra_toolchain" } | 17 | ra_toolchain = { path = "../ra_toolchain" } |
diff --git a/crates/ra_assists/src/handlers/remove_dbg.rs b/crates/ra_assists/src/handlers/remove_dbg.rs index a616cca57..9430ce1b5 100644 --- a/crates/ra_assists/src/handlers/remove_dbg.rs +++ b/crates/ra_assists/src/handlers/remove_dbg.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | use ra_syntax::{ | 1 | use ra_syntax::{ |
2 | ast::{self, AstNode}, | 2 | ast::{self, AstNode}, |
3 | TextSize, T, | 3 | TextRange, TextSize, T, |
4 | }; | 4 | }; |
5 | 5 | ||
6 | use crate::{AssistContext, AssistId, AssistKind, Assists}; | 6 | use crate::{AssistContext, AssistId, AssistKind, Assists}; |
@@ -27,19 +27,33 @@ pub(crate) fn remove_dbg(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | |||
27 | return None; | 27 | return None; |
28 | } | 28 | } |
29 | 29 | ||
30 | let macro_range = macro_call.syntax().text_range(); | 30 | let is_leaf = macro_call.syntax().next_sibling().is_none(); |
31 | 31 | ||
32 | let macro_content = { | 32 | let macro_end = if macro_call.semicolon_token().is_some() { |
33 | let macro_args = macro_call.token_tree()?.syntax().clone(); | 33 | macro_call.syntax().text_range().end() - TextSize::of(';') |
34 | } else { | ||
35 | macro_call.syntax().text_range().end() | ||
36 | }; | ||
34 | 37 | ||
35 | let text = macro_args.text(); | 38 | // macro_range determines what will be deleted and replaced with macro_content |
36 | let without_parens = TextSize::of('(')..text.len() - TextSize::of(')'); | 39 | let macro_range = TextRange::new(macro_call.syntax().text_range().start(), macro_end); |
37 | text.slice(without_parens).to_string() | 40 | let paste_instead_of_dbg = { |
41 | let text = macro_call.token_tree()?.syntax().text(); | ||
42 | |||
43 | // leafiness determines if we should include the parenthesis or not | ||
44 | let slice_index: TextRange = if is_leaf { | ||
45 | // leaf means - we can extract the contents of the dbg! in text | ||
46 | TextRange::new(TextSize::of('('), text.len() - TextSize::of(')')) | ||
47 | } else { | ||
48 | // not leaf - means we should keep the parens | ||
49 | TextRange::up_to(text.len()) | ||
50 | }; | ||
51 | text.slice(slice_index).to_string() | ||
38 | }; | 52 | }; |
39 | 53 | ||
40 | let target = macro_call.syntax().text_range(); | 54 | let target = macro_call.syntax().text_range(); |
41 | acc.add(AssistId("remove_dbg", AssistKind::Refactor), "Remove dbg!()", target, |builder| { | 55 | acc.add(AssistId("remove_dbg", AssistKind::Refactor), "Remove dbg!()", target, |builder| { |
42 | builder.replace(macro_range, macro_content); | 56 | builder.replace(macro_range, paste_instead_of_dbg); |
43 | }) | 57 | }) |
44 | } | 58 | } |
45 | 59 | ||
@@ -99,6 +113,7 @@ fn foo(n: usize) { | |||
99 | ", | 113 | ", |
100 | ); | 114 | ); |
101 | } | 115 | } |
116 | |||
102 | #[test] | 117 | #[test] |
103 | fn test_remove_dbg_with_brackets_and_braces() { | 118 | fn test_remove_dbg_with_brackets_and_braces() { |
104 | check_assist(remove_dbg, "dbg![<|>1 + 1]", "1 + 1"); | 119 | check_assist(remove_dbg, "dbg![<|>1 + 1]", "1 + 1"); |
@@ -113,7 +128,7 @@ fn foo(n: usize) { | |||
113 | } | 128 | } |
114 | 129 | ||
115 | #[test] | 130 | #[test] |
116 | fn remove_dbg_target() { | 131 | fn test_remove_dbg_target() { |
117 | check_assist_target( | 132 | check_assist_target( |
118 | remove_dbg, | 133 | remove_dbg, |
119 | " | 134 | " |
@@ -126,4 +141,65 @@ fn foo(n: usize) { | |||
126 | "dbg!(n.checked_sub(4))", | 141 | "dbg!(n.checked_sub(4))", |
127 | ); | 142 | ); |
128 | } | 143 | } |
144 | |||
145 | #[test] | ||
146 | fn test_remove_dbg_keep_semicolon() { | ||
147 | // https://github.com/rust-analyzer/rust-analyzer/issues/5129#issuecomment-651399779 | ||
148 | // not quite though | ||
149 | // adding a comment at the end of the line makes | ||
150 | // the ast::MacroCall to include the semicolon at the end | ||
151 | check_assist( | ||
152 | remove_dbg, | ||
153 | r#"let res = <|>dbg!(1 * 20); // needless comment"#, | ||
154 | r#"let res = 1 * 20; // needless comment"#, | ||
155 | ); | ||
156 | } | ||
157 | |||
158 | #[test] | ||
159 | fn test_remove_dbg_keep_expression() { | ||
160 | check_assist( | ||
161 | remove_dbg, | ||
162 | r#"let res = <|>dbg!(a + b).foo();"#, | ||
163 | r#"let res = (a + b).foo();"#, | ||
164 | ); | ||
165 | } | ||
166 | |||
167 | #[test] | ||
168 | fn test_remove_dbg_from_inside_fn() { | ||
169 | check_assist_target( | ||
170 | remove_dbg, | ||
171 | r#" | ||
172 | fn square(x: u32) -> u32 { | ||
173 | x * x | ||
174 | } | ||
175 | |||
176 | fn main() { | ||
177 | let x = square(dbg<|>!(5 + 10)); | ||
178 | println!("{}", x); | ||
179 | }"#, | ||
180 | "dbg!(5 + 10)", | ||
181 | ); | ||
182 | |||
183 | check_assist( | ||
184 | remove_dbg, | ||
185 | r#" | ||
186 | fn square(x: u32) -> u32 { | ||
187 | x * x | ||
188 | } | ||
189 | |||
190 | fn main() { | ||
191 | let x = square(dbg<|>!(5 + 10)); | ||
192 | println!("{}", x); | ||
193 | }"#, | ||
194 | r#" | ||
195 | fn square(x: u32) -> u32 { | ||
196 | x * x | ||
197 | } | ||
198 | |||
199 | fn main() { | ||
200 | let x = square(5 + 10); | ||
201 | println!("{}", x); | ||
202 | }"#, | ||
203 | ); | ||
204 | } | ||
129 | } | 205 | } |
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index c6bc85e2f..c33b645f3 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<'_> { | |||
627 | .items() | 627 | .items() |
628 | .filter_map(|item| { | 628 | .filter_map(|item| { |
629 | let (def, name): (ModuleDefId, Option<ast::Name>) = match item { | 629 | let (def, name): (ModuleDefId, Option<ast::Name>) = match item { |
630 | ast::ModuleItem::FnDef(def) => { | 630 | ast::Item::FnDef(def) => { |
631 | let id = self.find_inner_item(&def)?; | 631 | let id = self.find_inner_item(&def)?; |
632 | ( | 632 | ( |
633 | FunctionLoc { container: container.into(), id }.intern(self.db).into(), | 633 | FunctionLoc { container: container.into(), id }.intern(self.db).into(), |
634 | def.name(), | 634 | def.name(), |
635 | ) | 635 | ) |
636 | } | 636 | } |
637 | ast::ModuleItem::TypeAliasDef(def) => { | 637 | ast::Item::TypeAliasDef(def) => { |
638 | let id = self.find_inner_item(&def)?; | 638 | let id = self.find_inner_item(&def)?; |
639 | ( | 639 | ( |
640 | TypeAliasLoc { container: container.into(), id }.intern(self.db).into(), | 640 | TypeAliasLoc { container: container.into(), id }.intern(self.db).into(), |
641 | def.name(), | 641 | def.name(), |
642 | ) | 642 | ) |
643 | } | 643 | } |
644 | ast::ModuleItem::ConstDef(def) => { | 644 | ast::Item::ConstDef(def) => { |
645 | let id = self.find_inner_item(&def)?; | 645 | let id = self.find_inner_item(&def)?; |
646 | ( | 646 | ( |
647 | ConstLoc { container: container.into(), id }.intern(self.db).into(), | 647 | ConstLoc { container: container.into(), id }.intern(self.db).into(), |
648 | def.name(), | 648 | def.name(), |
649 | ) | 649 | ) |
650 | } | 650 | } |
651 | ast::ModuleItem::StaticDef(def) => { | 651 | ast::Item::StaticDef(def) => { |
652 | let id = self.find_inner_item(&def)?; | 652 | let id = self.find_inner_item(&def)?; |
653 | (StaticLoc { container, id }.intern(self.db).into(), def.name()) | 653 | (StaticLoc { container, id }.intern(self.db).into(), def.name()) |
654 | } | 654 | } |
655 | ast::ModuleItem::StructDef(def) => { | 655 | ast::Item::StructDef(def) => { |
656 | let id = self.find_inner_item(&def)?; | 656 | let id = self.find_inner_item(&def)?; |
657 | (StructLoc { container, id }.intern(self.db).into(), def.name()) | 657 | (StructLoc { container, id }.intern(self.db).into(), def.name()) |
658 | } | 658 | } |
659 | ast::ModuleItem::EnumDef(def) => { | 659 | ast::Item::EnumDef(def) => { |
660 | let id = self.find_inner_item(&def)?; | 660 | let id = self.find_inner_item(&def)?; |
661 | (EnumLoc { container, id }.intern(self.db).into(), def.name()) | 661 | (EnumLoc { container, id }.intern(self.db).into(), def.name()) |
662 | } | 662 | } |
663 | ast::ModuleItem::UnionDef(def) => { | 663 | ast::Item::UnionDef(def) => { |
664 | let id = self.find_inner_item(&def)?; | 664 | let id = self.find_inner_item(&def)?; |
665 | (UnionLoc { container, id }.intern(self.db).into(), def.name()) | 665 | (UnionLoc { container, id }.intern(self.db).into(), def.name()) |
666 | } | 666 | } |
667 | ast::ModuleItem::TraitDef(def) => { | 667 | ast::Item::TraitDef(def) => { |
668 | let id = self.find_inner_item(&def)?; | 668 | let id = self.find_inner_item(&def)?; |
669 | (TraitLoc { container, id }.intern(self.db).into(), def.name()) | 669 | (TraitLoc { container, id }.intern(self.db).into(), def.name()) |
670 | } | 670 | } |
671 | ast::ModuleItem::ExternBlock(_) => return None, // FIXME: collect from extern blocks | 671 | ast::Item::ExternBlock(_) => return None, // FIXME: collect from extern blocks |
672 | ast::ModuleItem::ImplDef(_) | 672 | ast::Item::ImplDef(_) |
673 | | ast::ModuleItem::UseItem(_) | 673 | | ast::Item::UseItem(_) |
674 | | ast::ModuleItem::ExternCrateItem(_) | 674 | | ast::Item::ExternCrateItem(_) |
675 | | ast::ModuleItem::Module(_) | 675 | | ast::Item::Module(_) |
676 | | ast::ModuleItem::MacroCall(_) => return None, | 676 | | ast::Item::MacroCall(_) => return None, |
677 | }; | 677 | }; |
678 | 678 | ||
679 | Some((def, name)) | 679 | Some((def, name)) |
diff --git a/crates/ra_hir_def/src/item_tree.rs b/crates/ra_hir_def/src/item_tree.rs index da79d8ffd..615c1e14c 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 { | |||
70 | pub struct ItemTree { | 70 | pub struct ItemTree { |
71 | top_level: SmallVec<[ModItem; 1]>, | 71 | top_level: SmallVec<[ModItem; 1]>, |
72 | attrs: FxHashMap<AttrOwner, Attrs>, | 72 | attrs: FxHashMap<AttrOwner, Attrs>, |
73 | inner_items: FxHashMap<FileAstId<ast::ModuleItem>, SmallVec<[ModItem; 1]>>, | 73 | inner_items: FxHashMap<FileAstId<ast::Item>, SmallVec<[ModItem; 1]>>, |
74 | 74 | ||
75 | data: Option<Box<ItemTreeData>>, | 75 | data: Option<Box<ItemTreeData>>, |
76 | } | 76 | } |
@@ -187,7 +187,7 @@ impl ItemTree { | |||
187 | /// | 187 | /// |
188 | /// Most AST items are lowered to a single `ModItem`, but some (eg. `use` items) may be lowered | 188 | /// Most AST items are lowered to a single `ModItem`, but some (eg. `use` items) may be lowered |
189 | /// to multiple items in the `ItemTree`. | 189 | /// to multiple items in the `ItemTree`. |
190 | pub fn inner_items(&self, ast: FileAstId<ast::ModuleItem>) -> &[ModItem] { | 190 | pub fn inner_items(&self, ast: FileAstId<ast::Item>) -> &[ModItem] { |
191 | &self.inner_items[&ast] | 191 | &self.inner_items[&ast] |
192 | } | 192 | } |
193 | 193 | ||
@@ -310,7 +310,7 @@ from_attrs!(ModItem(ModItem), Variant(Idx<Variant>), Field(Idx<Field>)); | |||
310 | 310 | ||
311 | /// Trait implemented by all item nodes in the item tree. | 311 | /// Trait implemented by all item nodes in the item tree. |
312 | pub trait ItemTreeNode: Clone { | 312 | pub trait ItemTreeNode: Clone { |
313 | type Source: AstNode + Into<ast::ModuleItem>; | 313 | type Source: AstNode + Into<ast::Item>; |
314 | 314 | ||
315 | fn ast_id(&self) -> FileAstId<Self::Source>; | 315 | fn ast_id(&self) -> FileAstId<Self::Source>; |
316 | 316 | ||
diff --git a/crates/ra_hir_def/src/item_tree/lower.rs b/crates/ra_hir_def/src/item_tree/lower.rs index f79b8fca3..eb1da4632 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 { | |||
70 | self.tree.data_mut() | 70 | self.tree.data_mut() |
71 | } | 71 | } |
72 | 72 | ||
73 | fn lower_mod_item(&mut self, item: &ast::ModuleItem, inner: bool) -> Option<ModItems> { | 73 | fn lower_mod_item(&mut self, item: &ast::Item, inner: bool) -> Option<ModItems> { |
74 | assert!(inner || self.inner_items.is_empty()); | 74 | assert!(inner || self.inner_items.is_empty()); |
75 | 75 | ||
76 | // Collect inner items for 1-to-1-lowered items. | 76 | // Collect inner items for 1-to-1-lowered items. |
77 | match item { | 77 | match item { |
78 | ast::ModuleItem::StructDef(_) | 78 | ast::Item::StructDef(_) |
79 | | ast::ModuleItem::UnionDef(_) | 79 | | ast::Item::UnionDef(_) |
80 | | ast::ModuleItem::EnumDef(_) | 80 | | ast::Item::EnumDef(_) |
81 | | ast::ModuleItem::FnDef(_) | 81 | | ast::Item::FnDef(_) |
82 | | ast::ModuleItem::TypeAliasDef(_) | 82 | | ast::Item::TypeAliasDef(_) |
83 | | ast::ModuleItem::ConstDef(_) | 83 | | ast::Item::ConstDef(_) |
84 | | ast::ModuleItem::StaticDef(_) | 84 | | ast::Item::StaticDef(_) |
85 | | ast::ModuleItem::MacroCall(_) => { | 85 | | ast::Item::MacroCall(_) => { |
86 | // Skip this if we're already collecting inner items. We'll descend into all nodes | 86 | // Skip this if we're already collecting inner items. We'll descend into all nodes |
87 | // already. | 87 | // already. |
88 | if !inner { | 88 | if !inner { |
@@ -92,34 +92,30 @@ impl Ctx { | |||
92 | 92 | ||
93 | // These are handled in their respective `lower_X` method (since we can't just blindly | 93 | // These are handled in their respective `lower_X` method (since we can't just blindly |
94 | // walk them). | 94 | // walk them). |
95 | ast::ModuleItem::TraitDef(_) | 95 | ast::Item::TraitDef(_) | ast::Item::ImplDef(_) | ast::Item::ExternBlock(_) => {} |
96 | | ast::ModuleItem::ImplDef(_) | ||
97 | | ast::ModuleItem::ExternBlock(_) => {} | ||
98 | 96 | ||
99 | // These don't have inner items. | 97 | // These don't have inner items. |
100 | ast::ModuleItem::Module(_) | 98 | ast::Item::Module(_) | ast::Item::ExternCrateItem(_) | ast::Item::UseItem(_) => {} |
101 | | ast::ModuleItem::ExternCrateItem(_) | ||
102 | | ast::ModuleItem::UseItem(_) => {} | ||
103 | }; | 99 | }; |
104 | 100 | ||
105 | let attrs = Attrs::new(item, &self.hygiene); | 101 | let attrs = Attrs::new(item, &self.hygiene); |
106 | let items = match item { | 102 | let items = match item { |
107 | ast::ModuleItem::StructDef(ast) => self.lower_struct(ast).map(Into::into), | 103 | ast::Item::StructDef(ast) => self.lower_struct(ast).map(Into::into), |
108 | ast::ModuleItem::UnionDef(ast) => self.lower_union(ast).map(Into::into), | 104 | ast::Item::UnionDef(ast) => self.lower_union(ast).map(Into::into), |
109 | ast::ModuleItem::EnumDef(ast) => self.lower_enum(ast).map(Into::into), | 105 | ast::Item::EnumDef(ast) => self.lower_enum(ast).map(Into::into), |
110 | ast::ModuleItem::FnDef(ast) => self.lower_function(ast).map(Into::into), | 106 | ast::Item::FnDef(ast) => self.lower_function(ast).map(Into::into), |
111 | ast::ModuleItem::TypeAliasDef(ast) => self.lower_type_alias(ast).map(Into::into), | 107 | ast::Item::TypeAliasDef(ast) => self.lower_type_alias(ast).map(Into::into), |
112 | ast::ModuleItem::StaticDef(ast) => self.lower_static(ast).map(Into::into), | 108 | ast::Item::StaticDef(ast) => self.lower_static(ast).map(Into::into), |
113 | ast::ModuleItem::ConstDef(ast) => Some(self.lower_const(ast).into()), | 109 | ast::Item::ConstDef(ast) => Some(self.lower_const(ast).into()), |
114 | ast::ModuleItem::Module(ast) => self.lower_module(ast).map(Into::into), | 110 | ast::Item::Module(ast) => self.lower_module(ast).map(Into::into), |
115 | ast::ModuleItem::TraitDef(ast) => self.lower_trait(ast).map(Into::into), | 111 | ast::Item::TraitDef(ast) => self.lower_trait(ast).map(Into::into), |
116 | ast::ModuleItem::ImplDef(ast) => self.lower_impl(ast).map(Into::into), | 112 | ast::Item::ImplDef(ast) => self.lower_impl(ast).map(Into::into), |
117 | ast::ModuleItem::UseItem(ast) => Some(ModItems( | 113 | ast::Item::UseItem(ast) => Some(ModItems( |
118 | self.lower_use(ast).into_iter().map(Into::into).collect::<SmallVec<_>>(), | 114 | self.lower_use(ast).into_iter().map(Into::into).collect::<SmallVec<_>>(), |
119 | )), | 115 | )), |
120 | ast::ModuleItem::ExternCrateItem(ast) => self.lower_extern_crate(ast).map(Into::into), | 116 | ast::Item::ExternCrateItem(ast) => self.lower_extern_crate(ast).map(Into::into), |
121 | ast::ModuleItem::MacroCall(ast) => self.lower_macro_call(ast).map(Into::into), | 117 | ast::Item::MacroCall(ast) => self.lower_macro_call(ast).map(Into::into), |
122 | ast::ModuleItem::ExternBlock(ast) => { | 118 | ast::Item::ExternBlock(ast) => { |
123 | Some(ModItems(self.lower_extern_block(ast).into_iter().collect::<SmallVec<_>>())) | 119 | Some(ModItems(self.lower_extern_block(ast).into_iter().collect::<SmallVec<_>>())) |
124 | } | 120 | } |
125 | }; | 121 | }; |
@@ -147,22 +143,22 @@ impl Ctx { | |||
147 | fn collect_inner_items(&mut self, container: &SyntaxNode) { | 143 | fn collect_inner_items(&mut self, container: &SyntaxNode) { |
148 | let forced_vis = self.forced_visibility.take(); | 144 | let forced_vis = self.forced_visibility.take(); |
149 | let mut inner_items = mem::take(&mut self.tree.inner_items); | 145 | let mut inner_items = mem::take(&mut self.tree.inner_items); |
150 | inner_items.extend( | 146 | inner_items.extend(container.descendants().skip(1).filter_map(ast::Item::cast).filter_map( |
151 | container.descendants().skip(1).filter_map(ast::ModuleItem::cast).filter_map(|item| { | 147 | |item| { |
152 | let ast_id = self.source_ast_id_map.ast_id(&item); | 148 | let ast_id = self.source_ast_id_map.ast_id(&item); |
153 | Some((ast_id, self.lower_mod_item(&item, true)?.0)) | 149 | Some((ast_id, self.lower_mod_item(&item, true)?.0)) |
154 | }), | 150 | }, |
155 | ); | 151 | )); |
156 | self.tree.inner_items = inner_items; | 152 | self.tree.inner_items = inner_items; |
157 | self.forced_visibility = forced_vis; | 153 | self.forced_visibility = forced_vis; |
158 | } | 154 | } |
159 | 155 | ||
160 | fn lower_assoc_item(&mut self, item: &ast::ModuleItem) -> Option<AssocItem> { | 156 | fn lower_assoc_item(&mut self, item: &ast::Item) -> Option<AssocItem> { |
161 | match item { | 157 | match item { |
162 | ast::ModuleItem::FnDef(ast) => self.lower_function(ast).map(Into::into), | 158 | ast::Item::FnDef(ast) => self.lower_function(ast).map(Into::into), |
163 | ast::ModuleItem::TypeAliasDef(ast) => self.lower_type_alias(ast).map(Into::into), | 159 | ast::Item::TypeAliasDef(ast) => self.lower_type_alias(ast).map(Into::into), |
164 | ast::ModuleItem::ConstDef(ast) => Some(self.lower_const(ast).into()), | 160 | ast::Item::ConstDef(ast) => Some(self.lower_const(ast).into()), |
165 | ast::ModuleItem::MacroCall(ast) => self.lower_macro_call(ast).map(Into::into), | 161 | ast::Item::MacroCall(ast) => self.lower_macro_call(ast).map(Into::into), |
166 | _ => None, | 162 | _ => None, |
167 | } | 163 | } |
168 | } | 164 | } |
diff --git a/crates/ra_hir_def/src/item_tree/tests.rs b/crates/ra_hir_def/src/item_tree/tests.rs index f26982985..a6057ceab 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) { | |||
21 | let mut outer_items = FxHashSet::default(); | 21 | let mut outer_items = FxHashSet::default(); |
22 | let mut worklist = tree.top_level_items().to_vec(); | 22 | let mut worklist = tree.top_level_items().to_vec(); |
23 | while let Some(item) = worklist.pop() { | 23 | while let Some(item) = worklist.pop() { |
24 | let node: ast::ModuleItem = match item { | 24 | let node: ast::Item = match item { |
25 | ModItem::Import(it) => tree.source(&db, InFile::new(file_id, it)).into(), | 25 | ModItem::Import(it) => tree.source(&db, InFile::new(file_id, it)).into(), |
26 | ModItem::ExternCrate(it) => tree.source(&db, InFile::new(file_id, it)).into(), | 26 | ModItem::ExternCrate(it) => tree.source(&db, InFile::new(file_id, it)).into(), |
27 | ModItem::Function(it) => tree.source(&db, InFile::new(file_id, it)).into(), | 27 | ModItem::Function(it) => tree.source(&db, InFile::new(file_id, it)).into(), |
@@ -53,7 +53,7 @@ fn test_inner_items(ra_fixture: &str) { | |||
53 | 53 | ||
54 | // Now descend the root node and check that all `ast::ModuleItem`s are either recorded above, or | 54 | // Now descend the root node and check that all `ast::ModuleItem`s are either recorded above, or |
55 | // registered as inner items. | 55 | // registered as inner items. |
56 | for item in root.descendants().skip(1).filter_map(ast::ModuleItem::cast) { | 56 | for item in root.descendants().skip(1).filter_map(ast::Item::cast) { |
57 | if outer_items.contains(&item) { | 57 | if outer_items.contains(&item) { |
58 | continue; | 58 | continue; |
59 | } | 59 | } |
@@ -279,7 +279,7 @@ fn simple_inner_items() { | |||
279 | 279 | ||
280 | inner items: | 280 | inner items: |
281 | 281 | ||
282 | for AST FileAstId::<ra_syntax::ast::generated::nodes::ModuleItem>(2): | 282 | for AST FileAstId::<ra_syntax::ast::generated::nodes::Item>(2): |
283 | 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) } | 283 | 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) } |
284 | 284 | ||
285 | "#]], | 285 | "#]], |
@@ -412,7 +412,7 @@ fn inner_item_attrs() { | |||
412 | 412 | ||
413 | inner items: | 413 | inner items: |
414 | 414 | ||
415 | for AST FileAstId::<ra_syntax::ast::generated::nodes::ModuleItem>(1): | 415 | for AST FileAstId::<ra_syntax::ast::generated::nodes::Item>(1): |
416 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("on_inner"))] }, input: None }]) }] | 416 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("on_inner"))] }, input: None }]) }] |
417 | 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) } | 417 | 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) } |
418 | 418 | ||
diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs index 87000fe98..237b1038a 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> { | |||
521 | } | 521 | } |
522 | } | 522 | } |
523 | 523 | ||
524 | impl AsMacroCall for AstIdWithPath<ast::ModuleItem> { | 524 | impl AsMacroCall for AstIdWithPath<ast::Item> { |
525 | fn as_call_id( | 525 | fn as_call_id( |
526 | &self, | 526 | &self, |
527 | db: &dyn db::DefDatabase, | 527 | 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 a030cab47..28b7a20c5 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 { | |||
170 | #[derive(Clone, Debug, Eq, PartialEq)] | 170 | #[derive(Clone, Debug, Eq, PartialEq)] |
171 | struct DeriveDirective { | 171 | struct DeriveDirective { |
172 | module_id: LocalModuleId, | 172 | module_id: LocalModuleId, |
173 | ast_id: AstIdWithPath<ast::ModuleItem>, | 173 | ast_id: AstIdWithPath<ast::Item>, |
174 | } | 174 | } |
175 | 175 | ||
176 | struct DefData<'a> { | 176 | struct DefData<'a> { |
@@ -1100,7 +1100,7 @@ impl ModCollector<'_, '_> { | |||
1100 | res | 1100 | res |
1101 | } | 1101 | } |
1102 | 1102 | ||
1103 | fn collect_derives(&mut self, attrs: &Attrs, ast_id: FileAstId<ast::ModuleItem>) { | 1103 | fn collect_derives(&mut self, attrs: &Attrs, ast_id: FileAstId<ast::Item>) { |
1104 | for derive_subtree in attrs.by_key("derive").tt_values() { | 1104 | for derive_subtree in attrs.by_key("derive").tt_values() { |
1105 | // for #[derive(Copy, Clone)], `derive_subtree` is the `(Copy, Clone)` subtree | 1105 | // for #[derive(Copy, Clone)], `derive_subtree` is the `(Copy, Clone)` subtree |
1106 | for tt in &derive_subtree.token_trees { | 1106 | 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 f4d31526a..8bfe1b4ba 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 { | |||
73 | // change parent's id. This means that, say, adding a new function to a | 73 | // change parent's id. This means that, say, adding a new function to a |
74 | // trait does not change ids of top-level items, which helps caching. | 74 | // trait does not change ids of top-level items, which helps caching. |
75 | bfs(node, |it| { | 75 | bfs(node, |it| { |
76 | if let Some(module_item) = ast::ModuleItem::cast(it) { | 76 | if let Some(module_item) = ast::Item::cast(it) { |
77 | res.alloc(module_item.syntax()); | 77 | res.alloc(module_item.syntax()); |
78 | } | 78 | } |
79 | }); | 79 | }); |
diff --git a/crates/ra_hir_expand/src/builtin_derive.rs b/crates/ra_hir_expand/src/builtin_derive.rs index f2d664863..8f70a3567 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 { | |||
276 | let file_id = file_pos.file_id; | 276 | let file_id = file_pos.file_id; |
277 | let parsed = db.parse(file_id); | 277 | let parsed = db.parse(file_id); |
278 | let items: Vec<_> = | 278 | let items: Vec<_> = |
279 | parsed.syntax_node().descendants().filter_map(ast::ModuleItem::cast).collect(); | 279 | parsed.syntax_node().descendants().filter_map(ast::Item::cast).collect(); |
280 | 280 | ||
281 | let ast_id_map = db.ast_id_map(file_id.into()); | 281 | let ast_id_map = db.ast_id_map(file_id.into()); |
282 | 282 | ||
diff --git a/crates/ra_hir_expand/src/lib.rs b/crates/ra_hir_expand/src/lib.rs index d9e31ac20..2e8d63691 100644 --- a/crates/ra_hir_expand/src/lib.rs +++ b/crates/ra_hir_expand/src/lib.rs | |||
@@ -159,7 +159,7 @@ impl HirFileId { | |||
159 | } | 159 | } |
160 | 160 | ||
161 | /// Indicate it is macro file generated for builtin derive | 161 | /// Indicate it is macro file generated for builtin derive |
162 | pub fn is_builtin_derive(&self, db: &dyn db::AstDatabase) -> Option<InFile<ast::ModuleItem>> { | 162 | pub fn is_builtin_derive(&self, db: &dyn db::AstDatabase) -> Option<InFile<ast::Item>> { |
163 | match self.0 { | 163 | match self.0 { |
164 | HirFileIdRepr::FileId(_) => None, | 164 | HirFileIdRepr::FileId(_) => None, |
165 | HirFileIdRepr::MacroFile(macro_file) => { | 165 | HirFileIdRepr::MacroFile(macro_file) => { |
@@ -174,7 +174,7 @@ impl HirFileId { | |||
174 | MacroDefKind::BuiltInDerive(_) => loc.kind.node(db), | 174 | MacroDefKind::BuiltInDerive(_) => loc.kind.node(db), |
175 | _ => return None, | 175 | _ => return None, |
176 | }; | 176 | }; |
177 | Some(item.with_value(ast::ModuleItem::cast(item.value.clone())?)) | 177 | Some(item.with_value(ast::Item::cast(item.value.clone())?)) |
178 | } | 178 | } |
179 | } | 179 | } |
180 | } | 180 | } |
@@ -258,7 +258,7 @@ pub struct MacroCallLoc { | |||
258 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 258 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
259 | pub enum MacroCallKind { | 259 | pub enum MacroCallKind { |
260 | FnLike(AstId<ast::MacroCall>), | 260 | FnLike(AstId<ast::MacroCall>), |
261 | Attr(AstId<ast::ModuleItem>, String), | 261 | Attr(AstId<ast::Item>, String), |
262 | } | 262 | } |
263 | 263 | ||
264 | impl MacroCallKind { | 264 | 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 db2abb4f1..7a53083f5 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) | |||
28 | } | 28 | } |
29 | }; | 29 | }; |
30 | for item in items { | 30 | for item in items { |
31 | if let ast::ModuleItem::FnDef(func) = item { | 31 | if let ast::Item::FnDef(func) = item { |
32 | if Some(&func) == me.as_ref() { | 32 | if Some(&func) == me.as_ref() { |
33 | continue; | 33 | continue; |
34 | } | 34 | } |
diff --git a/crates/ra_ide/src/runnables.rs b/crates/ra_ide/src/runnables.rs index 45e0a7d85..f612835c2 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 { | |||
246 | 246 | ||
247 | for item in item_list.items() { | 247 | for item in item_list.items() { |
248 | match item { | 248 | match item { |
249 | ast::ModuleItem::FnDef(f) => { | 249 | ast::Item::FnDef(f) => { |
250 | if has_test_related_attribute(&f) { | 250 | if has_test_related_attribute(&f) { |
251 | return true; | 251 | return true; |
252 | } | 252 | } |
253 | } | 253 | } |
254 | ast::ModuleItem::Module(submodule) => { | 254 | ast::Item::Module(submodule) => { |
255 | if has_test_function_or_multiple_test_submodules(&submodule) { | 255 | if has_test_function_or_multiple_test_submodules(&submodule) { |
256 | number_of_test_submodules += 1; | 256 | number_of_test_submodules += 1; |
257 | } | 257 | } |
diff --git a/crates/ra_parser/src/syntax_kind/generated.rs b/crates/ra_parser/src/syntax_kind/generated.rs index e7404492a..625f0c822 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 { | |||
362 | } | 362 | } |
363 | } | 363 | } |
364 | #[macro_export] | 364 | #[macro_export] |
365 | 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 } ; } | 365 | 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_proc_macro_srv/Cargo.toml b/crates/ra_proc_macro_srv/Cargo.toml index 12ce497f8..bc119a6c7 100644 --- a/crates/ra_proc_macro_srv/Cargo.toml +++ b/crates/ra_proc_macro_srv/Cargo.toml | |||
@@ -19,7 +19,7 @@ memmap = "0.7" | |||
19 | test_utils = { path = "../test_utils" } | 19 | test_utils = { path = "../test_utils" } |
20 | 20 | ||
21 | [dev-dependencies] | 21 | [dev-dependencies] |
22 | cargo_metadata = "0.10.0" | 22 | cargo_metadata = "0.11.1" |
23 | difference = "2.0.0" | 23 | difference = "2.0.0" |
24 | # used as proc macro test target | 24 | # used as proc macro test target |
25 | serde_derive = "1.0.106" | 25 | serde_derive = "1.0.106" |
diff --git a/crates/ra_project_model/Cargo.toml b/crates/ra_project_model/Cargo.toml index 827eb7e28..99adea8e4 100644 --- a/crates/ra_project_model/Cargo.toml +++ b/crates/ra_project_model/Cargo.toml | |||
@@ -12,7 +12,7 @@ doctest = false | |||
12 | log = "0.4.8" | 12 | log = "0.4.8" |
13 | rustc-hash = "1.1.0" | 13 | rustc-hash = "1.1.0" |
14 | 14 | ||
15 | cargo_metadata = "0.10.0" | 15 | cargo_metadata = "0.11.1" |
16 | 16 | ||
17 | ra_arena = { path = "../ra_arena" } | 17 | ra_arena = { path = "../ra_arena" } |
18 | ra_cfg = { path = "../ra_cfg" } | 18 | ra_cfg = { path = "../ra_cfg" } |
diff --git a/crates/ra_ssr/src/parsing.rs b/crates/ra_ssr/src/parsing.rs index 769720bef..78e03f394 100644 --- a/crates/ra_ssr/src/parsing.rs +++ b/crates/ra_ssr/src/parsing.rs | |||
@@ -71,10 +71,7 @@ impl ParsedRule { | |||
71 | }; | 71 | }; |
72 | builder.try_add(ast::Expr::parse(&raw_pattern), raw_template.map(ast::Expr::parse)); | 72 | builder.try_add(ast::Expr::parse(&raw_pattern), raw_template.map(ast::Expr::parse)); |
73 | builder.try_add(ast::TypeRef::parse(&raw_pattern), raw_template.map(ast::TypeRef::parse)); | 73 | builder.try_add(ast::TypeRef::parse(&raw_pattern), raw_template.map(ast::TypeRef::parse)); |
74 | builder.try_add( | 74 | builder.try_add(ast::Item::parse(&raw_pattern), raw_template.map(ast::Item::parse)); |
75 | ast::ModuleItem::parse(&raw_pattern), | ||
76 | raw_template.map(ast::ModuleItem::parse), | ||
77 | ); | ||
78 | builder.try_add(ast::Path::parse(&raw_pattern), raw_template.map(ast::Path::parse)); | 75 | builder.try_add(ast::Path::parse(&raw_pattern), raw_template.map(ast::Path::parse)); |
79 | builder.try_add(ast::Pat::parse(&raw_pattern), raw_template.map(ast::Pat::parse)); | 76 | builder.try_add(ast::Pat::parse(&raw_pattern), raw_template.map(ast::Pat::parse)); |
80 | builder.build() | 77 | builder.build() |
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index 04a4d354c..dfda79550 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 { | |||
11 | } | 11 | } |
12 | impl ast::AttrsOwner for SourceFile {} | 12 | impl ast::AttrsOwner for SourceFile {} |
13 | impl ast::ModuleItemOwner for SourceFile {} | 13 | impl ast::ModuleItemOwner for SourceFile {} |
14 | impl SourceFile {} | 14 | impl SourceFile { |
15 | pub fn shebang_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![shebang]) } | ||
16 | } | ||
15 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 17 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
16 | pub struct Attr { | 18 | pub struct Attr { |
17 | pub(crate) syntax: SyntaxNode, | 19 | pub(crate) syntax: SyntaxNode, |
@@ -26,6 +28,57 @@ impl Attr { | |||
26 | pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } | 28 | pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } |
27 | } | 29 | } |
28 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 30 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
31 | pub struct ConstDef { | ||
32 | pub(crate) syntax: SyntaxNode, | ||
33 | } | ||
34 | impl ast::AttrsOwner for ConstDef {} | ||
35 | impl ast::NameOwner for ConstDef {} | ||
36 | impl ast::VisibilityOwner for ConstDef {} | ||
37 | impl ast::TypeAscriptionOwner for ConstDef {} | ||
38 | impl ConstDef { | ||
39 | pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) } | ||
40 | pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } | ||
41 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } | ||
42 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } | ||
43 | pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
44 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | ||
45 | } | ||
46 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
47 | pub struct EnumDef { | ||
48 | pub(crate) syntax: SyntaxNode, | ||
49 | } | ||
50 | impl ast::AttrsOwner for EnumDef {} | ||
51 | impl ast::NameOwner for EnumDef {} | ||
52 | impl ast::VisibilityOwner for EnumDef {} | ||
53 | impl ast::TypeParamsOwner for EnumDef {} | ||
54 | impl EnumDef { | ||
55 | pub fn enum_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![enum]) } | ||
56 | pub fn variant_list(&self) -> Option<EnumVariantList> { support::child(&self.syntax) } | ||
57 | } | ||
58 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
59 | pub struct ExternBlock { | ||
60 | pub(crate) syntax: SyntaxNode, | ||
61 | } | ||
62 | impl ast::AttrsOwner for ExternBlock {} | ||
63 | impl ExternBlock { | ||
64 | pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) } | ||
65 | pub fn extern_item_list(&self) -> Option<ExternItemList> { support::child(&self.syntax) } | ||
66 | } | ||
67 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
68 | pub struct ExternCrateItem { | ||
69 | pub(crate) syntax: SyntaxNode, | ||
70 | } | ||
71 | impl ast::AttrsOwner for ExternCrateItem {} | ||
72 | impl ast::VisibilityOwner for ExternCrateItem {} | ||
73 | impl ExternCrateItem { | ||
74 | pub fn extern_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![extern]) } | ||
75 | pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) } | ||
76 | pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } | ||
77 | pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) } | ||
78 | pub fn alias(&self) -> Option<Alias> { support::child(&self.syntax) } | ||
79 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | ||
80 | } | ||
81 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
29 | pub struct FnDef { | 82 | pub struct FnDef { |
30 | pub(crate) syntax: SyntaxNode, | 83 | pub(crate) syntax: SyntaxNode, |
31 | } | 84 | } |
@@ -46,6 +99,131 @@ impl FnDef { | |||
46 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | 99 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } |
47 | } | 100 | } |
48 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 101 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
102 | pub struct ImplDef { | ||
103 | pub(crate) syntax: SyntaxNode, | ||
104 | } | ||
105 | impl ast::AttrsOwner for ImplDef {} | ||
106 | impl ast::VisibilityOwner for ImplDef {} | ||
107 | impl ast::TypeParamsOwner for ImplDef {} | ||
108 | impl ImplDef { | ||
109 | pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } | ||
110 | pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) } | ||
111 | pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) } | ||
112 | pub fn impl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![impl]) } | ||
113 | pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) } | ||
114 | pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) } | ||
115 | pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) } | ||
116 | } | ||
117 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
118 | pub struct MacroCall { | ||
119 | pub(crate) syntax: SyntaxNode, | ||
120 | } | ||
121 | impl ast::AttrsOwner for MacroCall {} | ||
122 | impl ast::NameOwner for MacroCall {} | ||
123 | impl MacroCall { | ||
124 | pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } | ||
125 | pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) } | ||
126 | pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) } | ||
127 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | ||
128 | } | ||
129 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
130 | pub struct Module { | ||
131 | pub(crate) syntax: SyntaxNode, | ||
132 | } | ||
133 | impl ast::AttrsOwner for Module {} | ||
134 | impl ast::NameOwner for Module {} | ||
135 | impl ast::VisibilityOwner for Module {} | ||
136 | impl Module { | ||
137 | pub fn mod_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mod]) } | ||
138 | pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) } | ||
139 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | ||
140 | } | ||
141 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
142 | pub struct StaticDef { | ||
143 | pub(crate) syntax: SyntaxNode, | ||
144 | } | ||
145 | impl ast::AttrsOwner for StaticDef {} | ||
146 | impl ast::NameOwner for StaticDef {} | ||
147 | impl ast::VisibilityOwner for StaticDef {} | ||
148 | impl ast::TypeAscriptionOwner for StaticDef {} | ||
149 | impl StaticDef { | ||
150 | pub fn static_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![static]) } | ||
151 | pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } | ||
152 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } | ||
153 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } | ||
154 | pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
155 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | ||
156 | } | ||
157 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
158 | pub struct StructDef { | ||
159 | pub(crate) syntax: SyntaxNode, | ||
160 | } | ||
161 | impl ast::AttrsOwner for StructDef {} | ||
162 | impl ast::NameOwner for StructDef {} | ||
163 | impl ast::VisibilityOwner for StructDef {} | ||
164 | impl ast::TypeParamsOwner for StructDef {} | ||
165 | impl StructDef { | ||
166 | pub fn struct_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![struct]) } | ||
167 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | ||
168 | pub fn field_def_list(&self) -> Option<FieldDefList> { support::child(&self.syntax) } | ||
169 | } | ||
170 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
171 | pub struct TraitDef { | ||
172 | pub(crate) syntax: SyntaxNode, | ||
173 | } | ||
174 | impl ast::AttrsOwner for TraitDef {} | ||
175 | impl ast::NameOwner for TraitDef {} | ||
176 | impl ast::VisibilityOwner for TraitDef {} | ||
177 | impl ast::TypeParamsOwner for TraitDef {} | ||
178 | impl ast::TypeBoundsOwner for TraitDef {} | ||
179 | impl TraitDef { | ||
180 | pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) } | ||
181 | pub fn auto_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![auto]) } | ||
182 | pub fn trait_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![trait]) } | ||
183 | pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) } | ||
184 | } | ||
185 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
186 | pub struct TypeAliasDef { | ||
187 | pub(crate) syntax: SyntaxNode, | ||
188 | } | ||
189 | impl ast::AttrsOwner for TypeAliasDef {} | ||
190 | impl ast::NameOwner for TypeAliasDef {} | ||
191 | impl ast::VisibilityOwner for TypeAliasDef {} | ||
192 | impl ast::TypeParamsOwner for TypeAliasDef {} | ||
193 | impl ast::TypeBoundsOwner for TypeAliasDef {} | ||
194 | impl TypeAliasDef { | ||
195 | pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) } | ||
196 | pub fn type_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![type]) } | ||
197 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } | ||
198 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | ||
199 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | ||
200 | } | ||
201 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
202 | pub struct UnionDef { | ||
203 | pub(crate) syntax: SyntaxNode, | ||
204 | } | ||
205 | impl ast::AttrsOwner for UnionDef {} | ||
206 | impl ast::NameOwner for UnionDef {} | ||
207 | impl ast::VisibilityOwner for UnionDef {} | ||
208 | impl ast::TypeParamsOwner for UnionDef {} | ||
209 | impl UnionDef { | ||
210 | pub fn union_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![union]) } | ||
211 | pub fn record_field_def_list(&self) -> Option<RecordFieldDefList> { | ||
212 | support::child(&self.syntax) | ||
213 | } | ||
214 | } | ||
215 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
216 | pub struct UseItem { | ||
217 | pub(crate) syntax: SyntaxNode, | ||
218 | } | ||
219 | impl ast::AttrsOwner for UseItem {} | ||
220 | impl ast::VisibilityOwner for UseItem {} | ||
221 | impl UseItem { | ||
222 | pub fn use_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![use]) } | ||
223 | pub fn use_tree(&self) -> Option<UseTree> { support::child(&self.syntax) } | ||
224 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | ||
225 | } | ||
226 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
49 | pub struct Visibility { | 227 | pub struct Visibility { |
50 | pub(crate) syntax: SyntaxNode, | 228 | pub(crate) syntax: SyntaxNode, |
51 | } | 229 | } |
@@ -122,19 +300,6 @@ impl BlockExpr { | |||
122 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } | 300 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } |
123 | } | 301 | } |
124 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 302 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
125 | pub struct StructDef { | ||
126 | pub(crate) syntax: SyntaxNode, | ||
127 | } | ||
128 | impl ast::AttrsOwner for StructDef {} | ||
129 | impl ast::NameOwner for StructDef {} | ||
130 | impl ast::VisibilityOwner for StructDef {} | ||
131 | impl ast::TypeParamsOwner for StructDef {} | ||
132 | impl StructDef { | ||
133 | pub fn struct_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![struct]) } | ||
134 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | ||
135 | pub fn field_def_list(&self) -> Option<FieldDefList> { support::child(&self.syntax) } | ||
136 | } | ||
137 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
138 | pub struct RecordFieldDefList { | 303 | pub struct RecordFieldDefList { |
139 | pub(crate) syntax: SyntaxNode, | 304 | pub(crate) syntax: SyntaxNode, |
140 | } | 305 | } |
@@ -153,20 +318,6 @@ impl TupleFieldDefList { | |||
153 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } | 318 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } |
154 | } | 319 | } |
155 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 320 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
156 | pub struct UnionDef { | ||
157 | pub(crate) syntax: SyntaxNode, | ||
158 | } | ||
159 | impl ast::AttrsOwner for UnionDef {} | ||
160 | impl ast::NameOwner for UnionDef {} | ||
161 | impl ast::VisibilityOwner for UnionDef {} | ||
162 | impl ast::TypeParamsOwner for UnionDef {} | ||
163 | impl UnionDef { | ||
164 | pub fn union_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![union]) } | ||
165 | pub fn record_field_def_list(&self) -> Option<RecordFieldDefList> { | ||
166 | support::child(&self.syntax) | ||
167 | } | ||
168 | } | ||
169 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
170 | pub struct RecordFieldDef { | 321 | pub struct RecordFieldDef { |
171 | pub(crate) syntax: SyntaxNode, | 322 | pub(crate) syntax: SyntaxNode, |
172 | } | 323 | } |
@@ -188,18 +339,6 @@ impl TupleFieldDef { | |||
188 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 339 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } |
189 | } | 340 | } |
190 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 341 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
191 | pub struct EnumDef { | ||
192 | pub(crate) syntax: SyntaxNode, | ||
193 | } | ||
194 | impl ast::AttrsOwner for EnumDef {} | ||
195 | impl ast::NameOwner for EnumDef {} | ||
196 | impl ast::VisibilityOwner for EnumDef {} | ||
197 | impl ast::TypeParamsOwner for EnumDef {} | ||
198 | impl EnumDef { | ||
199 | pub fn enum_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![enum]) } | ||
200 | pub fn variant_list(&self) -> Option<EnumVariantList> { support::child(&self.syntax) } | ||
201 | } | ||
202 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
203 | pub struct EnumVariantList { | 342 | pub struct EnumVariantList { |
204 | pub(crate) syntax: SyntaxNode, | 343 | pub(crate) syntax: SyntaxNode, |
205 | } | 344 | } |
@@ -221,21 +360,6 @@ impl EnumVariant { | |||
221 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 360 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
222 | } | 361 | } |
223 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 362 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
224 | pub struct TraitDef { | ||
225 | pub(crate) syntax: SyntaxNode, | ||
226 | } | ||
227 | impl ast::AttrsOwner for TraitDef {} | ||
228 | impl ast::NameOwner for TraitDef {} | ||
229 | impl ast::VisibilityOwner for TraitDef {} | ||
230 | impl ast::TypeParamsOwner for TraitDef {} | ||
231 | impl ast::TypeBoundsOwner for TraitDef {} | ||
232 | impl TraitDef { | ||
233 | pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) } | ||
234 | pub fn auto_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![auto]) } | ||
235 | pub fn trait_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![trait]) } | ||
236 | pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) } | ||
237 | } | ||
238 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
239 | pub struct TypeBoundList { | 363 | pub struct TypeBoundList { |
240 | pub(crate) syntax: SyntaxNode, | 364 | pub(crate) syntax: SyntaxNode, |
241 | } | 365 | } |
@@ -253,82 +377,6 @@ impl ItemList { | |||
253 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } | 377 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } |
254 | } | 378 | } |
255 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 379 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
256 | pub struct Module { | ||
257 | pub(crate) syntax: SyntaxNode, | ||
258 | } | ||
259 | impl ast::AttrsOwner for Module {} | ||
260 | impl ast::NameOwner for Module {} | ||
261 | impl ast::VisibilityOwner for Module {} | ||
262 | impl Module { | ||
263 | pub fn mod_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mod]) } | ||
264 | pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) } | ||
265 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | ||
266 | } | ||
267 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
268 | pub struct ConstDef { | ||
269 | pub(crate) syntax: SyntaxNode, | ||
270 | } | ||
271 | impl ast::AttrsOwner for ConstDef {} | ||
272 | impl ast::NameOwner for ConstDef {} | ||
273 | impl ast::VisibilityOwner for ConstDef {} | ||
274 | impl ast::TypeAscriptionOwner for ConstDef {} | ||
275 | impl ConstDef { | ||
276 | pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) } | ||
277 | pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } | ||
278 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } | ||
279 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } | ||
280 | pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
281 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | ||
282 | } | ||
283 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
284 | pub struct StaticDef { | ||
285 | pub(crate) syntax: SyntaxNode, | ||
286 | } | ||
287 | impl ast::AttrsOwner for StaticDef {} | ||
288 | impl ast::NameOwner for StaticDef {} | ||
289 | impl ast::VisibilityOwner for StaticDef {} | ||
290 | impl ast::TypeAscriptionOwner for StaticDef {} | ||
291 | impl StaticDef { | ||
292 | pub fn static_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![static]) } | ||
293 | pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } | ||
294 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } | ||
295 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } | ||
296 | pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
297 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | ||
298 | } | ||
299 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
300 | pub struct TypeAliasDef { | ||
301 | pub(crate) syntax: SyntaxNode, | ||
302 | } | ||
303 | impl ast::AttrsOwner for TypeAliasDef {} | ||
304 | impl ast::NameOwner for TypeAliasDef {} | ||
305 | impl ast::VisibilityOwner for TypeAliasDef {} | ||
306 | impl ast::TypeParamsOwner for TypeAliasDef {} | ||
307 | impl ast::TypeBoundsOwner for TypeAliasDef {} | ||
308 | impl TypeAliasDef { | ||
309 | pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) } | ||
310 | pub fn type_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![type]) } | ||
311 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } | ||
312 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | ||
313 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | ||
314 | } | ||
315 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
316 | pub struct ImplDef { | ||
317 | pub(crate) syntax: SyntaxNode, | ||
318 | } | ||
319 | impl ast::AttrsOwner for ImplDef {} | ||
320 | impl ast::VisibilityOwner for ImplDef {} | ||
321 | impl ast::TypeParamsOwner for ImplDef {} | ||
322 | impl ImplDef { | ||
323 | pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } | ||
324 | pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) } | ||
325 | pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) } | ||
326 | pub fn impl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![impl]) } | ||
327 | pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) } | ||
328 | pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) } | ||
329 | pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) } | ||
330 | } | ||
331 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
332 | pub struct ParenType { | 380 | pub struct ParenType { |
333 | pub(crate) syntax: SyntaxNode, | 381 | pub(crate) syntax: SyntaxNode, |
334 | } | 382 | } |
@@ -920,18 +968,6 @@ impl MacroPat { | |||
920 | pub fn macro_call(&self) -> Option<MacroCall> { support::child(&self.syntax) } | 968 | pub fn macro_call(&self) -> Option<MacroCall> { support::child(&self.syntax) } |
921 | } | 969 | } |
922 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 970 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
923 | pub struct MacroCall { | ||
924 | pub(crate) syntax: SyntaxNode, | ||
925 | } | ||
926 | impl ast::AttrsOwner for MacroCall {} | ||
927 | impl ast::NameOwner for MacroCall {} | ||
928 | impl MacroCall { | ||
929 | pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } | ||
930 | pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) } | ||
931 | pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) } | ||
932 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | ||
933 | } | ||
934 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
935 | pub struct RecordPat { | 971 | pub struct RecordPat { |
936 | pub(crate) syntax: SyntaxNode, | 972 | pub(crate) syntax: SyntaxNode, |
937 | } | 973 | } |
@@ -1125,17 +1161,6 @@ impl Param { | |||
1125 | pub fn dotdotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![...]) } | 1161 | pub fn dotdotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![...]) } |
1126 | } | 1162 | } |
1127 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1163 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1128 | pub struct UseItem { | ||
1129 | pub(crate) syntax: SyntaxNode, | ||
1130 | } | ||
1131 | impl ast::AttrsOwner for UseItem {} | ||
1132 | impl ast::VisibilityOwner for UseItem {} | ||
1133 | impl UseItem { | ||
1134 | pub fn use_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![use]) } | ||
1135 | pub fn use_tree(&self) -> Option<UseTree> { support::child(&self.syntax) } | ||
1136 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | ||
1137 | } | ||
1138 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1139 | pub struct UseTree { | 1164 | pub struct UseTree { |
1140 | pub(crate) syntax: SyntaxNode, | 1165 | pub(crate) syntax: SyntaxNode, |
1141 | } | 1166 | } |
@@ -1164,20 +1189,6 @@ impl Alias { | |||
1164 | pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) } | 1189 | pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) } |
1165 | } | 1190 | } |
1166 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1191 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1167 | pub struct ExternCrateItem { | ||
1168 | pub(crate) syntax: SyntaxNode, | ||
1169 | } | ||
1170 | impl ast::AttrsOwner for ExternCrateItem {} | ||
1171 | impl ast::VisibilityOwner for ExternCrateItem {} | ||
1172 | impl ExternCrateItem { | ||
1173 | pub fn extern_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![extern]) } | ||
1174 | pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) } | ||
1175 | pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } | ||
1176 | pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) } | ||
1177 | pub fn alias(&self) -> Option<Alias> { support::child(&self.syntax) } | ||
1178 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | ||
1179 | } | ||
1180 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1181 | pub struct PathSegment { | 1192 | pub struct PathSegment { |
1182 | pub(crate) syntax: SyntaxNode, | 1193 | pub(crate) syntax: SyntaxNode, |
1183 | } | 1194 | } |
@@ -1229,15 +1240,6 @@ impl ConstArg { | |||
1229 | pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) } | 1240 | pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) } |
1230 | } | 1241 | } |
1231 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1242 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1232 | pub struct ExternBlock { | ||
1233 | pub(crate) syntax: SyntaxNode, | ||
1234 | } | ||
1235 | impl ast::AttrsOwner for ExternBlock {} | ||
1236 | impl ExternBlock { | ||
1237 | pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) } | ||
1238 | pub fn extern_item_list(&self) -> Option<ExternItemList> { support::child(&self.syntax) } | ||
1239 | } | ||
1240 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1241 | pub struct ExternItemList { | 1243 | pub struct ExternItemList { |
1242 | pub(crate) syntax: SyntaxNode, | 1244 | pub(crate) syntax: SyntaxNode, |
1243 | } | 1245 | } |
@@ -1257,23 +1259,23 @@ impl MetaItem { | |||
1257 | pub fn nested_meta_items(&self) -> AstChildren<MetaItem> { support::children(&self.syntax) } | 1259 | pub fn nested_meta_items(&self) -> AstChildren<MetaItem> { support::children(&self.syntax) } |
1258 | } | 1260 | } |
1259 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1261 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1260 | pub enum ModuleItem { | 1262 | pub enum Item { |
1261 | StructDef(StructDef), | 1263 | ConstDef(ConstDef), |
1262 | UnionDef(UnionDef), | ||
1263 | EnumDef(EnumDef), | 1264 | EnumDef(EnumDef), |
1265 | ExternBlock(ExternBlock), | ||
1266 | ExternCrateItem(ExternCrateItem), | ||
1264 | FnDef(FnDef), | 1267 | FnDef(FnDef), |
1268 | ImplDef(ImplDef), | ||
1269 | MacroCall(MacroCall), | ||
1270 | Module(Module), | ||
1271 | StaticDef(StaticDef), | ||
1272 | StructDef(StructDef), | ||
1265 | TraitDef(TraitDef), | 1273 | TraitDef(TraitDef), |
1266 | TypeAliasDef(TypeAliasDef), | 1274 | TypeAliasDef(TypeAliasDef), |
1267 | ImplDef(ImplDef), | 1275 | UnionDef(UnionDef), |
1268 | UseItem(UseItem), | 1276 | UseItem(UseItem), |
1269 | ExternCrateItem(ExternCrateItem), | ||
1270 | ConstDef(ConstDef), | ||
1271 | StaticDef(StaticDef), | ||
1272 | Module(Module), | ||
1273 | MacroCall(MacroCall), | ||
1274 | ExternBlock(ExternBlock), | ||
1275 | } | 1277 | } |
1276 | impl ast::AttrsOwner for ModuleItem {} | 1278 | impl ast::AttrsOwner for Item {} |
1277 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1279 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1278 | pub enum TypeRef { | 1280 | pub enum TypeRef { |
1279 | ParenType(ParenType), | 1281 | ParenType(ParenType), |
@@ -1407,8 +1409,8 @@ impl AstNode for Attr { | |||
1407 | } | 1409 | } |
1408 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1410 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1409 | } | 1411 | } |
1410 | impl AstNode for FnDef { | 1412 | impl AstNode for ConstDef { |
1411 | fn can_cast(kind: SyntaxKind) -> bool { kind == FN_DEF } | 1413 | fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_DEF } |
1412 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1414 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1413 | if Self::can_cast(syntax.kind()) { | 1415 | if Self::can_cast(syntax.kind()) { |
1414 | Some(Self { syntax }) | 1416 | Some(Self { syntax }) |
@@ -1418,8 +1420,8 @@ impl AstNode for FnDef { | |||
1418 | } | 1420 | } |
1419 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1421 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1420 | } | 1422 | } |
1421 | impl AstNode for Visibility { | 1423 | impl AstNode for EnumDef { |
1422 | fn can_cast(kind: SyntaxKind) -> bool { kind == VISIBILITY } | 1424 | fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_DEF } |
1423 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1425 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1424 | if Self::can_cast(syntax.kind()) { | 1426 | if Self::can_cast(syntax.kind()) { |
1425 | Some(Self { syntax }) | 1427 | Some(Self { syntax }) |
@@ -1429,8 +1431,8 @@ impl AstNode for Visibility { | |||
1429 | } | 1431 | } |
1430 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1432 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1431 | } | 1433 | } |
1432 | impl AstNode for Abi { | 1434 | impl AstNode for ExternBlock { |
1433 | fn can_cast(kind: SyntaxKind) -> bool { kind == ABI } | 1435 | fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_BLOCK } |
1434 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1436 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1435 | if Self::can_cast(syntax.kind()) { | 1437 | if Self::can_cast(syntax.kind()) { |
1436 | Some(Self { syntax }) | 1438 | Some(Self { syntax }) |
@@ -1440,8 +1442,8 @@ impl AstNode for Abi { | |||
1440 | } | 1442 | } |
1441 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1443 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1442 | } | 1444 | } |
1443 | impl AstNode for Name { | 1445 | impl AstNode for ExternCrateItem { |
1444 | fn can_cast(kind: SyntaxKind) -> bool { kind == NAME } | 1446 | fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_CRATE_ITEM } |
1445 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1447 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1446 | if Self::can_cast(syntax.kind()) { | 1448 | if Self::can_cast(syntax.kind()) { |
1447 | Some(Self { syntax }) | 1449 | Some(Self { syntax }) |
@@ -1451,8 +1453,8 @@ impl AstNode for Name { | |||
1451 | } | 1453 | } |
1452 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1454 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1453 | } | 1455 | } |
1454 | impl AstNode for TypeParamList { | 1456 | impl AstNode for FnDef { |
1455 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_PARAM_LIST } | 1457 | fn can_cast(kind: SyntaxKind) -> bool { kind == FN_DEF } |
1456 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1458 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1457 | if Self::can_cast(syntax.kind()) { | 1459 | if Self::can_cast(syntax.kind()) { |
1458 | Some(Self { syntax }) | 1460 | Some(Self { syntax }) |
@@ -1462,8 +1464,8 @@ impl AstNode for TypeParamList { | |||
1462 | } | 1464 | } |
1463 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1465 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1464 | } | 1466 | } |
1465 | impl AstNode for ParamList { | 1467 | impl AstNode for ImplDef { |
1466 | fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM_LIST } | 1468 | fn can_cast(kind: SyntaxKind) -> bool { kind == IMPL_DEF } |
1467 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1469 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1468 | if Self::can_cast(syntax.kind()) { | 1470 | if Self::can_cast(syntax.kind()) { |
1469 | Some(Self { syntax }) | 1471 | Some(Self { syntax }) |
@@ -1473,8 +1475,8 @@ impl AstNode for ParamList { | |||
1473 | } | 1475 | } |
1474 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1476 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1475 | } | 1477 | } |
1476 | impl AstNode for RetType { | 1478 | impl AstNode for MacroCall { |
1477 | fn can_cast(kind: SyntaxKind) -> bool { kind == RET_TYPE } | 1479 | fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_CALL } |
1478 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1480 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1479 | if Self::can_cast(syntax.kind()) { | 1481 | if Self::can_cast(syntax.kind()) { |
1480 | Some(Self { syntax }) | 1482 | Some(Self { syntax }) |
@@ -1484,8 +1486,8 @@ impl AstNode for RetType { | |||
1484 | } | 1486 | } |
1485 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1487 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1486 | } | 1488 | } |
1487 | impl AstNode for WhereClause { | 1489 | impl AstNode for Module { |
1488 | fn can_cast(kind: SyntaxKind) -> bool { kind == WHERE_CLAUSE } | 1490 | fn can_cast(kind: SyntaxKind) -> bool { kind == MODULE } |
1489 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1491 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1490 | if Self::can_cast(syntax.kind()) { | 1492 | if Self::can_cast(syntax.kind()) { |
1491 | Some(Self { syntax }) | 1493 | Some(Self { syntax }) |
@@ -1495,8 +1497,8 @@ impl AstNode for WhereClause { | |||
1495 | } | 1497 | } |
1496 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1498 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1497 | } | 1499 | } |
1498 | impl AstNode for BlockExpr { | 1500 | impl AstNode for StaticDef { |
1499 | fn can_cast(kind: SyntaxKind) -> bool { kind == BLOCK_EXPR } | 1501 | fn can_cast(kind: SyntaxKind) -> bool { kind == STATIC_DEF } |
1500 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1502 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1501 | if Self::can_cast(syntax.kind()) { | 1503 | if Self::can_cast(syntax.kind()) { |
1502 | Some(Self { syntax }) | 1504 | Some(Self { syntax }) |
@@ -1517,8 +1519,8 @@ impl AstNode for StructDef { | |||
1517 | } | 1519 | } |
1518 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1520 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1519 | } | 1521 | } |
1520 | impl AstNode for RecordFieldDefList { | 1522 | impl AstNode for TraitDef { |
1521 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_DEF_LIST } | 1523 | fn can_cast(kind: SyntaxKind) -> bool { kind == TRAIT_DEF } |
1522 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1524 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1523 | if Self::can_cast(syntax.kind()) { | 1525 | if Self::can_cast(syntax.kind()) { |
1524 | Some(Self { syntax }) | 1526 | Some(Self { syntax }) |
@@ -1528,8 +1530,8 @@ impl AstNode for RecordFieldDefList { | |||
1528 | } | 1530 | } |
1529 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1531 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1530 | } | 1532 | } |
1531 | impl AstNode for TupleFieldDefList { | 1533 | impl AstNode for TypeAliasDef { |
1532 | fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_FIELD_DEF_LIST } | 1534 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ALIAS_DEF } |
1533 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1535 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1534 | if Self::can_cast(syntax.kind()) { | 1536 | if Self::can_cast(syntax.kind()) { |
1535 | Some(Self { syntax }) | 1537 | Some(Self { syntax }) |
@@ -1550,8 +1552,8 @@ impl AstNode for UnionDef { | |||
1550 | } | 1552 | } |
1551 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1553 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1552 | } | 1554 | } |
1553 | impl AstNode for RecordFieldDef { | 1555 | impl AstNode for UseItem { |
1554 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_DEF } | 1556 | fn can_cast(kind: SyntaxKind) -> bool { kind == USE_ITEM } |
1555 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1557 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1556 | if Self::can_cast(syntax.kind()) { | 1558 | if Self::can_cast(syntax.kind()) { |
1557 | Some(Self { syntax }) | 1559 | Some(Self { syntax }) |
@@ -1561,8 +1563,8 @@ impl AstNode for RecordFieldDef { | |||
1561 | } | 1563 | } |
1562 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1564 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1563 | } | 1565 | } |
1564 | impl AstNode for TupleFieldDef { | 1566 | impl AstNode for Visibility { |
1565 | fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_FIELD_DEF } | 1567 | fn can_cast(kind: SyntaxKind) -> bool { kind == VISIBILITY } |
1566 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1568 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1567 | if Self::can_cast(syntax.kind()) { | 1569 | if Self::can_cast(syntax.kind()) { |
1568 | Some(Self { syntax }) | 1570 | Some(Self { syntax }) |
@@ -1572,8 +1574,8 @@ impl AstNode for TupleFieldDef { | |||
1572 | } | 1574 | } |
1573 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1575 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1574 | } | 1576 | } |
1575 | impl AstNode for EnumDef { | 1577 | impl AstNode for Abi { |
1576 | fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_DEF } | 1578 | fn can_cast(kind: SyntaxKind) -> bool { kind == ABI } |
1577 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1579 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1578 | if Self::can_cast(syntax.kind()) { | 1580 | if Self::can_cast(syntax.kind()) { |
1579 | Some(Self { syntax }) | 1581 | Some(Self { syntax }) |
@@ -1583,8 +1585,8 @@ impl AstNode for EnumDef { | |||
1583 | } | 1585 | } |
1584 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1586 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1585 | } | 1587 | } |
1586 | impl AstNode for EnumVariantList { | 1588 | impl AstNode for Name { |
1587 | fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_VARIANT_LIST } | 1589 | fn can_cast(kind: SyntaxKind) -> bool { kind == NAME } |
1588 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1590 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1589 | if Self::can_cast(syntax.kind()) { | 1591 | if Self::can_cast(syntax.kind()) { |
1590 | Some(Self { syntax }) | 1592 | Some(Self { syntax }) |
@@ -1594,8 +1596,8 @@ impl AstNode for EnumVariantList { | |||
1594 | } | 1596 | } |
1595 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1597 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1596 | } | 1598 | } |
1597 | impl AstNode for EnumVariant { | 1599 | impl AstNode for TypeParamList { |
1598 | fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_VARIANT } | 1600 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_PARAM_LIST } |
1599 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1601 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1600 | if Self::can_cast(syntax.kind()) { | 1602 | if Self::can_cast(syntax.kind()) { |
1601 | Some(Self { syntax }) | 1603 | Some(Self { syntax }) |
@@ -1605,8 +1607,8 @@ impl AstNode for EnumVariant { | |||
1605 | } | 1607 | } |
1606 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1608 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1607 | } | 1609 | } |
1608 | impl AstNode for TraitDef { | 1610 | impl AstNode for ParamList { |
1609 | fn can_cast(kind: SyntaxKind) -> bool { kind == TRAIT_DEF } | 1611 | fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM_LIST } |
1610 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1612 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1611 | if Self::can_cast(syntax.kind()) { | 1613 | if Self::can_cast(syntax.kind()) { |
1612 | Some(Self { syntax }) | 1614 | Some(Self { syntax }) |
@@ -1616,8 +1618,8 @@ impl AstNode for TraitDef { | |||
1616 | } | 1618 | } |
1617 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1619 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1618 | } | 1620 | } |
1619 | impl AstNode for TypeBoundList { | 1621 | impl AstNode for RetType { |
1620 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND_LIST } | 1622 | fn can_cast(kind: SyntaxKind) -> bool { kind == RET_TYPE } |
1621 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1623 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1622 | if Self::can_cast(syntax.kind()) { | 1624 | if Self::can_cast(syntax.kind()) { |
1623 | Some(Self { syntax }) | 1625 | Some(Self { syntax }) |
@@ -1627,8 +1629,8 @@ impl AstNode for TypeBoundList { | |||
1627 | } | 1629 | } |
1628 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1630 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1629 | } | 1631 | } |
1630 | impl AstNode for ItemList { | 1632 | impl AstNode for WhereClause { |
1631 | fn can_cast(kind: SyntaxKind) -> bool { kind == ITEM_LIST } | 1633 | fn can_cast(kind: SyntaxKind) -> bool { kind == WHERE_CLAUSE } |
1632 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1634 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1633 | if Self::can_cast(syntax.kind()) { | 1635 | if Self::can_cast(syntax.kind()) { |
1634 | Some(Self { syntax }) | 1636 | Some(Self { syntax }) |
@@ -1638,8 +1640,8 @@ impl AstNode for ItemList { | |||
1638 | } | 1640 | } |
1639 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1641 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1640 | } | 1642 | } |
1641 | impl AstNode for Module { | 1643 | impl AstNode for BlockExpr { |
1642 | fn can_cast(kind: SyntaxKind) -> bool { kind == MODULE } | 1644 | fn can_cast(kind: SyntaxKind) -> bool { kind == BLOCK_EXPR } |
1643 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1645 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1644 | if Self::can_cast(syntax.kind()) { | 1646 | if Self::can_cast(syntax.kind()) { |
1645 | Some(Self { syntax }) | 1647 | Some(Self { syntax }) |
@@ -1649,8 +1651,8 @@ impl AstNode for Module { | |||
1649 | } | 1651 | } |
1650 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1652 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1651 | } | 1653 | } |
1652 | impl AstNode for ConstDef { | 1654 | impl AstNode for RecordFieldDefList { |
1653 | fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_DEF } | 1655 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_DEF_LIST } |
1654 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1656 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1655 | if Self::can_cast(syntax.kind()) { | 1657 | if Self::can_cast(syntax.kind()) { |
1656 | Some(Self { syntax }) | 1658 | Some(Self { syntax }) |
@@ -1660,8 +1662,8 @@ impl AstNode for ConstDef { | |||
1660 | } | 1662 | } |
1661 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1663 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1662 | } | 1664 | } |
1663 | impl AstNode for StaticDef { | 1665 | impl AstNode for TupleFieldDefList { |
1664 | fn can_cast(kind: SyntaxKind) -> bool { kind == STATIC_DEF } | 1666 | fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_FIELD_DEF_LIST } |
1665 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1667 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1666 | if Self::can_cast(syntax.kind()) { | 1668 | if Self::can_cast(syntax.kind()) { |
1667 | Some(Self { syntax }) | 1669 | Some(Self { syntax }) |
@@ -1671,8 +1673,8 @@ impl AstNode for StaticDef { | |||
1671 | } | 1673 | } |
1672 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1674 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1673 | } | 1675 | } |
1674 | impl AstNode for TypeAliasDef { | 1676 | impl AstNode for RecordFieldDef { |
1675 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ALIAS_DEF } | 1677 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_DEF } |
1676 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1678 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1677 | if Self::can_cast(syntax.kind()) { | 1679 | if Self::can_cast(syntax.kind()) { |
1678 | Some(Self { syntax }) | 1680 | Some(Self { syntax }) |
@@ -1682,8 +1684,52 @@ impl AstNode for TypeAliasDef { | |||
1682 | } | 1684 | } |
1683 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1685 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1684 | } | 1686 | } |
1685 | impl AstNode for ImplDef { | 1687 | impl AstNode for TupleFieldDef { |
1686 | fn can_cast(kind: SyntaxKind) -> bool { kind == IMPL_DEF } | 1688 | fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_FIELD_DEF } |
1689 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1690 | if Self::can_cast(syntax.kind()) { | ||
1691 | Some(Self { syntax }) | ||
1692 | } else { | ||
1693 | None | ||
1694 | } | ||
1695 | } | ||
1696 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1697 | } | ||
1698 | impl AstNode for EnumVariantList { | ||
1699 | fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_VARIANT_LIST } | ||
1700 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1701 | if Self::can_cast(syntax.kind()) { | ||
1702 | Some(Self { syntax }) | ||
1703 | } else { | ||
1704 | None | ||
1705 | } | ||
1706 | } | ||
1707 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1708 | } | ||
1709 | impl AstNode for EnumVariant { | ||
1710 | fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_VARIANT } | ||
1711 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1712 | if Self::can_cast(syntax.kind()) { | ||
1713 | Some(Self { syntax }) | ||
1714 | } else { | ||
1715 | None | ||
1716 | } | ||
1717 | } | ||
1718 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1719 | } | ||
1720 | impl AstNode for TypeBoundList { | ||
1721 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND_LIST } | ||
1722 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1723 | if Self::can_cast(syntax.kind()) { | ||
1724 | Some(Self { syntax }) | ||
1725 | } else { | ||
1726 | None | ||
1727 | } | ||
1728 | } | ||
1729 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1730 | } | ||
1731 | impl AstNode for ItemList { | ||
1732 | fn can_cast(kind: SyntaxKind) -> bool { kind == ITEM_LIST } | ||
1687 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1733 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1688 | if Self::can_cast(syntax.kind()) { | 1734 | if Self::can_cast(syntax.kind()) { |
1689 | Some(Self { syntax }) | 1735 | Some(Self { syntax }) |
@@ -2397,17 +2443,6 @@ impl AstNode for MacroPat { | |||
2397 | } | 2443 | } |
2398 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2444 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
2399 | } | 2445 | } |
2400 | impl AstNode for MacroCall { | ||
2401 | fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_CALL } | ||
2402 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2403 | if Self::can_cast(syntax.kind()) { | ||
2404 | Some(Self { syntax }) | ||
2405 | } else { | ||
2406 | None | ||
2407 | } | ||
2408 | } | ||
2409 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2410 | } | ||
2411 | impl AstNode for RecordPat { | 2446 | impl AstNode for RecordPat { |
2412 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_PAT } | 2447 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_PAT } |
2413 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2448 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -2606,17 +2641,6 @@ impl AstNode for Param { | |||
2606 | } | 2641 | } |
2607 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2642 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
2608 | } | 2643 | } |
2609 | impl AstNode for UseItem { | ||
2610 | fn can_cast(kind: SyntaxKind) -> bool { kind == USE_ITEM } | ||
2611 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2612 | if Self::can_cast(syntax.kind()) { | ||
2613 | Some(Self { syntax }) | ||
2614 | } else { | ||
2615 | None | ||
2616 | } | ||
2617 | } | ||
2618 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2619 | } | ||
2620 | impl AstNode for UseTree { | 2644 | impl AstNode for UseTree { |
2621 | fn can_cast(kind: SyntaxKind) -> bool { kind == USE_TREE } | 2645 | fn can_cast(kind: SyntaxKind) -> bool { kind == USE_TREE } |
2622 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2646 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -2650,17 +2674,6 @@ impl AstNode for Alias { | |||
2650 | } | 2674 | } |
2651 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2675 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
2652 | } | 2676 | } |
2653 | impl AstNode for ExternCrateItem { | ||
2654 | fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_CRATE_ITEM } | ||
2655 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2656 | if Self::can_cast(syntax.kind()) { | ||
2657 | Some(Self { syntax }) | ||
2658 | } else { | ||
2659 | None | ||
2660 | } | ||
2661 | } | ||
2662 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2663 | } | ||
2664 | impl AstNode for PathSegment { | 2677 | impl AstNode for PathSegment { |
2665 | fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_SEGMENT } | 2678 | fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_SEGMENT } |
2666 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2679 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -2716,17 +2729,6 @@ impl AstNode for ConstArg { | |||
2716 | } | 2729 | } |
2717 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2730 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
2718 | } | 2731 | } |
2719 | impl AstNode for ExternBlock { | ||
2720 | fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_BLOCK } | ||
2721 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2722 | if Self::can_cast(syntax.kind()) { | ||
2723 | Some(Self { syntax }) | ||
2724 | } else { | ||
2725 | None | ||
2726 | } | ||
2727 | } | ||
2728 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2729 | } | ||
2730 | impl AstNode for ExternItemList { | 2732 | impl AstNode for ExternItemList { |
2731 | fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_ITEM_LIST } | 2733 | fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_ITEM_LIST } |
2732 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2734 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -2749,93 +2751,93 @@ impl AstNode for MetaItem { | |||
2749 | } | 2751 | } |
2750 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2752 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
2751 | } | 2753 | } |
2752 | impl From<StructDef> for ModuleItem { | 2754 | impl From<ConstDef> for Item { |
2753 | fn from(node: StructDef) -> ModuleItem { ModuleItem::StructDef(node) } | 2755 | fn from(node: ConstDef) -> Item { Item::ConstDef(node) } |
2754 | } | 2756 | } |
2755 | impl From<UnionDef> for ModuleItem { | 2757 | impl From<EnumDef> for Item { |
2756 | fn from(node: UnionDef) -> ModuleItem { ModuleItem::UnionDef(node) } | 2758 | fn from(node: EnumDef) -> Item { Item::EnumDef(node) } |
2757 | } | 2759 | } |
2758 | impl From<EnumDef> for ModuleItem { | 2760 | impl From<ExternBlock> for Item { |
2759 | fn from(node: EnumDef) -> ModuleItem { ModuleItem::EnumDef(node) } | 2761 | fn from(node: ExternBlock) -> Item { Item::ExternBlock(node) } |
2760 | } | 2762 | } |
2761 | impl From<FnDef> for ModuleItem { | 2763 | impl From<ExternCrateItem> for Item { |
2762 | fn from(node: FnDef) -> ModuleItem { ModuleItem::FnDef(node) } | 2764 | fn from(node: ExternCrateItem) -> Item { Item::ExternCrateItem(node) } |
2763 | } | 2765 | } |
2764 | impl From<TraitDef> for ModuleItem { | 2766 | impl From<FnDef> for Item { |
2765 | fn from(node: TraitDef) -> ModuleItem { ModuleItem::TraitDef(node) } | 2767 | fn from(node: FnDef) -> Item { Item::FnDef(node) } |
2766 | } | 2768 | } |
2767 | impl From<TypeAliasDef> for ModuleItem { | 2769 | impl From<ImplDef> for Item { |
2768 | fn from(node: TypeAliasDef) -> ModuleItem { ModuleItem::TypeAliasDef(node) } | 2770 | fn from(node: ImplDef) -> Item { Item::ImplDef(node) } |
2769 | } | 2771 | } |
2770 | impl From<ImplDef> for ModuleItem { | 2772 | impl From<MacroCall> for Item { |
2771 | fn from(node: ImplDef) -> ModuleItem { ModuleItem::ImplDef(node) } | 2773 | fn from(node: MacroCall) -> Item { Item::MacroCall(node) } |
2772 | } | 2774 | } |
2773 | impl From<UseItem> for ModuleItem { | 2775 | impl From<Module> for Item { |
2774 | fn from(node: UseItem) -> ModuleItem { ModuleItem::UseItem(node) } | 2776 | fn from(node: Module) -> Item { Item::Module(node) } |
2775 | } | 2777 | } |
2776 | impl From<ExternCrateItem> for ModuleItem { | 2778 | impl From<StaticDef> for Item { |
2777 | fn from(node: ExternCrateItem) -> ModuleItem { ModuleItem::ExternCrateItem(node) } | 2779 | fn from(node: StaticDef) -> Item { Item::StaticDef(node) } |
2778 | } | 2780 | } |
2779 | impl From<ConstDef> for ModuleItem { | 2781 | impl From<StructDef> for Item { |
2780 | fn from(node: ConstDef) -> ModuleItem { ModuleItem::ConstDef(node) } | 2782 | fn from(node: StructDef) -> Item { Item::StructDef(node) } |
2781 | } | 2783 | } |
2782 | impl From<StaticDef> for ModuleItem { | 2784 | impl From<TraitDef> for Item { |
2783 | fn from(node: StaticDef) -> ModuleItem { ModuleItem::StaticDef(node) } | 2785 | fn from(node: TraitDef) -> Item { Item::TraitDef(node) } |
2784 | } | 2786 | } |
2785 | impl From<Module> for ModuleItem { | 2787 | impl From<TypeAliasDef> for Item { |
2786 | fn from(node: Module) -> ModuleItem { ModuleItem::Module(node) } | 2788 | fn from(node: TypeAliasDef) -> Item { Item::TypeAliasDef(node) } |
2787 | } | 2789 | } |
2788 | impl From<MacroCall> for ModuleItem { | 2790 | impl From<UnionDef> for Item { |
2789 | fn from(node: MacroCall) -> ModuleItem { ModuleItem::MacroCall(node) } | 2791 | fn from(node: UnionDef) -> Item { Item::UnionDef(node) } |
2790 | } | 2792 | } |
2791 | impl From<ExternBlock> for ModuleItem { | 2793 | impl From<UseItem> for Item { |
2792 | fn from(node: ExternBlock) -> ModuleItem { ModuleItem::ExternBlock(node) } | 2794 | fn from(node: UseItem) -> Item { Item::UseItem(node) } |
2793 | } | 2795 | } |
2794 | impl AstNode for ModuleItem { | 2796 | impl AstNode for Item { |
2795 | fn can_cast(kind: SyntaxKind) -> bool { | 2797 | fn can_cast(kind: SyntaxKind) -> bool { |
2796 | match kind { | 2798 | match kind { |
2797 | STRUCT_DEF | UNION_DEF | ENUM_DEF | FN_DEF | TRAIT_DEF | TYPE_ALIAS_DEF | IMPL_DEF | 2799 | CONST_DEF | ENUM_DEF | EXTERN_BLOCK | EXTERN_CRATE_ITEM | FN_DEF | IMPL_DEF |
2798 | | USE_ITEM | EXTERN_CRATE_ITEM | CONST_DEF | STATIC_DEF | MODULE | MACRO_CALL | 2800 | | MACRO_CALL | MODULE | STATIC_DEF | STRUCT_DEF | TRAIT_DEF | TYPE_ALIAS_DEF |
2799 | | EXTERN_BLOCK => true, | 2801 | | UNION_DEF | USE_ITEM => true, |
2800 | _ => false, | 2802 | _ => false, |
2801 | } | 2803 | } |
2802 | } | 2804 | } |
2803 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2805 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
2804 | let res = match syntax.kind() { | 2806 | let res = match syntax.kind() { |
2805 | STRUCT_DEF => ModuleItem::StructDef(StructDef { syntax }), | 2807 | CONST_DEF => Item::ConstDef(ConstDef { syntax }), |
2806 | UNION_DEF => ModuleItem::UnionDef(UnionDef { syntax }), | 2808 | ENUM_DEF => Item::EnumDef(EnumDef { syntax }), |
2807 | ENUM_DEF => ModuleItem::EnumDef(EnumDef { syntax }), | 2809 | EXTERN_BLOCK => Item::ExternBlock(ExternBlock { syntax }), |
2808 | FN_DEF => ModuleItem::FnDef(FnDef { syntax }), | 2810 | EXTERN_CRATE_ITEM => Item::ExternCrateItem(ExternCrateItem { syntax }), |
2809 | TRAIT_DEF => ModuleItem::TraitDef(TraitDef { syntax }), | 2811 | FN_DEF => Item::FnDef(FnDef { syntax }), |
2810 | TYPE_ALIAS_DEF => ModuleItem::TypeAliasDef(TypeAliasDef { syntax }), | 2812 | IMPL_DEF => Item::ImplDef(ImplDef { syntax }), |
2811 | IMPL_DEF => ModuleItem::ImplDef(ImplDef { syntax }), | 2813 | MACRO_CALL => Item::MacroCall(MacroCall { syntax }), |
2812 | USE_ITEM => ModuleItem::UseItem(UseItem { syntax }), | 2814 | MODULE => Item::Module(Module { syntax }), |
2813 | EXTERN_CRATE_ITEM => ModuleItem::ExternCrateItem(ExternCrateItem { syntax }), | 2815 | STATIC_DEF => Item::StaticDef(StaticDef { syntax }), |
2814 | CONST_DEF => ModuleItem::ConstDef(ConstDef { syntax }), | 2816 | STRUCT_DEF => Item::StructDef(StructDef { syntax }), |
2815 | STATIC_DEF => ModuleItem::StaticDef(StaticDef { syntax }), | 2817 | TRAIT_DEF => Item::TraitDef(TraitDef { syntax }), |
2816 | MODULE => ModuleItem::Module(Module { syntax }), | 2818 | TYPE_ALIAS_DEF => Item::TypeAliasDef(TypeAliasDef { syntax }), |
2817 | MACRO_CALL => ModuleItem::MacroCall(MacroCall { syntax }), | 2819 | UNION_DEF => Item::UnionDef(UnionDef { syntax }), |
2818 | EXTERN_BLOCK => ModuleItem::ExternBlock(ExternBlock { syntax }), | 2820 | USE_ITEM => Item::UseItem(UseItem { syntax }), |
2819 | _ => return None, | 2821 | _ => return None, |
2820 | }; | 2822 | }; |
2821 | Some(res) | 2823 | Some(res) |
2822 | } | 2824 | } |
2823 | fn syntax(&self) -> &SyntaxNode { | 2825 | fn syntax(&self) -> &SyntaxNode { |
2824 | match self { | 2826 | match self { |
2825 | ModuleItem::StructDef(it) => &it.syntax, | 2827 | Item::ConstDef(it) => &it.syntax, |
2826 | ModuleItem::UnionDef(it) => &it.syntax, | 2828 | Item::EnumDef(it) => &it.syntax, |
2827 | ModuleItem::EnumDef(it) => &it.syntax, | 2829 | Item::ExternBlock(it) => &it.syntax, |
2828 | ModuleItem::FnDef(it) => &it.syntax, | 2830 | Item::ExternCrateItem(it) => &it.syntax, |
2829 | ModuleItem::TraitDef(it) => &it.syntax, | 2831 | Item::FnDef(it) => &it.syntax, |
2830 | ModuleItem::TypeAliasDef(it) => &it.syntax, | 2832 | Item::ImplDef(it) => &it.syntax, |
2831 | ModuleItem::ImplDef(it) => &it.syntax, | 2833 | Item::MacroCall(it) => &it.syntax, |
2832 | ModuleItem::UseItem(it) => &it.syntax, | 2834 | Item::Module(it) => &it.syntax, |
2833 | ModuleItem::ExternCrateItem(it) => &it.syntax, | 2835 | Item::StaticDef(it) => &it.syntax, |
2834 | ModuleItem::ConstDef(it) => &it.syntax, | 2836 | Item::StructDef(it) => &it.syntax, |
2835 | ModuleItem::StaticDef(it) => &it.syntax, | 2837 | Item::TraitDef(it) => &it.syntax, |
2836 | ModuleItem::Module(it) => &it.syntax, | 2838 | Item::TypeAliasDef(it) => &it.syntax, |
2837 | ModuleItem::MacroCall(it) => &it.syntax, | 2839 | Item::UnionDef(it) => &it.syntax, |
2838 | ModuleItem::ExternBlock(it) => &it.syntax, | 2840 | Item::UseItem(it) => &it.syntax, |
2839 | } | 2841 | } |
2840 | } | 2842 | } |
2841 | } | 2843 | } |
@@ -3378,7 +3380,7 @@ impl AstNode for AdtDef { | |||
3378 | } | 3380 | } |
3379 | } | 3381 | } |
3380 | } | 3382 | } |
3381 | impl std::fmt::Display for ModuleItem { | 3383 | impl std::fmt::Display for Item { |
3382 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3384 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3383 | std::fmt::Display::fmt(self.syntax(), f) | 3385 | std::fmt::Display::fmt(self.syntax(), f) |
3384 | } | 3386 | } |
@@ -3438,47 +3440,47 @@ impl std::fmt::Display for Attr { | |||
3438 | std::fmt::Display::fmt(self.syntax(), f) | 3440 | std::fmt::Display::fmt(self.syntax(), f) |
3439 | } | 3441 | } |
3440 | } | 3442 | } |
3441 | impl std::fmt::Display for FnDef { | 3443 | impl std::fmt::Display for ConstDef { |
3442 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3444 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3443 | std::fmt::Display::fmt(self.syntax(), f) | 3445 | std::fmt::Display::fmt(self.syntax(), f) |
3444 | } | 3446 | } |
3445 | } | 3447 | } |
3446 | impl std::fmt::Display for Visibility { | 3448 | impl std::fmt::Display for EnumDef { |
3447 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3449 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3448 | std::fmt::Display::fmt(self.syntax(), f) | 3450 | std::fmt::Display::fmt(self.syntax(), f) |
3449 | } | 3451 | } |
3450 | } | 3452 | } |
3451 | impl std::fmt::Display for Abi { | 3453 | impl std::fmt::Display for ExternBlock { |
3452 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3454 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3453 | std::fmt::Display::fmt(self.syntax(), f) | 3455 | std::fmt::Display::fmt(self.syntax(), f) |
3454 | } | 3456 | } |
3455 | } | 3457 | } |
3456 | impl std::fmt::Display for Name { | 3458 | impl std::fmt::Display for ExternCrateItem { |
3457 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3459 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3458 | std::fmt::Display::fmt(self.syntax(), f) | 3460 | std::fmt::Display::fmt(self.syntax(), f) |
3459 | } | 3461 | } |
3460 | } | 3462 | } |
3461 | impl std::fmt::Display for TypeParamList { | 3463 | impl std::fmt::Display for FnDef { |
3462 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3464 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3463 | std::fmt::Display::fmt(self.syntax(), f) | 3465 | std::fmt::Display::fmt(self.syntax(), f) |
3464 | } | 3466 | } |
3465 | } | 3467 | } |
3466 | impl std::fmt::Display for ParamList { | 3468 | impl std::fmt::Display for ImplDef { |
3467 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3469 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3468 | std::fmt::Display::fmt(self.syntax(), f) | 3470 | std::fmt::Display::fmt(self.syntax(), f) |
3469 | } | 3471 | } |
3470 | } | 3472 | } |
3471 | impl std::fmt::Display for RetType { | 3473 | impl std::fmt::Display for MacroCall { |
3472 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3474 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3473 | std::fmt::Display::fmt(self.syntax(), f) | 3475 | std::fmt::Display::fmt(self.syntax(), f) |
3474 | } | 3476 | } |
3475 | } | 3477 | } |
3476 | impl std::fmt::Display for WhereClause { | 3478 | impl std::fmt::Display for Module { |
3477 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3479 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3478 | std::fmt::Display::fmt(self.syntax(), f) | 3480 | std::fmt::Display::fmt(self.syntax(), f) |
3479 | } | 3481 | } |
3480 | } | 3482 | } |
3481 | impl std::fmt::Display for BlockExpr { | 3483 | impl std::fmt::Display for StaticDef { |
3482 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3484 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3483 | std::fmt::Display::fmt(self.syntax(), f) | 3485 | std::fmt::Display::fmt(self.syntax(), f) |
3484 | } | 3486 | } |
@@ -3488,12 +3490,12 @@ impl std::fmt::Display for StructDef { | |||
3488 | std::fmt::Display::fmt(self.syntax(), f) | 3490 | std::fmt::Display::fmt(self.syntax(), f) |
3489 | } | 3491 | } |
3490 | } | 3492 | } |
3491 | impl std::fmt::Display for RecordFieldDefList { | 3493 | impl std::fmt::Display for TraitDef { |
3492 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3494 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3493 | std::fmt::Display::fmt(self.syntax(), f) | 3495 | std::fmt::Display::fmt(self.syntax(), f) |
3494 | } | 3496 | } |
3495 | } | 3497 | } |
3496 | impl std::fmt::Display for TupleFieldDefList { | 3498 | impl std::fmt::Display for TypeAliasDef { |
3497 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3499 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3498 | std::fmt::Display::fmt(self.syntax(), f) | 3500 | std::fmt::Display::fmt(self.syntax(), f) |
3499 | } | 3501 | } |
@@ -3503,67 +3505,87 @@ impl std::fmt::Display for UnionDef { | |||
3503 | std::fmt::Display::fmt(self.syntax(), f) | 3505 | std::fmt::Display::fmt(self.syntax(), f) |
3504 | } | 3506 | } |
3505 | } | 3507 | } |
3506 | impl std::fmt::Display for RecordFieldDef { | 3508 | impl std::fmt::Display for UseItem { |
3507 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3509 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3508 | std::fmt::Display::fmt(self.syntax(), f) | 3510 | std::fmt::Display::fmt(self.syntax(), f) |
3509 | } | 3511 | } |
3510 | } | 3512 | } |
3511 | impl std::fmt::Display for TupleFieldDef { | 3513 | impl std::fmt::Display for Visibility { |
3512 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3514 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3513 | std::fmt::Display::fmt(self.syntax(), f) | 3515 | std::fmt::Display::fmt(self.syntax(), f) |
3514 | } | 3516 | } |
3515 | } | 3517 | } |
3516 | impl std::fmt::Display for EnumDef { | 3518 | impl std::fmt::Display for Abi { |
3517 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3519 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3518 | std::fmt::Display::fmt(self.syntax(), f) | 3520 | std::fmt::Display::fmt(self.syntax(), f) |
3519 | } | 3521 | } |
3520 | } | 3522 | } |
3521 | impl std::fmt::Display for EnumVariantList { | 3523 | impl std::fmt::Display for Name { |
3522 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3524 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3523 | std::fmt::Display::fmt(self.syntax(), f) | 3525 | std::fmt::Display::fmt(self.syntax(), f) |
3524 | } | 3526 | } |
3525 | } | 3527 | } |
3526 | impl std::fmt::Display for EnumVariant { | 3528 | impl std::fmt::Display for TypeParamList { |
3527 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3529 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3528 | std::fmt::Display::fmt(self.syntax(), f) | 3530 | std::fmt::Display::fmt(self.syntax(), f) |
3529 | } | 3531 | } |
3530 | } | 3532 | } |
3531 | impl std::fmt::Display for TraitDef { | 3533 | impl std::fmt::Display for ParamList { |
3532 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3534 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3533 | std::fmt::Display::fmt(self.syntax(), f) | 3535 | std::fmt::Display::fmt(self.syntax(), f) |
3534 | } | 3536 | } |
3535 | } | 3537 | } |
3536 | impl std::fmt::Display for TypeBoundList { | 3538 | impl std::fmt::Display for RetType { |
3537 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3539 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3538 | std::fmt::Display::fmt(self.syntax(), f) | 3540 | std::fmt::Display::fmt(self.syntax(), f) |
3539 | } | 3541 | } |
3540 | } | 3542 | } |
3541 | impl std::fmt::Display for ItemList { | 3543 | impl std::fmt::Display for WhereClause { |
3542 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3544 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3543 | std::fmt::Display::fmt(self.syntax(), f) | 3545 | std::fmt::Display::fmt(self.syntax(), f) |
3544 | } | 3546 | } |
3545 | } | 3547 | } |
3546 | impl std::fmt::Display for Module { | 3548 | impl std::fmt::Display for BlockExpr { |
3547 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3549 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3548 | std::fmt::Display::fmt(self.syntax(), f) | 3550 | std::fmt::Display::fmt(self.syntax(), f) |
3549 | } | 3551 | } |
3550 | } | 3552 | } |
3551 | impl std::fmt::Display for ConstDef { | 3553 | impl std::fmt::Display for RecordFieldDefList { |
3552 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3554 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3553 | std::fmt::Display::fmt(self.syntax(), f) | 3555 | std::fmt::Display::fmt(self.syntax(), f) |
3554 | } | 3556 | } |
3555 | } | 3557 | } |
3556 | impl std::fmt::Display for StaticDef { | 3558 | impl std::fmt::Display for TupleFieldDefList { |
3557 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3559 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3558 | std::fmt::Display::fmt(self.syntax(), f) | 3560 | std::fmt::Display::fmt(self.syntax(), f) |
3559 | } | 3561 | } |
3560 | } | 3562 | } |
3561 | impl std::fmt::Display for TypeAliasDef { | 3563 | impl std::fmt::Display for RecordFieldDef { |
3562 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3564 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3563 | std::fmt::Display::fmt(self.syntax(), f) | 3565 | std::fmt::Display::fmt(self.syntax(), f) |
3564 | } | 3566 | } |
3565 | } | 3567 | } |
3566 | impl std::fmt::Display for ImplDef { | 3568 | impl std::fmt::Display for TupleFieldDef { |
3569 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3570 | std::fmt::Display::fmt(self.syntax(), f) | ||
3571 | } | ||
3572 | } | ||
3573 | impl std::fmt::Display for EnumVariantList { | ||
3574 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3575 | std::fmt::Display::fmt(self.syntax(), f) | ||
3576 | } | ||
3577 | } | ||
3578 | impl std::fmt::Display for EnumVariant { | ||
3579 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3580 | std::fmt::Display::fmt(self.syntax(), f) | ||
3581 | } | ||
3582 | } | ||
3583 | impl std::fmt::Display for TypeBoundList { | ||
3584 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3585 | std::fmt::Display::fmt(self.syntax(), f) | ||
3586 | } | ||
3587 | } | ||
3588 | impl std::fmt::Display for ItemList { | ||
3567 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3589 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3568 | std::fmt::Display::fmt(self.syntax(), f) | 3590 | std::fmt::Display::fmt(self.syntax(), f) |
3569 | } | 3591 | } |
@@ -3888,11 +3910,6 @@ impl std::fmt::Display for MacroPat { | |||
3888 | std::fmt::Display::fmt(self.syntax(), f) | 3910 | std::fmt::Display::fmt(self.syntax(), f) |
3889 | } | 3911 | } |
3890 | } | 3912 | } |
3891 | impl std::fmt::Display for MacroCall { | ||
3892 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3893 | std::fmt::Display::fmt(self.syntax(), f) | ||
3894 | } | ||
3895 | } | ||
3896 | impl std::fmt::Display for RecordPat { | 3913 | impl std::fmt::Display for RecordPat { |
3897 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3914 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3898 | std::fmt::Display::fmt(self.syntax(), f) | 3915 | std::fmt::Display::fmt(self.syntax(), f) |
@@ -3983,11 +4000,6 @@ impl std::fmt::Display for Param { | |||
3983 | std::fmt::Display::fmt(self.syntax(), f) | 4000 | std::fmt::Display::fmt(self.syntax(), f) |
3984 | } | 4001 | } |
3985 | } | 4002 | } |
3986 | impl std::fmt::Display for UseItem { | ||
3987 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3988 | std::fmt::Display::fmt(self.syntax(), f) | ||
3989 | } | ||
3990 | } | ||
3991 | impl std::fmt::Display for UseTree { | 4003 | impl std::fmt::Display for UseTree { |
3992 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 4004 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3993 | std::fmt::Display::fmt(self.syntax(), f) | 4005 | std::fmt::Display::fmt(self.syntax(), f) |
@@ -4003,11 +4015,6 @@ impl std::fmt::Display for Alias { | |||
4003 | std::fmt::Display::fmt(self.syntax(), f) | 4015 | std::fmt::Display::fmt(self.syntax(), f) |
4004 | } | 4016 | } |
4005 | } | 4017 | } |
4006 | impl std::fmt::Display for ExternCrateItem { | ||
4007 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
4008 | std::fmt::Display::fmt(self.syntax(), f) | ||
4009 | } | ||
4010 | } | ||
4011 | impl std::fmt::Display for PathSegment { | 4018 | impl std::fmt::Display for PathSegment { |
4012 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 4019 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
4013 | std::fmt::Display::fmt(self.syntax(), f) | 4020 | std::fmt::Display::fmt(self.syntax(), f) |
@@ -4033,11 +4040,6 @@ impl std::fmt::Display for ConstArg { | |||
4033 | std::fmt::Display::fmt(self.syntax(), f) | 4040 | std::fmt::Display::fmt(self.syntax(), f) |
4034 | } | 4041 | } |
4035 | } | 4042 | } |
4036 | impl std::fmt::Display for ExternBlock { | ||
4037 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
4038 | std::fmt::Display::fmt(self.syntax(), f) | ||
4039 | } | ||
4040 | } | ||
4041 | impl std::fmt::Display for ExternItemList { | 4043 | impl std::fmt::Display for ExternItemList { |
4042 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 4044 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
4043 | std::fmt::Display::fmt(self.syntax(), f) | 4045 | 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 a8f2454fd..9fe0b93c1 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 { | |||
44 | } | 44 | } |
45 | 45 | ||
46 | pub trait ModuleItemOwner: AstNode { | 46 | pub trait ModuleItemOwner: AstNode { |
47 | fn items(&self) -> AstChildren<ast::ModuleItem> { | 47 | fn items(&self) -> AstChildren<ast::Item> { |
48 | support::children(self.syntax()) | 48 | support::children(self.syntax()) |
49 | } | 49 | } |
50 | } | 50 | } |
diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs index ac59455e7..219dd0b07 100644 --- a/crates/ra_syntax/src/lib.rs +++ b/crates/ra_syntax/src/lib.rs | |||
@@ -187,7 +187,7 @@ impl ast::Expr { | |||
187 | } | 187 | } |
188 | } | 188 | } |
189 | 189 | ||
190 | impl ast::ModuleItem { | 190 | impl ast::Item { |
191 | /// Returns `text`, parsed as an item, but only if it has no errors. | 191 | /// Returns `text`, parsed as an item, but only if it has no errors. |
192 | pub fn parse(text: &str) -> Result<Self, ()> { | 192 | pub fn parse(text: &str) -> Result<Self, ()> { |
193 | parsing::parse_text_fragment(text, ra_parser::FragmentKind::Item) | 193 | parsing::parse_text_fragment(text, ra_parser::FragmentKind::Item) |
@@ -255,7 +255,7 @@ fn api_walkthrough() { | |||
255 | let mut func = None; | 255 | let mut func = None; |
256 | for item in file.items() { | 256 | for item in file.items() { |
257 | match item { | 257 | match item { |
258 | ast::ModuleItem::FnDef(f) => func = Some(f), | 258 | ast::Item::FnDef(f) => func = Some(f), |
259 | _ => unreachable!(), | 259 | _ => unreachable!(), |
260 | } | 260 | } |
261 | } | 261 | } |
diff --git a/crates/ra_syntax/src/tests.rs b/crates/ra_syntax/src/tests.rs index 8447dcad7..68cee8914 100644 --- a/crates/ra_syntax/src/tests.rs +++ b/crates/ra_syntax/src/tests.rs | |||
@@ -89,7 +89,7 @@ fn item_parser_tests() { | |||
89 | fragment_parser_dir_test( | 89 | fragment_parser_dir_test( |
90 | &["parser/fragments/item/ok"], | 90 | &["parser/fragments/item/ok"], |
91 | &["parser/fragments/item/err"], | 91 | &["parser/fragments/item/err"], |
92 | crate::ast::ModuleItem::parse, | 92 | crate::ast::Item::parse, |
93 | ); | 93 | ); |
94 | } | 94 | } |
95 | 95 | ||
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index 1350bd400..87a1367ac 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs | |||
@@ -469,12 +469,12 @@ pub(crate) fn handle_runnables( | |||
469 | res.push(runnable); | 469 | res.push(runnable); |
470 | } | 470 | } |
471 | 471 | ||
472 | // Add `cargo check` and `cargo test` for the whole package | 472 | // Add `cargo check` and `cargo test` for all targets of the whole package |
473 | match cargo_spec { | 473 | match cargo_spec { |
474 | Some(spec) => { | 474 | Some(spec) => { |
475 | for &cmd in ["check", "test"].iter() { | 475 | for &cmd in ["check", "test"].iter() { |
476 | res.push(lsp_ext::Runnable { | 476 | res.push(lsp_ext::Runnable { |
477 | label: format!("cargo {} -p {}", cmd, spec.package), | 477 | label: format!("cargo {} -p {} --all-targets", cmd, spec.package), |
478 | location: None, | 478 | location: None, |
479 | kind: lsp_ext::RunnableKind::Cargo, | 479 | kind: lsp_ext::RunnableKind::Cargo, |
480 | args: lsp_ext::CargoRunnable { | 480 | args: lsp_ext::CargoRunnable { |
@@ -483,6 +483,7 @@ pub(crate) fn handle_runnables( | |||
483 | cmd.to_string(), | 483 | cmd.to_string(), |
484 | "--package".to_string(), | 484 | "--package".to_string(), |
485 | spec.package.clone(), | 485 | spec.package.clone(), |
486 | "--all-targets".to_string(), | ||
486 | ], | 487 | ], |
487 | executable_args: Vec::new(), | 488 | executable_args: Vec::new(), |
488 | expect_test: None, | 489 | expect_test: None, |
diff --git a/crates/rust-analyzer/tests/heavy_tests/main.rs b/crates/rust-analyzer/tests/heavy_tests/main.rs index 28e896648..7370505f8 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() {} | |||
115 | }, | 115 | }, |
116 | { | 116 | { |
117 | "args": { | 117 | "args": { |
118 | "cargoArgs": ["check", "--package", "foo"], | 118 | "cargoArgs": ["check", "--package", "foo", "--all-targets"], |
119 | "executableArgs": [], | 119 | "executableArgs": [], |
120 | "workspaceRoot": server.path().join("foo") | 120 | "workspaceRoot": server.path().join("foo") |
121 | }, | 121 | }, |
122 | "kind": "cargo", | 122 | "kind": "cargo", |
123 | "label": "cargo check -p foo" | 123 | "label": "cargo check -p foo --all-targets" |
124 | }, | 124 | }, |
125 | { | 125 | { |
126 | "args": { | 126 | "args": { |
127 | "cargoArgs": ["test", "--package", "foo"], | 127 | "cargoArgs": ["test", "--package", "foo", "--all-targets"], |
128 | "executableArgs": [], | 128 | "executableArgs": [], |
129 | "workspaceRoot": server.path().join("foo") | 129 | "workspaceRoot": server.path().join("foo") |
130 | }, | 130 | }, |
131 | "kind": "cargo", | 131 | "kind": "cargo", |
132 | "label": "cargo test -p foo" | 132 | "label": "cargo test -p foo --all-targets" |
133 | } | 133 | } |
134 | ]), | 134 | ]), |
135 | ); | 135 | ); |
diff --git a/xtask/src/codegen/gen_syntax.rs b/xtask/src/codegen/gen_syntax.rs index 24e8be1fb..9b49712c1 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> { | |||
374 | #([#all_keywords_idents] => { $crate::SyntaxKind::#all_keywords };)* | 374 | #([#all_keywords_idents] => { $crate::SyntaxKind::#all_keywords };)* |
375 | [lifetime] => { $crate::SyntaxKind::LIFETIME }; | 375 | [lifetime] => { $crate::SyntaxKind::LIFETIME }; |
376 | [ident] => { $crate::SyntaxKind::IDENT }; | 376 | [ident] => { $crate::SyntaxKind::IDENT }; |
377 | [shebang] => { $crate::SyntaxKind::SHEBANG }; | ||
377 | } | 378 | } |
378 | }; | 379 | }; |
379 | 380 | ||
@@ -595,7 +596,6 @@ fn lower_rule(acc: &mut Vec<Field>, grammar: &Grammar, rule: &Rule) { | |||
595 | } | 596 | } |
596 | 597 | ||
597 | fn deduplicate_fields(ast: &mut AstSrc) { | 598 | fn deduplicate_fields(ast: &mut AstSrc) { |
598 | eprintln!(); | ||
599 | for node in &mut ast.nodes { | 599 | for node in &mut ast.nodes { |
600 | let mut i = 0; | 600 | let mut i = 0; |
601 | 'outer: while i < node.fields.len() { | 601 | 'outer: while i < node.fields.len() { |
diff --git a/xtask/src/codegen/rust.ungram b/xtask/src/codegen/rust.ungram index b6ec5d5e7..a93cb3815 100644 --- a/xtask/src/codegen/rust.ungram +++ b/xtask/src/codegen/rust.ungram | |||
@@ -1,6 +1,23 @@ | |||
1 | SourceFile = | 1 | SourceFile = |
2 | 'shebang'? | ||
2 | Attr* | 3 | Attr* |
3 | items:ModuleItem* | 4 | Item* |
5 | |||
6 | Item = | ||
7 | ConstDef | ||
8 | | EnumDef | ||
9 | | ExternBlock | ||
10 | | ExternCrateItem | ||
11 | | FnDef | ||
12 | | ImplDef | ||
13 | | MacroCall | ||
14 | | Module | ||
15 | | StaticDef | ||
16 | | StructDef | ||
17 | | TraitDef | ||
18 | | TypeAliasDef | ||
19 | | UnionDef | ||
20 | | UseItem | ||
4 | 21 | ||
5 | FnDef = | 22 | FnDef = |
6 | Attr* Visibility? Abi? 'const' 'default' 'async' 'unsafe' 'fn' Name TypeParamList? | 23 | Attr* Visibility? Abi? 'const' 'default' 'async' 'unsafe' 'fn' Name TypeParamList? |
@@ -59,7 +76,7 @@ Module = | |||
59 | ItemList = | 76 | ItemList = |
60 | '{' | 77 | '{' |
61 | AssocItem* | 78 | AssocItem* |
62 | items:ModuleItem* | 79 | Item* |
63 | '}' | 80 | '}' |
64 | 81 | ||
65 | ConstDef = | 82 | ConstDef = |
@@ -168,7 +185,7 @@ Label = | |||
168 | BlockExpr = | 185 | BlockExpr = |
169 | Attr* Label | 186 | Attr* Label |
170 | '{' | 187 | '{' |
171 | items:ModuleItem* | 188 | Item* |
172 | statements:Stmt* | 189 | statements:Stmt* |
173 | Expr? | 190 | Expr? |
174 | '}' | 191 | '}' |
@@ -316,7 +333,7 @@ TokenTree = | |||
316 | '(' ')' | '{' '}' | '[' ']' | 333 | '(' ')' | '{' '}' | '[' ']' |
317 | 334 | ||
318 | MacroItems = | 335 | MacroItems = |
319 | items:ModuleItem* | 336 | Item* |
320 | 337 | ||
321 | MacroStmts = | 338 | MacroStmts = |
322 | statements:Stmt* | 339 | statements:Stmt* |
@@ -454,22 +471,6 @@ AssocItem = | |||
454 | ExternItem = | 471 | ExternItem = |
455 | FnDef | StaticDef | 472 | FnDef | StaticDef |
456 | 473 | ||
457 | ModuleItem = | ||
458 | StructDef | ||
459 | | UnionDef | ||
460 | | EnumDef | ||
461 | | FnDef | ||
462 | | TraitDef | ||
463 | | TypeAliasDef | ||
464 | | ImplDef | ||
465 | | UseItem | ||
466 | | ExternCrateItem | ||
467 | | ConstDef | ||
468 | | StaticDef | ||
469 | | Module | ||
470 | | MacroCall | ||
471 | | ExternBlock | ||
472 | |||
473 | AttrInput = | 474 | AttrInput = |
474 | Literal | 475 | Literal |
475 | | TokenTree | 476 | | TokenTree |