diff options
Diffstat (limited to 'crates/ra_hir/src/path.rs')
-rw-r--r-- | crates/ra_hir/src/path.rs | 12 |
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 | ||
19 | impl Path { | 19 | impl 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 | ||
101 | fn expand_use_tree( | 101 | fn 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 | ||
149 | fn convert_path(prefix: Option<Path>, path: ast::Path) -> Option<Path> { | 149 | fn 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 { |