aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/path.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/path.rs')
-rw-r--r--crates/ra_hir/src/path.rs26
1 files changed, 13 insertions, 13 deletions
diff --git a/crates/ra_hir/src/path.rs b/crates/ra_hir/src/path.rs
index bce9d2d4b..882db7681 100644
--- a/crates/ra_hir/src/path.rs
+++ b/crates/ra_hir/src/path.rs
@@ -47,9 +47,9 @@ pub enum PathKind {
47 47
48impl Path { 48impl Path {
49 /// Calls `cb` with all paths, represented by this use item. 49 /// Calls `cb` with all paths, represented by this use item.
50 pub fn expand_use_item<'a>( 50 pub fn expand_use_item(
51 item: &'a ast::UseItem, 51 item: &ast::UseItem,
52 mut cb: impl FnMut(Path, &'a ast::UseTree, bool, Option<Name>), 52 mut cb: impl FnMut(Path, &ast::UseTree, bool, Option<Name>),
53 ) { 53 ) {
54 if let Some(tree) = item.use_tree() { 54 if let Some(tree) = item.use_tree() {
55 expand_use_tree(None, tree, &mut cb); 55 expand_use_tree(None, tree, &mut cb);
@@ -57,7 +57,7 @@ impl Path {
57 } 57 }
58 58
59 /// Converts an `ast::Path` to `Path`. Works with use trees. 59 /// Converts an `ast::Path` to `Path`. Works with use trees.
60 pub fn from_ast(mut path: &ast::Path) -> Option<Path> { 60 pub fn from_ast(mut path: ast::Path) -> Option<Path> {
61 let mut kind = PathKind::Plain; 61 let mut kind = PathKind::Plain;
62 let mut segments = Vec::new(); 62 let mut segments = Vec::new();
63 loop { 63 loop {
@@ -87,7 +87,7 @@ impl Path {
87 break; 87 break;
88 } 88 }
89 } 89 }
90 path = match qualifier(path) { 90 path = match qualifier(&path) {
91 Some(it) => it, 91 Some(it) => it,
92 None => break, 92 None => break,
93 }; 93 };
@@ -95,7 +95,7 @@ impl Path {
95 segments.reverse(); 95 segments.reverse();
96 return Some(Path { kind, segments }); 96 return Some(Path { kind, segments });
97 97
98 fn qualifier(path: &ast::Path) -> Option<&ast::Path> { 98 fn qualifier(path: &ast::Path) -> Option<ast::Path> {
99 if let Some(q) = path.qualifier() { 99 if let Some(q) = path.qualifier() {
100 return Some(q); 100 return Some(q);
101 } 101 }
@@ -136,7 +136,7 @@ impl Path {
136} 136}
137 137
138impl GenericArgs { 138impl GenericArgs {
139 pub(crate) fn from_ast(node: &ast::TypeArgList) -> Option<GenericArgs> { 139 pub(crate) fn from_ast(node: ast::TypeArgList) -> Option<GenericArgs> {
140 let mut args = Vec::new(); 140 let mut args = Vec::new();
141 for type_arg in node.type_args() { 141 for type_arg in node.type_args() {
142 let type_ref = TypeRef::from_ast_opt(type_arg.type_ref()); 142 let type_ref = TypeRef::from_ast_opt(type_arg.type_ref());
@@ -160,10 +160,10 @@ impl From<Name> for Path {
160 } 160 }
161} 161}
162 162
163fn expand_use_tree<'a>( 163fn expand_use_tree(
164 prefix: Option<Path>, 164 prefix: Option<Path>,
165 tree: &'a ast::UseTree, 165 tree: ast::UseTree,
166 cb: &mut impl FnMut(Path, &'a ast::UseTree, bool, Option<Name>), 166 cb: &mut impl FnMut(Path, &ast::UseTree, bool, Option<Name>),
167) { 167) {
168 if let Some(use_tree_list) = tree.use_tree_list() { 168 if let Some(use_tree_list) = tree.use_tree_list() {
169 let prefix = match tree.path() { 169 let prefix = match tree.path() {
@@ -188,7 +188,7 @@ fn expand_use_tree<'a>(
188 if let Some(segment) = ast_path.segment() { 188 if let Some(segment) = ast_path.segment() {
189 if segment.kind() == Some(ast::PathSegmentKind::SelfKw) { 189 if segment.kind() == Some(ast::PathSegmentKind::SelfKw) {
190 if let Some(prefix) = prefix { 190 if let Some(prefix) = prefix {
191 cb(prefix, tree, false, alias); 191 cb(prefix, &tree, false, alias);
192 return; 192 return;
193 } 193 }
194 } 194 }
@@ -196,7 +196,7 @@ fn expand_use_tree<'a>(
196 } 196 }
197 if let Some(path) = convert_path(prefix, ast_path) { 197 if let Some(path) = convert_path(prefix, ast_path) {
198 let is_glob = tree.has_star(); 198 let is_glob = tree.has_star();
199 cb(path, tree, is_glob, alias) 199 cb(path, &tree, is_glob, alias)
200 } 200 }
201 // FIXME: report errors somewhere 201 // FIXME: report errors somewhere
202 // We get here if we do 202 // We get here if we do
@@ -204,7 +204,7 @@ fn expand_use_tree<'a>(
204 } 204 }
205} 205}
206 206
207fn convert_path(prefix: Option<Path>, path: &ast::Path) -> Option<Path> { 207fn convert_path(prefix: Option<Path>, path: ast::Path) -> Option<Path> {
208 let prefix = 208 let prefix =
209 if let Some(qual) = path.qualifier() { Some(convert_path(prefix, qual)?) } else { prefix }; 209 if let Some(qual) = path.qualifier() { Some(convert_path(prefix, qual)?) } else { prefix };
210 let segment = path.segment()?; 210 let segment = path.segment()?;