Skip to content

Commit 2a32abb

Browse files
committed
Auto merge of #83681 - jyn514:blanket-impls-tweaks, r=Aaron1011
rustdoc: Only look at blanket impls in `get_blanket_impls` The idea here is that all the work in https://github.com/rust-lang/rust/blob/16156fb2787f745e57504197bd7fe38b69c6cbea/compiler/rustc_middle/src/ty/trait_def.rs#L172-L186 doesn't matter for `get_blanket_impls` - Rustdoc will already pick up on those blocks when it documents the item.
2 parents 6ff482b + 6f06b76 commit 2a32abb

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

compiler/rustc_middle/src/ty/trait_def.rs

+6
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ pub struct TraitImpls {
6969
non_blanket_impls: FxHashMap<fast_reject::SimplifiedType, Vec<DefId>>,
7070
}
7171

72+
impl TraitImpls {
73+
pub fn blanket_impls(&self) -> &[DefId] {
74+
self.blanket_impls.as_slice()
75+
}
76+
}
77+
7278
impl<'tcx> TraitDef {
7379
pub fn new(
7480
def_id: DefId,

src/librustdoc/clean/blanket_impl.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
2626
{
2727
continue;
2828
}
29-
self.cx.tcx.for_each_relevant_impl(trait_def_id, ty, |impl_def_id| {
29+
// NOTE: doesn't use `for_each_relevant_impl` to avoid looking at anything besides blanket impls
30+
let trait_impls = self.cx.tcx.trait_impls_of(trait_def_id);
31+
for &impl_def_id in trait_impls.blanket_impls() {
3032
debug!(
3133
"get_blanket_impls: Considering impl for trait '{:?}' {:?}",
3234
trait_def_id, impl_def_id
@@ -86,7 +88,7 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
8688
may_apply, trait_ref, ty
8789
);
8890
if !may_apply {
89-
return;
91+
continue;
9092
}
9193

9294
self.cx.generated_synthetics.insert((ty, trait_def_id));
@@ -127,7 +129,7 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
127129
blanket_impl: Some(trait_ref.self_ty().clean(self.cx)),
128130
}),
129131
});
130-
});
132+
}
131133
}
132134
impls
133135
}

0 commit comments

Comments
 (0)