mirror of https://github.com/rust-lang/rust.git
Move the self handling from directly inside the loop
This commit is contained in:
parent
d8d60215da
commit
bb1ee2f13a
|
@ -86,25 +86,22 @@ fn expand_use_tree(
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
for child_tree in use_tree_list.use_trees() {
|
for child_tree in use_tree_list.use_trees() {
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
expand_use_tree(prefix.clone(), child_tree, cb);
|
expand_use_tree(prefix.clone(), child_tree, cb);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if let Some(ast_path) = tree.path() {
|
if let Some(ast_path) = tree.path() {
|
||||||
|
// Handle self in a path.
|
||||||
|
// E.g. `use something::{self, <...>}`
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if let Some(path) = convert_path(prefix, ast_path) {
|
if let Some(path) = convert_path(prefix, ast_path) {
|
||||||
let range = if tree.has_star() {
|
let range = if tree.has_star() {
|
||||||
None
|
None
|
||||||
|
@ -114,6 +111,8 @@ fn expand_use_tree(
|
||||||
};
|
};
|
||||||
cb(path, range)
|
cb(path, range)
|
||||||
}
|
}
|
||||||
|
// TODO: report errors somewhere
|
||||||
|
// We get here if we do
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue