aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
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/item_tree/tests.rs4
-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/replacing.rs106
-rw-r--r--crates/ra_ssr/src/search.rs2
-rw-r--r--crates/ra_ssr/src/tests.rs25
-rw-r--r--crates/ra_syntax/src/ast/edit.rs4
-rw-r--r--crates/ra_syntax/src/ast/generated/nodes.rs184
-rw-r--r--crates/ra_syntax/src/ast/make.rs2
-rw-r--r--crates/ra_syntax/test_data/parser/err/0002_duplicate_shebang.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/err/0004_use_path_bad_segment.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/err/0035_use_recover.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/err/0036_partial_use.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/err/0040_illegal_crate_kw_location.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/err/0041_illegal_super_keyword_location.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/err/0042_illegal_self_keyword_location.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/err/0015_empty_segment.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0002_use_tree_list.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0020_use_star.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0043_use_alias.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0067_crate_path.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0069_use_tree_list_after_path.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0110_use_path.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0009_use_item.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0010_use_path_segments.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0013_use_path_self_super.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0014_use_tree.rast14
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0015_use_tree.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0035_weird_exprs.rast4
39 files changed, 283 insertions, 190 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/item_tree/tests.rs b/crates/ra_hir_def/src/item_tree/tests.rs
index 68be1cb40..3f2e29d9e 100644
--- a/crates/ra_hir_def/src/item_tree/tests.rs
+++ b/crates/ra_hir_def/src/item_tree/tests.rs
@@ -228,9 +228,9 @@ fn smoke() {
228 228
229 top-level items: 229 top-level items:
230 #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_on_use"))] }, input: None }]) }] 230 #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_on_use"))] }, input: None }]) }]
231 Import { path: ModPath { kind: Plain, segments: [Name(Text("a"))] }, alias: None, visibility: RawVisibilityId("pub(self)"), is_glob: false, is_prelude: false, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::UseItem>(0) } 231 Import { path: ModPath { kind: Plain, segments: [Name(Text("a"))] }, alias: None, visibility: RawVisibilityId("pub(self)"), is_glob: false, is_prelude: false, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Use>(0) }
232 #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_on_use"))] }, input: None }]) }] 232 #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_on_use"))] }, input: None }]) }]
233 Import { path: ModPath { kind: Plain, segments: [Name(Text("b"))] }, alias: None, visibility: RawVisibilityId("pub(self)"), is_glob: true, is_prelude: false, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::UseItem>(0) } 233 Import { path: ModPath { kind: Plain, segments: [Name(Text("b"))] }, alias: None, visibility: RawVisibilityId("pub(self)"), is_glob: true, is_prelude: false, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Use>(0) }
234 #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("ext_crate"))] }, input: None }]) }] 234 #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("ext_crate"))] }, input: None }]) }]
235 ExternCrate { path: ModPath { kind: Plain, segments: [Name(Text("krate"))] }, alias: None, visibility: RawVisibilityId("pub(self)"), is_macro_use: false, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::ExternCrate>(1) } 235 ExternCrate { path: ModPath { kind: Plain, segments: [Name(Text("krate"))] }, alias: None, visibility: RawVisibilityId("pub(self)"), is_macro_use: false, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::ExternCrate>(1) }
236 #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("on_trait"))] }, input: None }]) }] 236 #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("on_trait"))] }, input: None }]) }]
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/replacing.rs b/crates/ra_ssr/src/replacing.rs
index 4b3f5509c..0943244ff 100644
--- a/crates/ra_ssr/src/replacing.rs
+++ b/crates/ra_ssr/src/replacing.rs
@@ -3,8 +3,9 @@
3use crate::matching::Var; 3use crate::matching::Var;
4use crate::{resolving::ResolvedRule, Match, SsrMatches}; 4use crate::{resolving::ResolvedRule, Match, SsrMatches};
5use ra_syntax::ast::{self, AstToken}; 5use ra_syntax::ast::{self, AstToken};
6use ra_syntax::{SyntaxElement, SyntaxKind, SyntaxNode, SyntaxToken, TextSize}; 6use ra_syntax::{SyntaxElement, SyntaxKind, SyntaxNode, SyntaxToken, TextRange, TextSize};
7use ra_text_edit::TextEdit; 7use ra_text_edit::TextEdit;
8use rustc_hash::{FxHashMap, FxHashSet};
8 9
9/// Returns a text edit that will replace each match in `matches` with its corresponding replacement 10/// Returns a text edit that will replace each match in `matches` with its corresponding replacement
10/// template. Placeholders in the template will have been substituted with whatever they matched to 11/// template. Placeholders in the template will have been substituted with whatever they matched to
@@ -38,62 +39,79 @@ struct ReplacementRenderer<'a> {
38 file_src: &'a str, 39 file_src: &'a str,
39 rules: &'a [ResolvedRule], 40 rules: &'a [ResolvedRule],
40 rule: &'a ResolvedRule, 41 rule: &'a ResolvedRule,
42 out: String,
43 // Map from a range within `out` to a token in `template` that represents a placeholder. This is
44 // used to validate that the generated source code doesn't split any placeholder expansions (see
45 // below).
46 placeholder_tokens_by_range: FxHashMap<TextRange, SyntaxToken>,
47 // Which placeholder tokens need to be wrapped in parenthesis in order to ensure that when `out`
48 // is parsed, placeholders don't get split. e.g. if a template of `$a.to_string()` results in `1
49 // + 2.to_string()` then the placeholder value `1 + 2` was split and needs parenthesis.
50 placeholder_tokens_requiring_parenthesis: FxHashSet<SyntaxToken>,
41} 51}
42 52
43fn render_replace(match_info: &Match, file_src: &str, rules: &[ResolvedRule]) -> String { 53fn render_replace(match_info: &Match, file_src: &str, rules: &[ResolvedRule]) -> String {
44 let mut out = String::new();
45 let rule = &rules[match_info.rule_index]; 54 let rule = &rules[match_info.rule_index];
46 let template = rule 55 let template = rule
47 .template 56 .template
48 .as_ref() 57 .as_ref()
49 .expect("You called MatchFinder::edits after calling MatchFinder::add_search_pattern"); 58 .expect("You called MatchFinder::edits after calling MatchFinder::add_search_pattern");
50 let renderer = ReplacementRenderer { match_info, file_src, rules, rule }; 59 let mut renderer = ReplacementRenderer {
51 renderer.render_node(&template.node, &mut out); 60 match_info,
61 file_src,
62 rules,
63 rule,
64 out: String::new(),
65 placeholder_tokens_requiring_parenthesis: FxHashSet::default(),
66 placeholder_tokens_by_range: FxHashMap::default(),
67 };
68 renderer.render_node(&template.node);
69 renderer.maybe_rerender_with_extra_parenthesis(&template.node);
52 for comment in &match_info.ignored_comments { 70 for comment in &match_info.ignored_comments {
53 out.push_str(&comment.syntax().to_string()); 71 renderer.out.push_str(&comment.syntax().to_string());
54 } 72 }
55 out 73 renderer.out
56} 74}
57 75
58impl ReplacementRenderer<'_> { 76impl ReplacementRenderer<'_> {
59 fn render_node_children(&self, node: &SyntaxNode, out: &mut String) { 77 fn render_node_children(&mut self, node: &SyntaxNode) {
60 for node_or_token in node.children_with_tokens() { 78 for node_or_token in node.children_with_tokens() {
61 self.render_node_or_token(&node_or_token, out); 79 self.render_node_or_token(&node_or_token);
62 } 80 }
63 } 81 }
64 82
65 fn render_node_or_token(&self, node_or_token: &SyntaxElement, out: &mut String) { 83 fn render_node_or_token(&mut self, node_or_token: &SyntaxElement) {
66 match node_or_token { 84 match node_or_token {
67 SyntaxElement::Token(token) => { 85 SyntaxElement::Token(token) => {
68 self.render_token(&token, out); 86 self.render_token(&token);
69 } 87 }
70 SyntaxElement::Node(child_node) => { 88 SyntaxElement::Node(child_node) => {
71 self.render_node(&child_node, out); 89 self.render_node(&child_node);
72 } 90 }
73 } 91 }
74 } 92 }
75 93
76 fn render_node(&self, node: &SyntaxNode, out: &mut String) { 94 fn render_node(&mut self, node: &SyntaxNode) {
77 use ra_syntax::ast::AstNode; 95 use ra_syntax::ast::AstNode;
78 if let Some(mod_path) = self.match_info.rendered_template_paths.get(&node) { 96 if let Some(mod_path) = self.match_info.rendered_template_paths.get(&node) {
79 out.push_str(&mod_path.to_string()); 97 self.out.push_str(&mod_path.to_string());
80 // Emit everything except for the segment's name-ref, since we already effectively 98 // Emit everything except for the segment's name-ref, since we already effectively
81 // emitted that as part of `mod_path`. 99 // emitted that as part of `mod_path`.
82 if let Some(path) = ast::Path::cast(node.clone()) { 100 if let Some(path) = ast::Path::cast(node.clone()) {
83 if let Some(segment) = path.segment() { 101 if let Some(segment) = path.segment() {
84 for node_or_token in segment.syntax().children_with_tokens() { 102 for node_or_token in segment.syntax().children_with_tokens() {
85 if node_or_token.kind() != SyntaxKind::NAME_REF { 103 if node_or_token.kind() != SyntaxKind::NAME_REF {
86 self.render_node_or_token(&node_or_token, out); 104 self.render_node_or_token(&node_or_token);
87 } 105 }
88 } 106 }
89 } 107 }
90 } 108 }
91 } else { 109 } else {
92 self.render_node_children(&node, out); 110 self.render_node_children(&node);
93 } 111 }
94 } 112 }
95 113
96 fn render_token(&self, token: &SyntaxToken, out: &mut String) { 114 fn render_token(&mut self, token: &SyntaxToken) {
97 if let Some(placeholder) = self.rule.get_placeholder(&token) { 115 if let Some(placeholder) = self.rule.get_placeholder(&token) {
98 if let Some(placeholder_value) = 116 if let Some(placeholder_value) =
99 self.match_info.placeholder_values.get(&Var(placeholder.ident.to_string())) 117 self.match_info.placeholder_values.get(&Var(placeholder.ident.to_string()))
@@ -107,8 +125,23 @@ impl ReplacementRenderer<'_> {
107 range.start(), 125 range.start(),
108 self.rules, 126 self.rules,
109 ); 127 );
128 let needs_parenthesis =
129 self.placeholder_tokens_requiring_parenthesis.contains(token);
110 edit.apply(&mut matched_text); 130 edit.apply(&mut matched_text);
111 out.push_str(&matched_text); 131 if needs_parenthesis {
132 self.out.push('(');
133 }
134 self.placeholder_tokens_by_range.insert(
135 TextRange::new(
136 TextSize::of(&self.out),
137 TextSize::of(&self.out) + TextSize::of(&matched_text),
138 ),
139 token.clone(),
140 );
141 self.out.push_str(&matched_text);
142 if needs_parenthesis {
143 self.out.push(')');
144 }
112 } else { 145 } else {
113 // We validated that all placeholder references were valid before we 146 // We validated that all placeholder references were valid before we
114 // started, so this shouldn't happen. 147 // started, so this shouldn't happen.
@@ -118,7 +151,44 @@ impl ReplacementRenderer<'_> {
118 ); 151 );
119 } 152 }
120 } else { 153 } else {
121 out.push_str(token.text().as_str()); 154 self.out.push_str(token.text().as_str());
155 }
156 }
157
158 // Checks if the resulting code, when parsed doesn't split any placeholders due to different
159 // order of operations between the search pattern and the replacement template. If any do, then
160 // we rerender the template and wrap the problematic placeholders with parenthesis.
161 fn maybe_rerender_with_extra_parenthesis(&mut self, template: &SyntaxNode) {
162 if let Some(node) = parse_as_kind(&self.out, template.kind()) {
163 self.remove_node_ranges(node);
164 if self.placeholder_tokens_by_range.is_empty() {
165 return;
166 }
167 self.placeholder_tokens_requiring_parenthesis =
168 self.placeholder_tokens_by_range.values().cloned().collect();
169 self.out.clear();
170 self.render_node(template);
171 }
172 }
173
174 fn remove_node_ranges(&mut self, node: SyntaxNode) {
175 self.placeholder_tokens_by_range.remove(&node.text_range());
176 for child in node.children() {
177 self.remove_node_ranges(child);
178 }
179 }
180}
181
182fn parse_as_kind(code: &str, kind: SyntaxKind) -> Option<SyntaxNode> {
183 use ra_syntax::ast::AstNode;
184 if ast::Expr::can_cast(kind) {
185 if let Ok(expr) = ast::Expr::parse(code) {
186 return Some(expr.syntax().clone());
187 }
188 } else if ast::Item::can_cast(kind) {
189 if let Ok(item) = ast::Item::parse(code) {
190 return Some(item.syntax().clone());
122 } 191 }
123 } 192 }
193 None
124} 194}
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_ssr/src/tests.rs b/crates/ra_ssr/src/tests.rs
index f5ffff7cc..a4fa2cb44 100644
--- a/crates/ra_ssr/src/tests.rs
+++ b/crates/ra_ssr/src/tests.rs
@@ -664,7 +664,7 @@ fn replace_binary_op() {
664 assert_ssr_transform( 664 assert_ssr_transform(
665 "$a + $b ==>> $b + $a", 665 "$a + $b ==>> $b + $a",
666 "fn f() {1 + 2 + 3 + 4}", 666 "fn f() {1 + 2 + 3 + 4}",
667 expect![["fn f() {4 + 3 + 2 + 1}"]], 667 expect![[r#"fn f() {4 + (3 + (2 + 1))}"#]],
668 ); 668 );
669} 669}
670 670
@@ -773,12 +773,33 @@ fn preserves_whitespace_within_macro_expansion() {
773 macro_rules! macro1 { 773 macro_rules! macro1 {
774 ($a:expr) => {$a} 774 ($a:expr) => {$a}
775 } 775 }
776 fn f() {macro1!(4 - 3 - 1 * 2} 776 fn f() {macro1!(4 - (3 - 1 * 2)}
777 "#]], 777 "#]],
778 ) 778 )
779} 779}
780 780
781#[test] 781#[test]
782fn add_parenthesis_when_necessary() {
783 assert_ssr_transform(
784 "foo($a) ==>> $a.to_string()",
785 r#"
786 fn foo(_: i32) {}
787 fn bar3(v: i32) {
788 foo(1 + 2);
789 foo(-v);
790 }
791 "#,
792 expect![[r#"
793 fn foo(_: i32) {}
794 fn bar3(v: i32) {
795 (1 + 2).to_string();
796 (-v).to_string();
797 }
798 "#]],
799 )
800}
801
802#[test]
782fn match_failure_reasons() { 803fn match_failure_reasons() {
783 let code = r#" 804 let code = r#"
784 fn bar() {} 805 fn bar() {}
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 3fd761367..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![;]) }
@@ -268,6 +268,36 @@ pub struct Rename {
268impl ast::NameOwner for Rename {} 268impl ast::NameOwner for Rename {}
269impl Rename { 269impl Rename {
270 pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) } 270 pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) }
271 pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) }
272}
273#[derive(Debug, Clone, PartialEq, Eq, Hash)]
274pub struct UseTree {
275 pub(crate) syntax: SyntaxNode,
276}
277impl UseTree {
278 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
279 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) }
280 pub fn star_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![*]) }
281 pub fn use_tree_list(&self) -> Option<UseTreeList> { support::child(&self.syntax) }
282 pub fn rename(&self) -> Option<Rename> { support::child(&self.syntax) }
283}
284#[derive(Debug, Clone, PartialEq, Eq, Hash)]
285pub struct Path {
286 pub(crate) syntax: SyntaxNode,
287}
288impl Path {
289 pub fn qualifier(&self) -> Option<Path> { support::child(&self.syntax) }
290 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) }
291 pub fn segment(&self) -> Option<PathSegment> { support::child(&self.syntax) }
292}
293#[derive(Debug, Clone, PartialEq, Eq, Hash)]
294pub struct UseTreeList {
295 pub(crate) syntax: SyntaxNode,
296}
297impl UseTreeList {
298 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
299 pub fn use_trees(&self) -> AstChildren<UseTree> { support::children(&self.syntax) }
300 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
271} 301}
272#[derive(Debug, Clone, PartialEq, Eq, Hash)] 302#[derive(Debug, Clone, PartialEq, Eq, Hash)]
273pub struct Abi { 303pub struct Abi {
@@ -433,15 +463,6 @@ impl PathType {
433 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } 463 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
434} 464}
435#[derive(Debug, Clone, PartialEq, Eq, Hash)] 465#[derive(Debug, Clone, PartialEq, Eq, Hash)]
436pub struct Path {
437 pub(crate) syntax: SyntaxNode,
438}
439impl Path {
440 pub fn qualifier(&self) -> Option<Path> { support::child(&self.syntax) }
441 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) }
442 pub fn segment(&self) -> Option<PathSegment> { support::child(&self.syntax) }
443}
444#[derive(Debug, Clone, PartialEq, Eq, Hash)]
445pub struct PointerType { 466pub struct PointerType {
446 pub(crate) syntax: SyntaxNode, 467 pub(crate) syntax: SyntaxNode,
447} 468}
@@ -1178,26 +1199,6 @@ impl Param {
1178 pub fn dotdotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![...]) } 1199 pub fn dotdotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![...]) }
1179} 1200}
1180#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1201#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1181pub struct UseTree {
1182 pub(crate) syntax: SyntaxNode,
1183}
1184impl UseTree {
1185 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1186 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) }
1187 pub fn star_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![*]) }
1188 pub fn use_tree_list(&self) -> Option<UseTreeList> { support::child(&self.syntax) }
1189 pub fn rename(&self) -> Option<Rename> { support::child(&self.syntax) }
1190}
1191#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1192pub struct UseTreeList {
1193 pub(crate) syntax: SyntaxNode,
1194}
1195impl UseTreeList {
1196 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
1197 pub fn use_trees(&self) -> AstChildren<UseTree> { support::children(&self.syntax) }
1198 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
1199}
1200#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1201pub struct PathSegment { 1202pub struct PathSegment {
1202 pub(crate) syntax: SyntaxNode, 1203 pub(crate) syntax: SyntaxNode,
1203} 1204}
@@ -1282,7 +1283,7 @@ pub enum Item {
1282 TraitDef(TraitDef), 1283 TraitDef(TraitDef),
1283 TypeAliasDef(TypeAliasDef), 1284 TypeAliasDef(TypeAliasDef),
1284 UnionDef(UnionDef), 1285 UnionDef(UnionDef),
1285 UseItem(UseItem), 1286 Use(Use),
1286} 1287}
1287impl ast::AttrsOwner for Item {} 1288impl ast::AttrsOwner for Item {}
1288#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1289#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -1561,8 +1562,8 @@ impl AstNode for UnionDef {
1561 } 1562 }
1562 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1563 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1563} 1564}
1564impl AstNode for UseItem { 1565impl AstNode for Use {
1565 fn can_cast(kind: SyntaxKind) -> bool { kind == USE_ITEM } 1566 fn can_cast(kind: SyntaxKind) -> bool { kind == USE }
1566 fn cast(syntax: SyntaxNode) -> Option<Self> { 1567 fn cast(syntax: SyntaxNode) -> Option<Self> {
1567 if Self::can_cast(syntax.kind()) { 1568 if Self::can_cast(syntax.kind()) {
1568 Some(Self { syntax }) 1569 Some(Self { syntax })
@@ -1627,6 +1628,39 @@ impl AstNode for Rename {
1627 } 1628 }
1628 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1629 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1629} 1630}
1631impl AstNode for UseTree {
1632 fn can_cast(kind: SyntaxKind) -> bool { kind == USE_TREE }
1633 fn cast(syntax: SyntaxNode) -> Option<Self> {
1634 if Self::can_cast(syntax.kind()) {
1635 Some(Self { syntax })
1636 } else {
1637 None
1638 }
1639 }
1640 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1641}
1642impl AstNode for Path {
1643 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH }
1644 fn cast(syntax: SyntaxNode) -> Option<Self> {
1645 if Self::can_cast(syntax.kind()) {
1646 Some(Self { syntax })
1647 } else {
1648 None
1649 }
1650 }
1651 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1652}
1653impl AstNode for UseTreeList {
1654 fn can_cast(kind: SyntaxKind) -> bool { kind == USE_TREE_LIST }
1655 fn cast(syntax: SyntaxNode) -> Option<Self> {
1656 if Self::can_cast(syntax.kind()) {
1657 Some(Self { syntax })
1658 } else {
1659 None
1660 }
1661 }
1662 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1663}
1630impl AstNode for Abi { 1664impl AstNode for Abi {
1631 fn can_cast(kind: SyntaxKind) -> bool { kind == ABI } 1665 fn can_cast(kind: SyntaxKind) -> bool { kind == ABI }
1632 fn cast(syntax: SyntaxNode) -> Option<Self> { 1666 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1825,17 +1859,6 @@ impl AstNode for PathType {
1825 } 1859 }
1826 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1860 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1827} 1861}
1828impl AstNode for Path {
1829 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH }
1830 fn cast(syntax: SyntaxNode) -> Option<Self> {
1831 if Self::can_cast(syntax.kind()) {
1832 Some(Self { syntax })
1833 } else {
1834 None
1835 }
1836 }
1837 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1838}
1839impl AstNode for PointerType { 1862impl AstNode for PointerType {
1840 fn can_cast(kind: SyntaxKind) -> bool { kind == POINTER_TYPE } 1863 fn can_cast(kind: SyntaxKind) -> bool { kind == POINTER_TYPE }
1841 fn cast(syntax: SyntaxNode) -> Option<Self> { 1864 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2672,28 +2695,6 @@ impl AstNode for Param {
2672 } 2695 }
2673 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2696 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2674} 2697}
2675impl AstNode for UseTree {
2676 fn can_cast(kind: SyntaxKind) -> bool { kind == USE_TREE }
2677 fn cast(syntax: SyntaxNode) -> Option<Self> {
2678 if Self::can_cast(syntax.kind()) {
2679 Some(Self { syntax })
2680 } else {
2681 None
2682 }
2683 }
2684 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2685}
2686impl AstNode for UseTreeList {
2687 fn can_cast(kind: SyntaxKind) -> bool { kind == USE_TREE_LIST }
2688 fn cast(syntax: SyntaxNode) -> Option<Self> {
2689 if Self::can_cast(syntax.kind()) {
2690 Some(Self { syntax })
2691 } else {
2692 None
2693 }
2694 }
2695 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2696}
2697impl AstNode for PathSegment { 2698impl AstNode for PathSegment {
2698 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_SEGMENT } 2699 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_SEGMENT }
2699 fn cast(syntax: SyntaxNode) -> Option<Self> { 2700 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2810,15 +2811,16 @@ impl From<TypeAliasDef> for Item {
2810impl From<UnionDef> for Item { 2811impl From<UnionDef> for Item {
2811 fn from(node: UnionDef) -> Item { Item::UnionDef(node) } 2812 fn from(node: UnionDef) -> Item { Item::UnionDef(node) }
2812} 2813}
2813impl From<UseItem> for Item { 2814impl From<Use> for Item {
2814 fn from(node: UseItem) -> Item { Item::UseItem(node) } 2815 fn from(node: Use) -> Item { Item::Use(node) }
2815} 2816}
2816impl AstNode for Item { 2817impl AstNode for Item {
2817 fn can_cast(kind: SyntaxKind) -> bool { 2818 fn can_cast(kind: SyntaxKind) -> bool {
2818 match kind { 2819 match kind {
2819 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
2820 | 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 => {
2821 | USE_ITEM => true, 2822 true
2823 }
2822 _ => false, 2824 _ => false,
2823 } 2825 }
2824 } 2826 }
@@ -2837,7 +2839,7 @@ impl AstNode for Item {
2837 TRAIT_DEF => Item::TraitDef(TraitDef { syntax }), 2839 TRAIT_DEF => Item::TraitDef(TraitDef { syntax }),
2838 TYPE_ALIAS_DEF => Item::TypeAliasDef(TypeAliasDef { syntax }), 2840 TYPE_ALIAS_DEF => Item::TypeAliasDef(TypeAliasDef { syntax }),
2839 UNION_DEF => Item::UnionDef(UnionDef { syntax }), 2841 UNION_DEF => Item::UnionDef(UnionDef { syntax }),
2840 USE_ITEM => Item::UseItem(UseItem { syntax }), 2842 USE => Item::Use(Use { syntax }),
2841 _ => return None, 2843 _ => return None,
2842 }; 2844 };
2843 Some(res) 2845 Some(res)
@@ -2857,7 +2859,7 @@ impl AstNode for Item {
2857 Item::TraitDef(it) => &it.syntax, 2859 Item::TraitDef(it) => &it.syntax,
2858 Item::TypeAliasDef(it) => &it.syntax, 2860 Item::TypeAliasDef(it) => &it.syntax,
2859 Item::UnionDef(it) => &it.syntax, 2861 Item::UnionDef(it) => &it.syntax,
2860 Item::UseItem(it) => &it.syntax, 2862 Item::Use(it) => &it.syntax,
2861 } 2863 }
2862 } 2864 }
2863} 2865}
@@ -3530,7 +3532,7 @@ impl std::fmt::Display for UnionDef {
3530 std::fmt::Display::fmt(self.syntax(), f) 3532 std::fmt::Display::fmt(self.syntax(), f)
3531 } 3533 }
3532} 3534}
3533impl std::fmt::Display for UseItem { 3535impl std::fmt::Display for Use {
3534 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3536 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3535 std::fmt::Display::fmt(self.syntax(), f) 3537 std::fmt::Display::fmt(self.syntax(), f)
3536 } 3538 }
@@ -3560,6 +3562,21 @@ impl std::fmt::Display for Rename {
3560 std::fmt::Display::fmt(self.syntax(), f) 3562 std::fmt::Display::fmt(self.syntax(), f)
3561 } 3563 }
3562} 3564}
3565impl std::fmt::Display for UseTree {
3566 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3567 std::fmt::Display::fmt(self.syntax(), f)
3568 }
3569}
3570impl std::fmt::Display for Path {
3571 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3572 std::fmt::Display::fmt(self.syntax(), f)
3573 }
3574}
3575impl std::fmt::Display for UseTreeList {
3576 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3577 std::fmt::Display::fmt(self.syntax(), f)
3578 }
3579}
3563impl std::fmt::Display for Abi { 3580impl std::fmt::Display for Abi {
3564 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3581 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3565 std::fmt::Display::fmt(self.syntax(), f) 3582 std::fmt::Display::fmt(self.syntax(), f)
@@ -3650,11 +3667,6 @@ impl std::fmt::Display for PathType {
3650 std::fmt::Display::fmt(self.syntax(), f) 3667 std::fmt::Display::fmt(self.syntax(), f)
3651 } 3668 }
3652} 3669}
3653impl std::fmt::Display for Path {
3654 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3655 std::fmt::Display::fmt(self.syntax(), f)
3656 }
3657}
3658impl std::fmt::Display for PointerType { 3670impl std::fmt::Display for PointerType {
3659 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3671 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3660 std::fmt::Display::fmt(self.syntax(), f) 3672 std::fmt::Display::fmt(self.syntax(), f)
@@ -4035,16 +4047,6 @@ impl std::fmt::Display for Param {
4035 std::fmt::Display::fmt(self.syntax(), f) 4047 std::fmt::Display::fmt(self.syntax(), f)
4036 } 4048 }
4037} 4049}
4038impl std::fmt::Display for UseTree {
4039 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4040 std::fmt::Display::fmt(self.syntax(), f)
4041 }
4042}
4043impl std::fmt::Display for UseTreeList {
4044 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4045 std::fmt::Display::fmt(self.syntax(), f)
4046 }
4047}
4048impl std::fmt::Display for PathSegment { 4050impl std::fmt::Display for PathSegment {
4049 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 4051 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4050 std::fmt::Display::fmt(self.syntax(), f) 4052 std::fmt::Display::fmt(self.syntax(), f)
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
diff --git a/crates/ra_syntax/test_data/parser/err/0002_duplicate_shebang.rast b/crates/ra_syntax/test_data/parser/err/0002_duplicate_shebang.rast
index 6717995e9..4cfd1bce4 100644
--- a/crates/ra_syntax/test_data/parser/err/0002_duplicate_shebang.rast
+++ b/crates/ra_syntax/test_data/parser/err/0002_duplicate_shebang.rast
@@ -6,7 +6,7 @@ [email protected]
6 [email protected] "!" 6 [email protected] "!"
7 [email protected] 7 [email protected]
8 [email protected] "/" 8 [email protected] "/"
9 USE_ITEM@24..28 9 [email protected]
10 [email protected] "use" 10 [email protected] "use"
11 [email protected] 11 [email protected]
12 [email protected] "/" 12 [email protected] "/"
diff --git a/crates/ra_syntax/test_data/parser/err/0004_use_path_bad_segment.rast b/crates/ra_syntax/test_data/parser/err/0004_use_path_bad_segment.rast
index b3bcf472a..9a0f4665e 100644
--- a/crates/ra_syntax/test_data/parser/err/0004_use_path_bad_segment.rast
+++ b/crates/ra_syntax/test_data/parser/err/0004_use_path_bad_segment.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 USE_ITEM@0..12 2 [email protected]
3 [email protected] "use" 3 [email protected] "use"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/err/0035_use_recover.rast b/crates/ra_syntax/test_data/parser/err/0035_use_recover.rast
index 9588cf3b3..0415085b0 100644
--- a/crates/ra_syntax/test_data/parser/err/0035_use_recover.rast
+++ b/crates/ra_syntax/test_data/parser/err/0035_use_recover.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 USE_ITEM@0..13 2 [email protected]
3 [email protected] "use" 3 [email protected] "use"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -14,10 +14,10 @@ [email protected]
14 [email protected] "bar" 14 [email protected] "bar"
15 [email protected] ";" 15 [email protected] ";"
16 [email protected] "\n" 16 [email protected] "\n"
17 USE_ITEM@14..17 17 [email protected]
18 [email protected] "use" 18 [email protected] "use"
19 [email protected] "\n" 19 [email protected] "\n"
20 USE_ITEM@18..33 20 [email protected]
21 [email protected] "use" 21 [email protected] "use"
22 [email protected] " " 22 [email protected] " "
23 [email protected] 23 [email protected]
@@ -31,7 +31,7 @@ [email protected]
31 [email protected] "baz" 31 [email protected] "baz"
32 [email protected] ";" 32 [email protected] ";"
33 [email protected] "\n" 33 [email protected] "\n"
34 USE_ITEM@34..37 34 [email protected]
35 [email protected] "use" 35 [email protected] "use"
36 [email protected] "\n" 36 [email protected] "\n"
37 [email protected] 37 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/err/0036_partial_use.rast b/crates/ra_syntax/test_data/parser/err/0036_partial_use.rast
index f926b67d2..ef6172f8a 100644
--- a/crates/ra_syntax/test_data/parser/err/0036_partial_use.rast
+++ b/crates/ra_syntax/test_data/parser/err/0036_partial_use.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 USE_ITEM@0..36 2 [email protected]
3 [email protected] "use" 3 [email protected] "use"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/err/0040_illegal_crate_kw_location.rast b/crates/ra_syntax/test_data/parser/err/0040_illegal_crate_kw_location.rast
index d2a549273..284c8715b 100644
--- a/crates/ra_syntax/test_data/parser/err/0040_illegal_crate_kw_location.rast
+++ b/crates/ra_syntax/test_data/parser/err/0040_illegal_crate_kw_location.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 USE_ITEM@0..12 2 [email protected]
3 [email protected] "use" 3 [email protected] "use"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -9,7 +9,7 @@ [email protected]
9 [email protected] "crate" 9 [email protected] "crate"
10 [email protected] ";" 10 [email protected] ";"
11 [email protected] "\n" 11 [email protected] "\n"
12 USE_ITEM@13..54 12 [email protected]
13 [email protected] "use" 13 [email protected] "use"
14 [email protected] " " 14 [email protected] " "
15 [email protected] 15 [email protected]
@@ -52,7 +52,7 @@ [email protected]
52 [email protected] "}" 52 [email protected] "}"
53 [email protected] ";" 53 [email protected] ";"
54 [email protected] "\n" 54 [email protected] "\n"
55 USE_ITEM@55..72 55 [email protected]
56 [email protected] "use" 56 [email protected] "use"
57 [email protected] " " 57 [email protected] " "
58 [email protected] 58 [email protected]
@@ -66,7 +66,7 @@ [email protected]
66 [email protected] "crate" 66 [email protected] "crate"
67 [email protected] ";" 67 [email protected] ";"
68 [email protected] "\n" 68 [email protected] "\n"
69 USE_ITEM@73..97 69 [email protected]
70 [email protected] "use" 70 [email protected] "use"
71 [email protected] " " 71 [email protected] " "
72 [email protected] 72 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/err/0041_illegal_super_keyword_location.rast b/crates/ra_syntax/test_data/parser/err/0041_illegal_super_keyword_location.rast
index d0360c467..2049a9d72 100644
--- a/crates/ra_syntax/test_data/parser/err/0041_illegal_super_keyword_location.rast
+++ b/crates/ra_syntax/test_data/parser/err/0041_illegal_super_keyword_location.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 USE_ITEM@0..12 2 [email protected]
3 [email protected] "use" 3 [email protected] "use"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -9,7 +9,7 @@ [email protected]
9 [email protected] "super" 9 [email protected] "super"
10 [email protected] ";" 10 [email protected] ";"
11 [email protected] "\n" 11 [email protected] "\n"
12 USE_ITEM@13..26 12 [email protected]
13 [email protected] "use" 13 [email protected] "use"
14 [email protected] " " 14 [email protected] " "
15 [email protected] 15 [email protected]
@@ -23,7 +23,7 @@ [email protected]
23 [email protected] "super" 23 [email protected] "super"
24 [email protected] ";" 24 [email protected] ";"
25 [email protected] "\n" 25 [email protected] "\n"
26 USE_ITEM@27..47 26 [email protected]
27 [email protected] "use" 27 [email protected] "use"
28 [email protected] " " 28 [email protected] " "
29 [email protected] 29 [email protected]
@@ -41,7 +41,7 @@ [email protected]
41 [email protected] "super" 41 [email protected] "super"
42 [email protected] ";" 42 [email protected] ";"
43 [email protected] "\n" 43 [email protected] "\n"
44 USE_ITEM@48..66 44 [email protected]
45 [email protected] "use" 45 [email protected] "use"
46 [email protected] " " 46 [email protected] " "
47 [email protected] 47 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/err/0042_illegal_self_keyword_location.rast b/crates/ra_syntax/test_data/parser/err/0042_illegal_self_keyword_location.rast
index 4f382b06c..deadf56b4 100644
--- a/crates/ra_syntax/test_data/parser/err/0042_illegal_self_keyword_location.rast
+++ b/crates/ra_syntax/test_data/parser/err/0042_illegal_self_keyword_location.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 USE_ITEM@0..11 2 [email protected]
3 [email protected] "use" 3 [email protected] "use"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -9,7 +9,7 @@ [email protected]
9 [email protected] "self" 9 [email protected] "self"
10 [email protected] ";" 10 [email protected] ";"
11 [email protected] "\n" 11 [email protected] "\n"
12 USE_ITEM@12..24 12 [email protected]
13 [email protected] "use" 13 [email protected] "use"
14 [email protected] " " 14 [email protected] " "
15 [email protected] 15 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/err/0015_empty_segment.rast b/crates/ra_syntax/test_data/parser/inline/err/0015_empty_segment.rast
index da8505607..2f59d0606 100644
--- a/crates/ra_syntax/test_data/parser/inline/err/0015_empty_segment.rast
+++ b/crates/ra_syntax/test_data/parser/inline/err/0015_empty_segment.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 USE_ITEM@0..12 2 [email protected]
3 [email protected] "use" 3 [email protected] "use"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0002_use_tree_list.rast b/crates/ra_syntax/test_data/parser/inline/ok/0002_use_tree_list.rast
index cf3a90400..1e80dd7e2 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0002_use_tree_list.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0002_use_tree_list.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 USE_ITEM@0..58 2 [email protected]
3 [email protected] "use" 3 [email protected] "use"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -51,7 +51,7 @@ [email protected]
51 [email protected] " " 51 [email protected] " "
52 [email protected] "// Rust 2018 (with a ..." 52 [email protected] "// Rust 2018 (with a ..."
53 [email protected] "\n" 53 [email protected] "\n"
54 USE_ITEM@98..121 54 [email protected]
55 [email protected] "use" 55 [email protected] "use"
56 [email protected] " " 56 [email protected] " "
57 [email protected] 57 [email protected]
@@ -77,7 +77,7 @@ [email protected]
77 [email protected] " " 77 [email protected] " "
78 [email protected] "// Rust 2015" 78 [email protected] "// Rust 2015"
79 [email protected] "\n" 79 [email protected] "\n"
80 USE_ITEM@135..166 80 [email protected]
81 [email protected] "use" 81 [email protected] "use"
82 [email protected] " " 82 [email protected] " "
83 [email protected] 83 [email protected]
@@ -104,7 +104,7 @@ [email protected]
104 [email protected] " " 104 [email protected] " "
105 [email protected] "// Rust 2015" 105 [email protected] "// Rust 2015"
106 [email protected] "\n" 106 [email protected] "\n"
107 USE_ITEM@180..205 107 [email protected]
108 [email protected] "use" 108 [email protected] "use"
109 [email protected] " " 109 [email protected] " "
110 [email protected] 110 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0020_use_star.rast b/crates/ra_syntax/test_data/parser/inline/ok/0020_use_star.rast
index 9e898b7b9..b3623c445 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0020_use_star.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0020_use_star.rast
@@ -1,12 +1,12 @@
1[email protected] 1[email protected]
2 USE_ITEM@0..6 2 [email protected]
3 [email protected] "use" 3 [email protected] "use"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "*" 6 [email protected] "*"
7 [email protected] ";" 7 [email protected] ";"
8 [email protected] "\n" 8 [email protected] "\n"
9 USE_ITEM@7..15 9 [email protected]
10 [email protected] "use" 10 [email protected] "use"
11 [email protected] " " 11 [email protected] " "
12 [email protected] 12 [email protected]
@@ -14,7 +14,7 @@ [email protected]
14 [email protected] "*" 14 [email protected] "*"
15 [email protected] ";" 15 [email protected] ";"
16 [email protected] "\n" 16 [email protected] "\n"
17 USE_ITEM@16..36 17 [email protected]
18 [email protected] "use" 18 [email protected] "use"
19 [email protected] " " 19 [email protected] " "
20 [email protected] 20 [email protected]
@@ -35,7 +35,7 @@ [email protected]
35 [email protected] "}" 35 [email protected] "}"
36 [email protected] ";" 36 [email protected] ";"
37 [email protected] "\n" 37 [email protected] "\n"
38 USE_ITEM@37..59 38 [email protected]
39 [email protected] "use" 39 [email protected] "use"
40 [email protected] " " 40 [email protected] " "
41 [email protected] 41 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0043_use_alias.rast b/crates/ra_syntax/test_data/parser/inline/ok/0043_use_alias.rast
index 8e9061e1d..60b517230 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0043_use_alias.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0043_use_alias.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 USE_ITEM@0..28 2 [email protected]
3 [email protected] "use" 3 [email protected] "use"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -20,7 +20,7 @@ [email protected]
20 [email protected] "some_name" 20 [email protected] "some_name"
21 [email protected] ";" 21 [email protected] ";"
22 [email protected] "\n" 22 [email protected] "\n"
23 USE_ITEM@29..181 23 [email protected]
24 [email protected] "use" 24 [email protected] "use"
25 [email protected] " " 25 [email protected] " "
26 [email protected] 26 [email protected]
@@ -121,7 +121,7 @@ [email protected]
121 [email protected] "}" 121 [email protected] "}"
122 [email protected] ";" 122 [email protected] ";"
123 [email protected] "\n" 123 [email protected] "\n"
124 USE_ITEM@182..197 124 [email protected]
125 [email protected] "use" 125 [email protected] "use"
126 [email protected] " " 126 [email protected] " "
127 [email protected] 127 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0067_crate_path.rast b/crates/ra_syntax/test_data/parser/inline/ok/0067_crate_path.rast
index caa76fe8a..702f2e0b0 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0067_crate_path.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0067_crate_path.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 USE_ITEM@0..15 2 [email protected]
3 [email protected] "use" 3 [email protected] "use"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0069_use_tree_list_after_path.rast b/crates/ra_syntax/test_data/parser/inline/ok/0069_use_tree_list_after_path.rast
index 18cd5271f..c4c5bc51e 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0069_use_tree_list_after_path.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0069_use_tree_list_after_path.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 USE_ITEM@0..18 2 [email protected]
3 [email protected] "use" 3 [email protected] "use"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -17,7 +17,7 @@ [email protected]
17 [email protected] "}" 17 [email protected] "}"
18 [email protected] ";" 18 [email protected] ";"
19 [email protected] "\n" 19 [email protected] "\n"
20 USE_ITEM@19..36 20 [email protected]
21 [email protected] "use" 21 [email protected] "use"
22 [email protected] " " 22 [email protected] " "
23 [email protected] 23 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0110_use_path.rast b/crates/ra_syntax/test_data/parser/inline/ok/0110_use_path.rast
index 015a7a7d2..82028096f 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0110_use_path.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0110_use_path.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 USE_ITEM@0..17 2 [email protected]
3 [email protected] "use" 3 [email protected] "use"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -12,7 +12,7 @@ [email protected]
12 [email protected] " " 12 [email protected] " "
13 [email protected] "// Rust 2018 - All fl ..." 13 [email protected] "// Rust 2018 - All fl ..."
14 [email protected] "\n" 14 [email protected] "\n"
15 USE_ITEM@46..61 15 [email protected]
16 [email protected] "use" 16 [email protected] "use"
17 [email protected] " " 17 [email protected] " "
18 [email protected] 18 [email protected]
@@ -24,7 +24,7 @@ [email protected]
24 [email protected] " " 24 [email protected] " "
25 [email protected] "// Rust 2018 - Anchor ..." 25 [email protected] "// Rust 2018 - Anchor ..."
26 [email protected] "\n" 26 [email protected] "\n"
27 USE_ITEM@92..124 27 [email protected]
28 [email protected] "use" 28 [email protected] "use"
29 [email protected] " " 29 [email protected] " "
30 [email protected] 30 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/ok/0009_use_item.rast b/crates/ra_syntax/test_data/parser/ok/0009_use_item.rast
index 96b8a94fc..6be1cf9fc 100644
--- a/crates/ra_syntax/test_data/parser/ok/0009_use_item.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0009_use_item.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 USE_ITEM@0..8 2 [email protected]
3 [email protected] "use" 3 [email protected] "use"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -9,7 +9,7 @@ [email protected]
9 [email protected] "foo" 9 [email protected] "foo"
10 [email protected] ";" 10 [email protected] ";"
11 [email protected] "\n" 11 [email protected] "\n"
12 USE_ITEM@9..19 12 [email protected]
13 [email protected] "use" 13 [email protected] "use"
14 [email protected] " " 14 [email protected] " "
15 [email protected] 15 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/ok/0010_use_path_segments.rast b/crates/ra_syntax/test_data/parser/ok/0010_use_path_segments.rast
index 07272dc3c..4d49e7933 100644
--- a/crates/ra_syntax/test_data/parser/ok/0010_use_path_segments.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0010_use_path_segments.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 USE_ITEM@0..20 2 [email protected]
3 [email protected] "use" 3 [email protected] "use"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -20,7 +20,7 @@ [email protected]
20 [email protected] "baz" 20 [email protected] "baz"
21 [email protected] ";" 21 [email protected] ";"
22 [email protected] "\n" 22 [email protected] "\n"
23 USE_ITEM@21..39 23 [email protected]
24 [email protected] "use" 24 [email protected] "use"
25 [email protected] " " 25 [email protected] " "
26 [email protected] 26 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/ok/0013_use_path_self_super.rast b/crates/ra_syntax/test_data/parser/ok/0013_use_path_self_super.rast
index 05d9c05ad..66ab13660 100644
--- a/crates/ra_syntax/test_data/parser/ok/0013_use_path_self_super.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0013_use_path_self_super.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 USE_ITEM@0..14 2 [email protected]
3 [email protected] "use" 3 [email protected] "use"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -13,7 +13,7 @@ [email protected]
13 [email protected] "foo" 13 [email protected] "foo"
14 [email protected] ";" 14 [email protected] ";"
15 [email protected] "\n" 15 [email protected] "\n"
16 USE_ITEM@15..37 16 [email protected]
17 [email protected] "use" 17 [email protected] "use"
18 [email protected] " " 18 [email protected] " "
19 [email protected] 19 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/ok/0014_use_tree.rast b/crates/ra_syntax/test_data/parser/ok/0014_use_tree.rast
index 3642c107b..4389d2d4b 100644
--- a/crates/ra_syntax/test_data/parser/ok/0014_use_tree.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0014_use_tree.rast
@@ -1,12 +1,12 @@
1[email protected] 1[email protected]
2 USE_ITEM@0..6 2 [email protected]
3 [email protected] "use" 3 [email protected] "use"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "*" 6 [email protected] "*"
7 [email protected] ";" 7 [email protected] ";"
8 [email protected] "\n" 8 [email protected] "\n"
9 USE_ITEM@7..15 9 [email protected]
10 [email protected] "use" 10 [email protected] "use"
11 [email protected] " " 11 [email protected] " "
12 [email protected] 12 [email protected]
@@ -14,7 +14,7 @@ [email protected]
14 [email protected] "*" 14 [email protected] "*"
15 [email protected] ";" 15 [email protected] ";"
16 [email protected] "\n" 16 [email protected] "\n"
17 USE_ITEM@16..25 17 [email protected]
18 [email protected] "use" 18 [email protected] "use"
19 [email protected] " " 19 [email protected] " "
20 [email protected] 20 [email protected]
@@ -24,7 +24,7 @@ [email protected]
24 [email protected] "}" 24 [email protected] "}"
25 [email protected] ";" 25 [email protected] ";"
26 [email protected] "\n" 26 [email protected] "\n"
27 USE_ITEM@26..33 27 [email protected]
28 [email protected] "use" 28 [email protected] "use"
29 [email protected] " " 29 [email protected] " "
30 [email protected] 30 [email protected]
@@ -33,7 +33,7 @@ [email protected]
33 [email protected] "}" 33 [email protected] "}"
34 [email protected] ";" 34 [email protected] ";"
35 [email protected] "\n" 35 [email protected] "\n"
36 USE_ITEM@34..45 36 [email protected]
37 [email protected] "use" 37 [email protected] "use"
38 [email protected] " " 38 [email protected] " "
39 [email protected] 39 [email protected]
@@ -45,7 +45,7 @@ [email protected]
45 [email protected] "*" 45 [email protected] "*"
46 [email protected] ";" 46 [email protected] ";"
47 [email protected] "\n" 47 [email protected] "\n"
48 USE_ITEM@46..58 48 [email protected]
49 [email protected] "use" 49 [email protected] "use"
50 [email protected] " " 50 [email protected] " "
51 [email protected] 51 [email protected]
@@ -59,7 +59,7 @@ [email protected]
59 [email protected] "}" 59 [email protected] "}"
60 [email protected] ";" 60 [email protected] ";"
61 [email protected] "\n" 61 [email protected] "\n"
62 USE_ITEM@59..80 62 [email protected]
63 [email protected] "use" 63 [email protected] "use"
64 [email protected] " " 64 [email protected] " "
65 [email protected] 65 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/ok/0015_use_tree.rast b/crates/ra_syntax/test_data/parser/ok/0015_use_tree.rast
index cdddb4214..d7e93f7eb 100644
--- a/crates/ra_syntax/test_data/parser/ok/0015_use_tree.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0015_use_tree.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 USE_ITEM@0..15 2 [email protected]
3 [email protected] "use" 3 [email protected] "use"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -15,7 +15,7 @@ [email protected]
15 [email protected] "bar" 15 [email protected] "bar"
16 [email protected] ";" 16 [email protected] ";"
17 [email protected] "\n" 17 [email protected] "\n"
18 USE_ITEM@16..54 18 [email protected]
19 [email protected] "use" 19 [email protected] "use"
20 [email protected] " " 20 [email protected] " "
21 [email protected] 21 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/ok/0035_weird_exprs.rast b/crates/ra_syntax/test_data/parser/ok/0035_weird_exprs.rast
index eb59d6e17..bbdf896d1 100644
--- a/crates/ra_syntax/test_data/parser/ok/0035_weird_exprs.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0035_weird_exprs.rast
@@ -78,7 +78,7 @@ [email protected]
78 [email protected] "\"128\"" 78 [email protected] "\"128\""
79 [email protected] "]" 79 [email protected] "]"
80 [email protected] "\n\n" 80 [email protected] "\n\n"
81 USE_ITEM@407..427 81 [email protected]
82 [email protected] "use" 82 [email protected] "use"
83 [email protected] " " 83 [email protected] " "
84 [email protected] 84 [email protected]
@@ -98,7 +98,7 @@ [email protected]
98 [email protected] "Cell" 98 [email protected] "Cell"
99 [email protected] ";" 99 [email protected] ";"
100 [email protected] "\n" 100 [email protected] "\n"
101 USE_ITEM@428..447 101 [email protected]
102 [email protected] "use" 102 [email protected] "use"
103 [email protected] " " 103 [email protected] " "
104 [email protected] 104 [email protected]