Skip to content

Commit f2b58f3

Browse files
committed
clean-up for_each_impl to use all_impls
handle `impls_for_ref_x` and reduce duplication when iterating over all impls. also: use it in `for_each_relevant_impl_treating_projections`
1 parent a9d7810 commit f2b58f3

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

compiler/rustc_middle/src/ty/trait_def.rs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -105,18 +105,10 @@ impl<'tcx> TraitDef {
105105

106106
impl<'tcx> TyCtxt<'tcx> {
107107
/// `trait_def_id` MUST BE the `DefId` of a trait.
108-
pub fn for_each_impl<F: FnMut(DefId)>(self, trait_def_id: DefId, mut f: F) {
109-
let impls = self.trait_impls_of(trait_def_id);
110-
111-
for &impl_def_id in impls.blanket_impls.iter() {
108+
pub fn for_each_impl(self, trait_def_id: DefId, mut f: impl FnMut(DefId)) {
109+
for impl_def_id in self.all_impls(trait_def_id) {
112110
f(impl_def_id);
113111
}
114-
115-
for v in impls.non_blanket_impls.values() {
116-
for &impl_def_id in v {
117-
f(impl_def_id);
118-
}
119-
}
120112
}
121113

122114
/// Iterate over every impl that could possibly match the self type `self_ty`.
@@ -190,9 +182,7 @@ impl<'tcx> TyCtxt<'tcx> {
190182
}
191183
}
192184
} else {
193-
for impl_def_id in self.all_impls(trait_def_id) {
194-
f(impl_def_id);
195-
}
185+
self.for_each_impl(trait_def_id, f);
196186
}
197187
}
198188

0 commit comments

Comments
 (0)