mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-22 02:00:00 +03:00
fix: remove wrong comma after remove unnecessary braces
This commit is contained in:
@@ -345,6 +345,12 @@ pub fn has_inner_comment(&self) -> bool {
|
||||
.is_some()
|
||||
}
|
||||
|
||||
pub fn comma(&self) -> impl Iterator<Item = SyntaxToken> {
|
||||
self.syntax()
|
||||
.children_with_tokens()
|
||||
.filter_map(|it| it.into_token().filter(|it| it.kind() == T![,]))
|
||||
}
|
||||
|
||||
/// Remove the unnecessary braces in current `UseTreeList`
|
||||
pub fn remove_unnecessary_braces(mut self) {
|
||||
let remove_brace_in_use_tree_list = |u: &ast::UseTreeList| {
|
||||
@@ -352,6 +358,7 @@ pub fn remove_unnecessary_braces(mut self) {
|
||||
if use_tree_count == 1 {
|
||||
u.l_curly_token().map(ted::remove);
|
||||
u.r_curly_token().map(ted::remove);
|
||||
u.comma().for_each(ted::remove);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user