Skip to content

Commit 243687a

Browse files
committed
Prefer retain over hand-rolling an inefficient version of it
1 parent 25e3785 commit 243687a

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

compiler/rustc_hir_analysis/src/astconv/object_safety.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -235,13 +235,9 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
235235
}
236236

237237
for def_ids in associated_types.values_mut() {
238-
for def_id in def_ids.clone() {
239-
// If the associated type has a `where Self: Sized` bound, we do not need to constrain the associated
240-
// type in the `dyn Trait`.
241-
if tcx.generics_require_sized_self(def_id) {
242-
def_ids.remove(&def_id);
243-
}
244-
}
238+
// If the associated type has a `where Self: Sized` bound, we do not need to constrain the associated
239+
// type in the `dyn Trait`.
240+
def_ids.retain(|def_id| !tcx.generics_require_sized_self(def_id));
245241
}
246242

247243
self.complain_about_missing_associated_types(

0 commit comments

Comments
 (0)