about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2023-06-16 15:05:39 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2023-07-05 07:46:05 +0000
commit243687a37c9a0c3f9f6cc0d28ad1730efe53902c (patch)
treece19d80730afb3d1c71fe001660149040f3858b6
parent25e3785b8691e269e4e10bb8deeae0df205e22c1 (diff)
downloadrust-243687a37c9a0c3f9f6cc0d28ad1730efe53902c.tar.gz
rust-243687a37c9a0c3f9f6cc0d28ad1730efe53902c.zip
Prefer `retain` over hand-rolling an inefficient version of it
-rw-r--r--compiler/rustc_hir_analysis/src/astconv/object_safety.rs10
1 files changed, 3 insertions, 7 deletions
diff --git a/compiler/rustc_hir_analysis/src/astconv/object_safety.rs b/compiler/rustc_hir_analysis/src/astconv/object_safety.rs
index 4bdc33a1620..6232b1d2a23 100644
--- a/compiler/rustc_hir_analysis/src/astconv/object_safety.rs
+++ b/compiler/rustc_hir_analysis/src/astconv/object_safety.rs
@@ -235,13 +235,9 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
         }
 
         for def_ids in associated_types.values_mut() {
-            for def_id in def_ids.clone() {
-                // If the associated type has a `where Self: Sized` bound, we do not need to constrain the associated
-                // type in the `dyn Trait`.
-                if tcx.generics_require_sized_self(def_id) {
-                    def_ids.remove(&def_id);
-                }
-            }
+            // If the associated type has a `where Self: Sized` bound, we do not need to constrain the associated
+            // type in the `dyn Trait`.
+            def_ids.retain(|def_id| !tcx.generics_require_sized_self(def_id));
         }
 
         self.complain_about_missing_associated_types(