aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-07-30 13:12:04 +0100
committerAleksey Kladov <[email protected]>2020-07-30 13:12:04 +0100
commit9697d23cbe7b0ad897139b15f1b1ffe1cab6ad89 (patch)
tree8bb4cfc1f38b2add3704c64e0443b69e38ab272a /crates
parent35e7966ebeee70ca2c15b5139b5c1918d9ef4086 (diff)
Rename UseItem -> Use
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_assists/src/handlers/auto_import.rs2
-rw-r--r--crates/ra_assists/src/handlers/merge_imports.rs2
-rw-r--r--crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs4
-rw-r--r--crates/ra_assists/src/utils/insert_use.rs8
-rw-r--r--crates/ra_hir_def/src/body/lower.rs2
-rw-r--r--crates/ra_hir_def/src/item_tree.rs4
-rw-r--r--crates/ra_hir_def/src/item_tree/lower.rs6
-rw-r--r--crates/ra_hir_def/src/path.rs2
-rw-r--r--crates/ra_ide/src/completion/completion_context.rs4
-rw-r--r--crates/ra_ide/src/folding_ranges.rs4
-rw-r--r--crates/ra_parser/src/grammar/items/use_item.rs2
-rw-r--r--crates/ra_parser/src/syntax_kind/generated.rs2
-rw-r--r--crates/ra_ssr/src/search.rs2
-rw-r--r--crates/ra_syntax/src/ast/edit.rs4
-rw-r--r--crates/ra_syntax/src/ast/generated/nodes.rs29
-rw-r--r--crates/ra_syntax/src/ast/make.rs2
16 files changed, 40 insertions, 39 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
413mod_items! { 413mod_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> {
83fn fold_kind(kind: SyntaxKind) -> Option<FoldKind> { 83fn 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
243impl UsageCache { 243impl 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
265impl ast::UseItem { 265impl 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)]
216pub struct UseItem { 216pub struct Use {
217 pub(crate) syntax: SyntaxNode, 217 pub(crate) syntax: SyntaxNode,
218} 218}
219impl ast::AttrsOwner for UseItem {} 219impl ast::AttrsOwner for Use {}
220impl ast::VisibilityOwner for UseItem {} 220impl ast::VisibilityOwner for Use {}
221impl UseItem { 221impl 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}
1288impl ast::AttrsOwner for Item {} 1288impl 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}
1565impl AstNode for UseItem { 1565impl 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 {
2811impl From<UnionDef> for Item { 2811impl From<UnionDef> for Item {
2812 fn from(node: UnionDef) -> Item { Item::UnionDef(node) } 2812 fn from(node: UnionDef) -> Item { Item::UnionDef(node) }
2813} 2813}
2814impl From<UseItem> for Item { 2814impl From<Use> for Item {
2815 fn from(node: UseItem) -> Item { Item::UseItem(node) } 2815 fn from(node: Use) -> Item { Item::Use(node) }
2816} 2816}
2817impl AstNode for Item { 2817impl 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}
3534impl std::fmt::Display for UseItem { 3535impl 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
63pub fn use_item(use_tree: ast::UseTree) -> ast::UseItem { 63pub 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