From bb1ee2f13a67342bdb09bcbf8684f6c9627b89e1 Mon Sep 17 00:00:00 2001 From: DJMcNab <36049421+DJMcNab@users.noreply.github.com> Date: Fri, 21 Dec 2018 23:01:16 +0000 Subject: Move the self handling from directly inside the loop --- crates/ra_hir/src/path.rs | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'crates/ra_hir/src') diff --git a/crates/ra_hir/src/path.rs b/crates/ra_hir/src/path.rs index 1b3fb4306..e04d00900 100644 --- a/crates/ra_hir/src/path.rs +++ b/crates/ra_hir/src/path.rs @@ -86,25 +86,22 @@ fn expand_use_tree( }, }; for child_tree in use_tree_list.use_trees() { + expand_use_tree(prefix.clone(), child_tree, cb); + } + } else { + if let Some(ast_path) = tree.path() { // Handle self in a path. // E.g. `use something::{self, <...>}` - if let Some(path) = child_tree.path() { - if path.qualifier().is_none() { - if let Some(segment) = path.segment() { - if segment.kind() == Some(ast::PathSegmentKind::SelfKw) { - /* TODO: Work out what on earth range means in this callback */ - if let Some(prefix) = prefix.clone() { - cb(prefix, Some(segment.syntax().range())); - continue; - } + if ast_path.qualifier().is_none() { + if let Some(segment) = ast_path.segment() { + if segment.kind() == Some(ast::PathSegmentKind::SelfKw) { + if let Some(prefix) = prefix { + cb(prefix, Some(segment.syntax().range())); + return; } } } } - expand_use_tree(prefix.clone(), child_tree, cb); - } - } else { - if let Some(ast_path) = tree.path() { if let Some(path) = convert_path(prefix, ast_path) { let range = if tree.has_star() { None @@ -114,6 +111,8 @@ fn expand_use_tree( }; cb(path, range) } + // TODO: report errors somewhere + // We get here if we do } } } -- cgit v1.2.3