mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
make ast::UseTree::wrap_in_tree_list
more robust
This commit is contained in:
parent
7219414e81
commit
da798bccf7
1 changed files with 8 additions and 3 deletions
|
@ -538,9 +538,13 @@ impl ast::UseTree {
|
||||||
/// `foo::bar` -> `{foo::bar}`
|
/// `foo::bar` -> `{foo::bar}`
|
||||||
///
|
///
|
||||||
/// `{foo::bar}` -> `{foo::bar}`
|
/// `{foo::bar}` -> `{foo::bar}`
|
||||||
pub fn wrap_in_tree_list(&self) {
|
pub fn wrap_in_tree_list(&self) -> Option<()> {
|
||||||
if self.path().is_none() {
|
if self.use_tree_list().is_some()
|
||||||
return;
|
&& self.path().is_none()
|
||||||
|
&& self.star_token().is_none()
|
||||||
|
&& self.rename().is_none()
|
||||||
|
{
|
||||||
|
return None;
|
||||||
}
|
}
|
||||||
let subtree = self.clone_subtree().clone_for_update();
|
let subtree = self.clone_subtree().clone_for_update();
|
||||||
ted::remove_all_iter(self.syntax().children_with_tokens());
|
ted::remove_all_iter(self.syntax().children_with_tokens());
|
||||||
|
@ -548,6 +552,7 @@ impl ast::UseTree {
|
||||||
self.syntax(),
|
self.syntax(),
|
||||||
make::use_tree_list(once(subtree)).clone_for_update().syntax(),
|
make::use_tree_list(once(subtree)).clone_for_update().syntax(),
|
||||||
);
|
);
|
||||||
|
Some(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue