aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/path.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-01-08 08:28:42 +0000
committerAleksey Kladov <[email protected]>2019-01-08 08:28:42 +0000
commitda0b348ae9f629c5cbe4a836a90ed85e36ca18e5 (patch)
tree614fd83f614632e3c87130117421708a7a028c13 /crates/ra_hir/src/path.rs
parentd6020f516f2826dac7188171241e9a72d6248cf8 (diff)
migrate ra_hir to rowan 2.0
Diffstat (limited to 'crates/ra_hir/src/path.rs')
-rw-r--r--crates/ra_hir/src/path.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/crates/ra_hir/src/path.rs b/crates/ra_hir/src/path.rs
index dcf4cf8b6..6f0b0da97 100644
--- a/crates/ra_hir/src/path.rs
+++ b/crates/ra_hir/src/path.rs
@@ -18,14 +18,14 @@ pub enum PathKind {
18 18
19impl Path { 19impl Path {
20 /// Calls `cb` with all paths, represented by this use item. 20 /// Calls `cb` with all paths, represented by this use item.
21 pub fn expand_use_item(item: ast::UseItem, mut cb: impl FnMut(Path, Option<TextRange>)) { 21 pub fn expand_use_item(item: &ast::UseItem, mut cb: impl FnMut(Path, Option<TextRange>)) {
22 if let Some(tree) = item.use_tree() { 22 if let Some(tree) = item.use_tree() {
23 expand_use_tree(None, tree, &mut cb); 23 expand_use_tree(None, tree, &mut cb);
24 } 24 }
25 } 25 }
26 26
27 /// Converts an `ast::Path` to `Path`. Works with use trees. 27 /// Converts an `ast::Path` to `Path`. Works with use trees.
28 pub fn from_ast(mut path: ast::Path) -> Option<Path> { 28 pub fn from_ast(mut path: &ast::Path) -> Option<Path> {
29 let mut kind = PathKind::Plain; 29 let mut kind = PathKind::Plain;
30 let mut segments = Vec::new(); 30 let mut segments = Vec::new();
31 loop { 31 loop {
@@ -53,7 +53,7 @@ impl Path {
53 segments.reverse(); 53 segments.reverse();
54 return Some(Path { kind, segments }); 54 return Some(Path { kind, segments });
55 55
56 fn qualifier(path: ast::Path) -> Option<ast::Path> { 56 fn qualifier(path: &ast::Path) -> Option<&ast::Path> {
57 if let Some(q) = path.qualifier() { 57 if let Some(q) = path.qualifier() {
58 return Some(q); 58 return Some(q);
59 } 59 }
@@ -66,7 +66,7 @@ impl Path {
66 } 66 }
67 67
68 /// Converts an `ast::NameRef` into a single-identifier `Path`. 68 /// Converts an `ast::NameRef` into a single-identifier `Path`.
69 pub fn from_name_ref(name_ref: ast::NameRef) -> Path { 69 pub fn from_name_ref(name_ref: &ast::NameRef) -> Path {
70 name_ref.as_name().into() 70 name_ref.as_name().into()
71 } 71 }
72 72
@@ -100,7 +100,7 @@ impl From<Name> for Path {
100 100
101fn expand_use_tree( 101fn expand_use_tree(
102 prefix: Option<Path>, 102 prefix: Option<Path>,
103 tree: ast::UseTree, 103 tree: &ast::UseTree,
104 cb: &mut impl FnMut(Path, Option<TextRange>), 104 cb: &mut impl FnMut(Path, Option<TextRange>),
105) { 105) {
106 if let Some(use_tree_list) = tree.use_tree_list() { 106 if let Some(use_tree_list) = tree.use_tree_list() {
@@ -146,7 +146,7 @@ fn expand_use_tree(
146 } 146 }
147} 147}
148 148
149fn convert_path(prefix: Option<Path>, path: ast::Path) -> Option<Path> { 149fn convert_path(prefix: Option<Path>, path: &ast::Path) -> Option<Path> {
150 let prefix = if let Some(qual) = path.qualifier() { 150 let prefix = if let Some(qual) = path.qualifier() {
151 Some(convert_path(prefix, qual)?) 151 Some(convert_path(prefix, qual)?)
152 } else { 152 } else {