diff options
-rw-r--r-- | crates/ra_assists/src/handlers/auto_import.rs | 2 | ||||
-rw-r--r-- | crates/ra_assists/src/handlers/merge_imports.rs | 2 | ||||
-rw-r--r-- | crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs | 4 | ||||
-rw-r--r-- | crates/ra_assists/src/utils/insert_use.rs | 8 | ||||
-rw-r--r-- | crates/ra_hir_def/src/body/lower.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir_def/src/item_tree.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir_def/src/item_tree/lower.rs | 6 | ||||
-rw-r--r-- | crates/ra_hir_def/src/path.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide/src/completion/completion_context.rs | 4 | ||||
-rw-r--r-- | crates/ra_ide/src/folding_ranges.rs | 4 | ||||
-rw-r--r-- | crates/ra_parser/src/grammar/items/use_item.rs | 2 | ||||
-rw-r--r-- | crates/ra_parser/src/syntax_kind/generated.rs | 2 | ||||
-rw-r--r-- | crates/ra_ssr/src/search.rs | 2 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/edit.rs | 4 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/generated/nodes.rs | 29 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/make.rs | 2 | ||||
-rw-r--r-- | xtask/src/ast_src.rs | 2 | ||||
-rw-r--r-- | xtask/src/codegen/rust.ungram | 4 |
18 files changed, 43 insertions, 42 deletions
diff --git a/crates/ra_assists/src/handlers/auto_import.rs b/crates/ra_assists/src/handlers/auto_import.rs index 947be3b9b..01e7b7a44 100644 --- a/crates/ra_assists/src/handlers/auto_import.rs +++ b/crates/ra_assists/src/handlers/auto_import.rs | |||
@@ -92,7 +92,7 @@ impl AutoImportAssets { | |||
92 | 92 | ||
93 | fn for_regular_path(path_under_caret: ast::Path, ctx: &AssistContext) -> Option<Self> { | 93 | fn for_regular_path(path_under_caret: ast::Path, ctx: &AssistContext) -> Option<Self> { |
94 | let syntax_under_caret = path_under_caret.syntax().to_owned(); | 94 | let syntax_under_caret = path_under_caret.syntax().to_owned(); |
95 | if syntax_under_caret.ancestors().find_map(ast::UseItem::cast).is_some() { | 95 | if syntax_under_caret.ancestors().find_map(ast::Use::cast).is_some() { |
96 | return None; | 96 | return None; |
97 | } | 97 | } |
98 | 98 | ||
diff --git a/crates/ra_assists/src/handlers/merge_imports.rs b/crates/ra_assists/src/handlers/merge_imports.rs index 1beccb61c..c775fe25c 100644 --- a/crates/ra_assists/src/handlers/merge_imports.rs +++ b/crates/ra_assists/src/handlers/merge_imports.rs | |||
@@ -28,7 +28,7 @@ pub(crate) fn merge_imports(acc: &mut Assists, ctx: &AssistContext) -> Option<() | |||
28 | let mut rewriter = SyntaxRewriter::default(); | 28 | let mut rewriter = SyntaxRewriter::default(); |
29 | let mut offset = ctx.offset(); | 29 | let mut offset = ctx.offset(); |
30 | 30 | ||
31 | if let Some(use_item) = tree.syntax().parent().and_then(ast::UseItem::cast) { | 31 | if let Some(use_item) = tree.syntax().parent().and_then(ast::Use::cast) { |
32 | let (merged, to_delete) = next_prev() | 32 | let (merged, to_delete) = next_prev() |
33 | .filter_map(|dir| neighbor(&use_item, dir)) | 33 | .filter_map(|dir| neighbor(&use_item, dir)) |
34 | .filter_map(|it| Some((it.clone(), it.use_tree()?))) | 34 | .filter_map(|it| Some((it.clone(), it.use_tree()?))) |
diff --git a/crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs b/crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs index 3d51faa54..53496ede1 100644 --- a/crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs +++ b/crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs | |||
@@ -25,7 +25,7 @@ pub(crate) fn replace_qualified_name_with_use( | |||
25 | ) -> Option<()> { | 25 | ) -> Option<()> { |
26 | let path: ast::Path = ctx.find_node_at_offset()?; | 26 | let path: ast::Path = ctx.find_node_at_offset()?; |
27 | // We don't want to mess with use statements | 27 | // We don't want to mess with use statements |
28 | if path.syntax().ancestors().find_map(ast::UseItem::cast).is_some() { | 28 | if path.syntax().ancestors().find_map(ast::Use::cast).is_some() { |
29 | return None; | 29 | return None; |
30 | } | 30 | } |
31 | 31 | ||
@@ -85,7 +85,7 @@ fn shorten_paths(rewriter: &mut SyntaxRewriter<'static>, node: SyntaxNode, path: | |||
85 | match child { | 85 | match child { |
86 | // Don't modify `use` items, as this can break the `use` item when injecting a new | 86 | // Don't modify `use` items, as this can break the `use` item when injecting a new |
87 | // import into the use tree. | 87 | // import into the use tree. |
88 | ast::UseItem(_it) => continue, | 88 | ast::Use(_it) => continue, |
89 | // Don't descend into submodules, they don't have the same `use` items in scope. | 89 | // Don't descend into submodules, they don't have the same `use` items in scope. |
90 | ast::Module(_it) => continue, | 90 | ast::Module(_it) => continue, |
91 | 91 | ||
diff --git a/crates/ra_assists/src/utils/insert_use.rs b/crates/ra_assists/src/utils/insert_use.rs index c05027eff..617afe2e9 100644 --- a/crates/ra_assists/src/utils/insert_use.rs +++ b/crates/ra_assists/src/utils/insert_use.rs | |||
@@ -225,7 +225,7 @@ fn walk_use_tree_for_best_action( | |||
225 | current_use_tree | 225 | current_use_tree |
226 | .syntax() | 226 | .syntax() |
227 | .ancestors() | 227 | .ancestors() |
228 | .find_map(ast::UseItem::cast) | 228 | .find_map(ast::Use::cast) |
229 | .map(|it| it.syntax().clone()), | 229 | .map(|it| it.syntax().clone()), |
230 | true, | 230 | true, |
231 | ); | 231 | ); |
@@ -254,7 +254,7 @@ fn walk_use_tree_for_best_action( | |||
254 | current_use_tree | 254 | current_use_tree |
255 | .syntax() | 255 | .syntax() |
256 | .ancestors() | 256 | .ancestors() |
257 | .find_map(ast::UseItem::cast) | 257 | .find_map(ast::Use::cast) |
258 | .map(|it| it.syntax().clone()), | 258 | .map(|it| it.syntax().clone()), |
259 | true, | 259 | true, |
260 | ), | 260 | ), |
@@ -304,7 +304,7 @@ fn walk_use_tree_for_best_action( | |||
304 | current_use_tree | 304 | current_use_tree |
305 | .syntax() | 305 | .syntax() |
306 | .ancestors() | 306 | .ancestors() |
307 | .find_map(ast::UseItem::cast) | 307 | .find_map(ast::Use::cast) |
308 | .map(|it| it.syntax().clone()), | 308 | .map(|it| it.syntax().clone()), |
309 | true, | 309 | true, |
310 | ); | 310 | ); |
@@ -377,7 +377,7 @@ fn best_action_for_target( | |||
377 | let mut storage = Vec::with_capacity(16); // this should be the only allocation | 377 | let mut storage = Vec::with_capacity(16); // this should be the only allocation |
378 | let best_action = container | 378 | let best_action = container |
379 | .children() | 379 | .children() |
380 | .filter_map(ast::UseItem::cast) | 380 | .filter_map(ast::Use::cast) |
381 | .filter_map(|it| it.use_tree()) | 381 | .filter_map(|it| it.use_tree()) |
382 | .map(|u| walk_use_tree_for_best_action(&mut storage, None, u, target)) | 382 | .map(|u| walk_use_tree_for_best_action(&mut storage, None, u, target)) |
383 | .fold(None, |best, a| match best { | 383 | .fold(None, |best, a| match best { |
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index bfd574c5d..5c57d8bde 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs | |||
@@ -670,7 +670,7 @@ impl ExprCollector<'_> { | |||
670 | } | 670 | } |
671 | ast::Item::ExternBlock(_) => return None, // FIXME: collect from extern blocks | 671 | ast::Item::ExternBlock(_) => return None, // FIXME: collect from extern blocks |
672 | ast::Item::ImplDef(_) | 672 | ast::Item::ImplDef(_) |
673 | | ast::Item::UseItem(_) | 673 | | ast::Item::Use(_) |
674 | | ast::Item::ExternCrate(_) | 674 | | ast::Item::ExternCrate(_) |
675 | | ast::Item::Module(_) | 675 | | ast::Item::Module(_) |
676 | | ast::Item::MacroCall(_) => return None, | 676 | | ast::Item::MacroCall(_) => return None, |
diff --git a/crates/ra_hir_def/src/item_tree.rs b/crates/ra_hir_def/src/item_tree.rs index 4db7b2793..0bab9c6d8 100644 --- a/crates/ra_hir_def/src/item_tree.rs +++ b/crates/ra_hir_def/src/item_tree.rs | |||
@@ -411,7 +411,7 @@ macro_rules! mod_items { | |||
411 | } | 411 | } |
412 | 412 | ||
413 | mod_items! { | 413 | mod_items! { |
414 | Import in imports -> ast::UseItem, | 414 | Import in imports -> ast::Use, |
415 | ExternCrate in extern_crates -> ast::ExternCrate, | 415 | ExternCrate in extern_crates -> ast::ExternCrate, |
416 | Function in functions -> ast::FnDef, | 416 | Function in functions -> ast::FnDef, |
417 | Struct in structs -> ast::StructDef, | 417 | Struct in structs -> ast::StructDef, |
@@ -482,7 +482,7 @@ pub struct Import { | |||
482 | pub is_prelude: bool, | 482 | pub is_prelude: bool, |
483 | /// AST ID of the `use` or `extern crate` item this import was derived from. Note that many | 483 | /// AST ID of the `use` or `extern crate` item this import was derived from. Note that many |
484 | /// `Import`s can map to the same `use` item. | 484 | /// `Import`s can map to the same `use` item. |
485 | pub ast_id: FileAstId<ast::UseItem>, | 485 | pub ast_id: FileAstId<ast::Use>, |
486 | } | 486 | } |
487 | 487 | ||
488 | #[derive(Debug, Clone, Eq, PartialEq)] | 488 | #[derive(Debug, Clone, Eq, PartialEq)] |
diff --git a/crates/ra_hir_def/src/item_tree/lower.rs b/crates/ra_hir_def/src/item_tree/lower.rs index 8a36de311..8bd0362dc 100644 --- a/crates/ra_hir_def/src/item_tree/lower.rs +++ b/crates/ra_hir_def/src/item_tree/lower.rs | |||
@@ -95,7 +95,7 @@ impl Ctx { | |||
95 | ast::Item::TraitDef(_) | ast::Item::ImplDef(_) | ast::Item::ExternBlock(_) => {} | 95 | ast::Item::TraitDef(_) | ast::Item::ImplDef(_) | ast::Item::ExternBlock(_) => {} |
96 | 96 | ||
97 | // These don't have inner items. | 97 | // These don't have inner items. |
98 | ast::Item::Module(_) | ast::Item::ExternCrate(_) | ast::Item::UseItem(_) => {} | 98 | ast::Item::Module(_) | ast::Item::ExternCrate(_) | ast::Item::Use(_) => {} |
99 | }; | 99 | }; |
100 | 100 | ||
101 | let attrs = Attrs::new(item, &self.hygiene); | 101 | let attrs = Attrs::new(item, &self.hygiene); |
@@ -110,7 +110,7 @@ impl Ctx { | |||
110 | ast::Item::Module(ast) => self.lower_module(ast).map(Into::into), | 110 | ast::Item::Module(ast) => self.lower_module(ast).map(Into::into), |
111 | ast::Item::TraitDef(ast) => self.lower_trait(ast).map(Into::into), | 111 | ast::Item::TraitDef(ast) => self.lower_trait(ast).map(Into::into), |
112 | ast::Item::ImplDef(ast) => self.lower_impl(ast).map(Into::into), | 112 | ast::Item::ImplDef(ast) => self.lower_impl(ast).map(Into::into), |
113 | ast::Item::UseItem(ast) => Some(ModItems( | 113 | ast::Item::Use(ast) => Some(ModItems( |
114 | self.lower_use(ast).into_iter().map(Into::into).collect::<SmallVec<_>>(), | 114 | self.lower_use(ast).into_iter().map(Into::into).collect::<SmallVec<_>>(), |
115 | )), | 115 | )), |
116 | ast::Item::ExternCrate(ast) => self.lower_extern_crate(ast).map(Into::into), | 116 | ast::Item::ExternCrate(ast) => self.lower_extern_crate(ast).map(Into::into), |
@@ -469,7 +469,7 @@ impl Ctx { | |||
469 | Some(id(self.data().impls.alloc(res))) | 469 | Some(id(self.data().impls.alloc(res))) |
470 | } | 470 | } |
471 | 471 | ||
472 | fn lower_use(&mut self, use_item: &ast::UseItem) -> Vec<FileItemTreeId<Import>> { | 472 | fn lower_use(&mut self, use_item: &ast::Use) -> Vec<FileItemTreeId<Import>> { |
473 | // FIXME: cfg_attr | 473 | // FIXME: cfg_attr |
474 | let is_prelude = use_item.has_atom_attr("prelude_import"); | 474 | let is_prelude = use_item.has_atom_attr("prelude_import"); |
475 | let visibility = self.lower_visibility(use_item); | 475 | let visibility = self.lower_visibility(use_item); |
diff --git a/crates/ra_hir_def/src/path.rs b/crates/ra_hir_def/src/path.rs index 190d6d98d..68b9f89c3 100644 --- a/crates/ra_hir_def/src/path.rs +++ b/crates/ra_hir_def/src/path.rs | |||
@@ -67,7 +67,7 @@ impl ModPath { | |||
67 | 67 | ||
68 | /// Calls `cb` with all paths, represented by this use item. | 68 | /// Calls `cb` with all paths, represented by this use item. |
69 | pub(crate) fn expand_use_item( | 69 | pub(crate) fn expand_use_item( |
70 | item_src: InFile<ast::UseItem>, | 70 | item_src: InFile<ast::Use>, |
71 | hygiene: &Hygiene, | 71 | hygiene: &Hygiene, |
72 | mut cb: impl FnMut(ModPath, &ast::UseTree, /* is_glob */ bool, Option<ImportAlias>), | 72 | mut cb: impl FnMut(ModPath, &ast::UseTree, /* is_glob */ bool, Option<ImportAlias>), |
73 | ) { | 73 | ) { |
diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs index c84d43d77..cc55f6dd6 100644 --- a/crates/ra_ide/src/completion/completion_context.rs +++ b/crates/ra_ide/src/completion/completion_context.rs | |||
@@ -36,7 +36,7 @@ pub(crate) struct CompletionContext<'a> { | |||
36 | pub(super) expected_type: Option<Type>, | 36 | pub(super) expected_type: Option<Type>, |
37 | pub(super) name_ref_syntax: Option<ast::NameRef>, | 37 | pub(super) name_ref_syntax: Option<ast::NameRef>, |
38 | pub(super) function_syntax: Option<ast::FnDef>, | 38 | pub(super) function_syntax: Option<ast::FnDef>, |
39 | pub(super) use_item_syntax: Option<ast::UseItem>, | 39 | pub(super) use_item_syntax: Option<ast::Use>, |
40 | pub(super) record_lit_syntax: Option<ast::RecordLit>, | 40 | pub(super) record_lit_syntax: Option<ast::RecordLit>, |
41 | pub(super) record_pat_syntax: Option<ast::RecordPat>, | 41 | pub(super) record_pat_syntax: Option<ast::RecordPat>, |
42 | pub(super) record_field_syntax: Option<ast::RecordField>, | 42 | pub(super) record_field_syntax: Option<ast::RecordField>, |
@@ -343,7 +343,7 @@ impl<'a> CompletionContext<'a> { | |||
343 | } | 343 | } |
344 | 344 | ||
345 | self.use_item_syntax = | 345 | self.use_item_syntax = |
346 | self.sema.ancestors_with_macros(self.token.parent()).find_map(ast::UseItem::cast); | 346 | self.sema.ancestors_with_macros(self.token.parent()).find_map(ast::Use::cast); |
347 | 347 | ||
348 | self.function_syntax = self | 348 | self.function_syntax = self |
349 | .sema | 349 | .sema |
diff --git a/crates/ra_ide/src/folding_ranges.rs b/crates/ra_ide/src/folding_ranges.rs index 315808890..bad079146 100644 --- a/crates/ra_ide/src/folding_ranges.rs +++ b/crates/ra_ide/src/folding_ranges.rs | |||
@@ -58,7 +58,7 @@ pub(crate) fn folding_ranges(file: &SourceFile) -> Vec<Fold> { | |||
58 | } | 58 | } |
59 | NodeOrToken::Node(node) => { | 59 | NodeOrToken::Node(node) => { |
60 | // Fold groups of imports | 60 | // Fold groups of imports |
61 | if node.kind() == USE_ITEM && !visited_imports.contains(&node) { | 61 | if node.kind() == USE && !visited_imports.contains(&node) { |
62 | if let Some(range) = contiguous_range_for_group(&node, &mut visited_imports) { | 62 | if let Some(range) = contiguous_range_for_group(&node, &mut visited_imports) { |
63 | res.push(Fold { range, kind: FoldKind::Imports }) | 63 | res.push(Fold { range, kind: FoldKind::Imports }) |
64 | } | 64 | } |
@@ -83,7 +83,7 @@ pub(crate) fn folding_ranges(file: &SourceFile) -> Vec<Fold> { | |||
83 | fn fold_kind(kind: SyntaxKind) -> Option<FoldKind> { | 83 | fn fold_kind(kind: SyntaxKind) -> Option<FoldKind> { |
84 | match kind { | 84 | match kind { |
85 | COMMENT => Some(FoldKind::Comment), | 85 | COMMENT => Some(FoldKind::Comment), |
86 | USE_ITEM => Some(FoldKind::Imports), | 86 | USE => Some(FoldKind::Imports), |
87 | ARG_LIST | PARAM_LIST => Some(FoldKind::ArgList), | 87 | ARG_LIST | PARAM_LIST => Some(FoldKind::ArgList), |
88 | RECORD_FIELD_DEF_LIST | 88 | RECORD_FIELD_DEF_LIST |
89 | | RECORD_FIELD_PAT_LIST | 89 | | RECORD_FIELD_PAT_LIST |
diff --git a/crates/ra_parser/src/grammar/items/use_item.rs b/crates/ra_parser/src/grammar/items/use_item.rs index 3a0c7a31a..8e836a77e 100644 --- a/crates/ra_parser/src/grammar/items/use_item.rs +++ b/crates/ra_parser/src/grammar/items/use_item.rs | |||
@@ -7,7 +7,7 @@ pub(super) fn use_item(p: &mut Parser, m: Marker) { | |||
7 | p.bump(T![use]); | 7 | p.bump(T![use]); |
8 | use_tree(p, true); | 8 | use_tree(p, true); |
9 | p.expect(T![;]); | 9 | p.expect(T![;]); |
10 | m.complete(p, USE_ITEM); | 10 | m.complete(p, USE); |
11 | } | 11 | } |
12 | 12 | ||
13 | /// Parse a use 'tree', such as `some::path` in `use some::path;` | 13 | /// Parse a use 'tree', such as `some::path` in `use some::path;` |
diff --git a/crates/ra_parser/src/syntax_kind/generated.rs b/crates/ra_parser/src/syntax_kind/generated.rs index 116b58858..4f35e0baa 100644 --- a/crates/ra_parser/src/syntax_kind/generated.rs +++ b/crates/ra_parser/src/syntax_kind/generated.rs | |||
@@ -130,7 +130,7 @@ pub enum SyntaxKind { | |||
130 | RET_TYPE, | 130 | RET_TYPE, |
131 | EXTERN_CRATE, | 131 | EXTERN_CRATE, |
132 | MODULE, | 132 | MODULE, |
133 | USE_ITEM, | 133 | USE, |
134 | STATIC_DEF, | 134 | STATIC_DEF, |
135 | CONST_DEF, | 135 | CONST_DEF, |
136 | TRAIT_DEF, | 136 | TRAIT_DEF, |
diff --git a/crates/ra_ssr/src/search.rs b/crates/ra_ssr/src/search.rs index 0f512cb62..213dc494f 100644 --- a/crates/ra_ssr/src/search.rs +++ b/crates/ra_ssr/src/search.rs | |||
@@ -237,7 +237,7 @@ fn is_search_permitted(node: &SyntaxNode) -> bool { | |||
237 | // and the code is `use foo::{baz, bar}`, we'll match `bar`, since it resolves to `foo::bar`. | 237 | // and the code is `use foo::{baz, bar}`, we'll match `bar`, since it resolves to `foo::bar`. |
238 | // However we'll then replace just the part we matched `bar`. We probably need to instead remove | 238 | // However we'll then replace just the part we matched `bar`. We probably need to instead remove |
239 | // `bar` and insert a new use declaration. | 239 | // `bar` and insert a new use declaration. |
240 | node.kind() != SyntaxKind::USE_ITEM | 240 | node.kind() != SyntaxKind::USE |
241 | } | 241 | } |
242 | 242 | ||
243 | impl UsageCache { | 243 | impl UsageCache { |
diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/ra_syntax/src/ast/edit.rs index 2e958fa23..6ebe10ff6 100644 --- a/crates/ra_syntax/src/ast/edit.rs +++ b/crates/ra_syntax/src/ast/edit.rs | |||
@@ -262,9 +262,9 @@ impl ast::PathSegment { | |||
262 | } | 262 | } |
263 | } | 263 | } |
264 | 264 | ||
265 | impl ast::UseItem { | 265 | impl ast::Use { |
266 | #[must_use] | 266 | #[must_use] |
267 | pub fn with_use_tree(&self, use_tree: ast::UseTree) -> ast::UseItem { | 267 | pub fn with_use_tree(&self, use_tree: ast::UseTree) -> ast::Use { |
268 | if let Some(old) = self.use_tree() { | 268 | if let Some(old) = self.use_tree() { |
269 | return self.replace_descendant(old, use_tree); | 269 | return self.replace_descendant(old, use_tree); |
270 | } | 270 | } |
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index 9d8127a3d..be657699f 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs | |||
@@ -213,12 +213,12 @@ impl UnionDef { | |||
213 | } | 213 | } |
214 | } | 214 | } |
215 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 215 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
216 | pub struct UseItem { | 216 | pub struct Use { |
217 | pub(crate) syntax: SyntaxNode, | 217 | pub(crate) syntax: SyntaxNode, |
218 | } | 218 | } |
219 | impl ast::AttrsOwner for UseItem {} | 219 | impl ast::AttrsOwner for Use {} |
220 | impl ast::VisibilityOwner for UseItem {} | 220 | impl ast::VisibilityOwner for Use {} |
221 | impl UseItem { | 221 | impl Use { |
222 | pub fn use_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![use]) } | 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) } | 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![;]) } | 224 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } |
@@ -1283,7 +1283,7 @@ pub enum Item { | |||
1283 | TraitDef(TraitDef), | 1283 | TraitDef(TraitDef), |
1284 | TypeAliasDef(TypeAliasDef), | 1284 | TypeAliasDef(TypeAliasDef), |
1285 | UnionDef(UnionDef), | 1285 | UnionDef(UnionDef), |
1286 | UseItem(UseItem), | 1286 | Use(Use), |
1287 | } | 1287 | } |
1288 | impl ast::AttrsOwner for Item {} | 1288 | impl ast::AttrsOwner for Item {} |
1289 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1289 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
@@ -1562,8 +1562,8 @@ impl AstNode for UnionDef { | |||
1562 | } | 1562 | } |
1563 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1563 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1564 | } | 1564 | } |
1565 | impl AstNode for UseItem { | 1565 | impl AstNode for Use { |
1566 | fn can_cast(kind: SyntaxKind) -> bool { kind == USE_ITEM } | 1566 | fn can_cast(kind: SyntaxKind) -> bool { kind == USE } |
1567 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1567 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1568 | if Self::can_cast(syntax.kind()) { | 1568 | if Self::can_cast(syntax.kind()) { |
1569 | Some(Self { syntax }) | 1569 | Some(Self { syntax }) |
@@ -2811,15 +2811,16 @@ impl From<TypeAliasDef> for Item { | |||
2811 | impl From<UnionDef> for Item { | 2811 | impl From<UnionDef> for Item { |
2812 | fn from(node: UnionDef) -> Item { Item::UnionDef(node) } | 2812 | fn from(node: UnionDef) -> Item { Item::UnionDef(node) } |
2813 | } | 2813 | } |
2814 | impl From<UseItem> for Item { | 2814 | impl From<Use> for Item { |
2815 | fn from(node: UseItem) -> Item { Item::UseItem(node) } | 2815 | fn from(node: Use) -> Item { Item::Use(node) } |
2816 | } | 2816 | } |
2817 | impl AstNode for Item { | 2817 | impl AstNode for Item { |
2818 | fn can_cast(kind: SyntaxKind) -> bool { | 2818 | fn can_cast(kind: SyntaxKind) -> bool { |
2819 | match kind { | 2819 | match kind { |
2820 | CONST_DEF | ENUM_DEF | EXTERN_BLOCK | EXTERN_CRATE | FN_DEF | IMPL_DEF | MACRO_CALL | 2820 | CONST_DEF | ENUM_DEF | EXTERN_BLOCK | EXTERN_CRATE | FN_DEF | IMPL_DEF | MACRO_CALL |
2821 | | MODULE | STATIC_DEF | STRUCT_DEF | TRAIT_DEF | TYPE_ALIAS_DEF | UNION_DEF | 2821 | | MODULE | STATIC_DEF | STRUCT_DEF | TRAIT_DEF | TYPE_ALIAS_DEF | UNION_DEF | USE => { |
2822 | | USE_ITEM => true, | 2822 | true |
2823 | } | ||
2823 | _ => false, | 2824 | _ => false, |
2824 | } | 2825 | } |
2825 | } | 2826 | } |
@@ -2838,7 +2839,7 @@ impl AstNode for Item { | |||
2838 | TRAIT_DEF => Item::TraitDef(TraitDef { syntax }), | 2839 | TRAIT_DEF => Item::TraitDef(TraitDef { syntax }), |
2839 | TYPE_ALIAS_DEF => Item::TypeAliasDef(TypeAliasDef { syntax }), | 2840 | TYPE_ALIAS_DEF => Item::TypeAliasDef(TypeAliasDef { syntax }), |
2840 | UNION_DEF => Item::UnionDef(UnionDef { syntax }), | 2841 | UNION_DEF => Item::UnionDef(UnionDef { syntax }), |
2841 | USE_ITEM => Item::UseItem(UseItem { syntax }), | 2842 | USE => Item::Use(Use { syntax }), |
2842 | _ => return None, | 2843 | _ => return None, |
2843 | }; | 2844 | }; |
2844 | Some(res) | 2845 | Some(res) |
@@ -2858,7 +2859,7 @@ impl AstNode for Item { | |||
2858 | Item::TraitDef(it) => &it.syntax, | 2859 | Item::TraitDef(it) => &it.syntax, |
2859 | Item::TypeAliasDef(it) => &it.syntax, | 2860 | Item::TypeAliasDef(it) => &it.syntax, |
2860 | Item::UnionDef(it) => &it.syntax, | 2861 | Item::UnionDef(it) => &it.syntax, |
2861 | Item::UseItem(it) => &it.syntax, | 2862 | Item::Use(it) => &it.syntax, |
2862 | } | 2863 | } |
2863 | } | 2864 | } |
2864 | } | 2865 | } |
@@ -3531,7 +3532,7 @@ impl std::fmt::Display for UnionDef { | |||
3531 | std::fmt::Display::fmt(self.syntax(), f) | 3532 | std::fmt::Display::fmt(self.syntax(), f) |
3532 | } | 3533 | } |
3533 | } | 3534 | } |
3534 | impl std::fmt::Display for UseItem { | 3535 | impl std::fmt::Display for Use { |
3535 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3536 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3536 | std::fmt::Display::fmt(self.syntax(), f) | 3537 | std::fmt::Display::fmt(self.syntax(), f) |
3537 | } | 3538 | } |
diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/ra_syntax/src/ast/make.rs index 2b05ed2d4..0ff69bc2d 100644 --- a/crates/ra_syntax/src/ast/make.rs +++ b/crates/ra_syntax/src/ast/make.rs | |||
@@ -60,7 +60,7 @@ pub fn use_tree_list(use_trees: impl IntoIterator<Item = ast::UseTree>) -> ast:: | |||
60 | ast_from_text(&format!("use {{{}}};", use_trees)) | 60 | ast_from_text(&format!("use {{{}}};", use_trees)) |
61 | } | 61 | } |
62 | 62 | ||
63 | pub fn use_item(use_tree: ast::UseTree) -> ast::UseItem { | 63 | pub fn use_item(use_tree: ast::UseTree) -> ast::Use { |
64 | ast_from_text(&format!("use {};", use_tree)) | 64 | ast_from_text(&format!("use {};", use_tree)) |
65 | } | 65 | } |
66 | 66 | ||
diff --git a/xtask/src/ast_src.rs b/xtask/src/ast_src.rs index 083727c5c..3a58217c4 100644 --- a/xtask/src/ast_src.rs +++ b/xtask/src/ast_src.rs | |||
@@ -100,7 +100,7 @@ pub(crate) const KINDS_SRC: KindsSrc = KindsSrc { | |||
100 | "RET_TYPE", | 100 | "RET_TYPE", |
101 | "EXTERN_CRATE", | 101 | "EXTERN_CRATE", |
102 | "MODULE", | 102 | "MODULE", |
103 | "USE_ITEM", | 103 | "USE", |
104 | "STATIC_DEF", | 104 | "STATIC_DEF", |
105 | "CONST_DEF", | 105 | "CONST_DEF", |
106 | "TRAIT_DEF", | 106 | "TRAIT_DEF", |
diff --git a/xtask/src/codegen/rust.ungram b/xtask/src/codegen/rust.ungram index 2ba68457f..449b0242f 100644 --- a/xtask/src/codegen/rust.ungram +++ b/xtask/src/codegen/rust.ungram | |||
@@ -17,7 +17,7 @@ Item = | |||
17 | | TraitDef | 17 | | TraitDef |
18 | | TypeAliasDef | 18 | | TypeAliasDef |
19 | | UnionDef | 19 | | UnionDef |
20 | | UseItem | 20 | | Use |
21 | 21 | ||
22 | Module = | 22 | Module = |
23 | Attr* Visibility? 'mod' Name | 23 | Attr* Visibility? 'mod' Name |
@@ -32,7 +32,7 @@ ExternCrate = | |||
32 | Rename = | 32 | Rename = |
33 | 'as' (Name | '_') | 33 | 'as' (Name | '_') |
34 | 34 | ||
35 | UseItem = | 35 | Use = |
36 | Attr* Visibility? 'use' UseTree ';' | 36 | Attr* Visibility? 'use' UseTree ';' |
37 | 37 | ||
38 | UseTree = | 38 | UseTree = |