Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit da798bc

Browse files
committed
make ast::UseTree::wrap_in_tree_list more robust
1 parent 7219414 commit da798bc

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

crates/syntax/src/ast/edit_in_place.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -538,16 +538,21 @@ impl ast::UseTree {
538538
/// `foo::bar` -> `{foo::bar}`
539539
///
540540
/// `{foo::bar}` -> `{foo::bar}`
541-
pub fn wrap_in_tree_list(&self) {
542-
if self.path().is_none() {
543-
return;
541+
pub fn wrap_in_tree_list(&self) -> Option<()> {
542+
if self.use_tree_list().is_some()
543+
&& self.path().is_none()
544+
&& self.star_token().is_none()
545+
&& self.rename().is_none()
546+
{
547+
return None;
544548
}
545549
let subtree = self.clone_subtree().clone_for_update();
546550
ted::remove_all_iter(self.syntax().children_with_tokens());
547551
ted::append_child(
548552
self.syntax(),
549553
make::use_tree_list(once(subtree)).clone_for_update().syntax(),
550554
);
555+
Some(())
551556
}
552557
}
553558

0 commit comments

Comments
 (0)