Skip to content

Commit 2426d42

Browse files
committed
fix: remove wrong comma after remove unnecessary braces
1 parent 3ce3593 commit 2426d42

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

crates/syntax/src/ast/node_ext.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,13 +345,20 @@ impl ast::UseTreeList {
345345
.is_some()
346346
}
347347

348+
pub fn comma(&self) -> impl Iterator<Item = SyntaxToken> {
349+
self.syntax()
350+
.children_with_tokens()
351+
.filter_map(|it| it.into_token().filter(|it| it.kind() == T![,]))
352+
}
353+
348354
/// Remove the unnecessary braces in current `UseTreeList`
349355
pub fn remove_unnecessary_braces(mut self) {
350356
let remove_brace_in_use_tree_list = |u: &ast::UseTreeList| {
351357
let use_tree_count = u.use_trees().count();
352358
if use_tree_count == 1 {
353359
u.l_curly_token().map(ted::remove);
354360
u.r_curly_token().map(ted::remove);
361+
u.comma().for_each(ted::remove);
355362
}
356363
};
357364

0 commit comments

Comments
 (0)