]> git.lizzy.rs Git - rust.git/commitdiff
Don't filter equal nodes in reorder assists
authorLukas Wirth <lukastw97@gmail.com>
Wed, 21 Apr 2021 22:54:31 +0000 (00:54 +0200)
committerLukas Wirth <lukastw97@gmail.com>
Wed, 21 Apr 2021 22:54:31 +0000 (00:54 +0200)
crates/ide_assists/src/handlers/reorder_fields.rs
crates/ide_assists/src/handlers/reorder_impl.rs

index 1a95135ca1dca8982bf19eff04f0f96c022f0eea..e90bbdbcf2678ca87f818ab772bda0dc7dc1028c 100644 (file)
@@ -83,11 +83,9 @@ fn replace<T: AstNode + PartialEq>(
     fields: impl Iterator<Item = T>,
     sorted_fields: impl IntoIterator<Item = T>,
 ) {
-    fields.zip(sorted_fields).filter(|(field, sorted)| field != sorted).for_each(
-        |(field, sorted_field)| {
-            ted::replace(field.syntax(), sorted_field.syntax().clone_for_update());
-        },
-    );
+    fields.zip(sorted_fields).for_each(|(field, sorted_field)| {
+        ted::replace(field.syntax(), sorted_field.syntax().clone_for_update())
+    });
 }
 
 fn compute_fields_ranks(path: &ast::Path, ctx: &AssistContext) -> Option<FxHashMap<String, usize>> {
index fd2897c4cc4425fa86f84a5f1d5d8b52938eb0b7..72d8892481c87b77306b0a4398b97b9499ada0cd 100644 (file)
@@ -79,11 +79,9 @@ pub(crate) fn reorder_impl(acc: &mut Assists, ctx: &AssistContext) -> Option<()>
         "Sort methods",
         target,
         |builder| {
-            for (old, new) in
-                methods.into_iter().zip(sorted).filter(|(field, sorted)| field != sorted)
-            {
-                ted::replace(builder.make_ast_mut(old).syntax(), new.clone_for_update().syntax());
-            }
+            methods.into_iter().zip(sorted).for_each(|(old, new)| {
+                ted::replace(builder.make_ast_mut(old).syntax(), new.clone_for_update().syntax())
+            });
         },
     )
 }