Skip to content

Commit

Permalink
Auto merge of #83681 - jyn514:blanket-impls-tweaks, r=Aaron1011
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bors committed Mar 31, 2021
2 parents 6ff482b + 6f06b76 commit 2a32abb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 6 additions & 0 deletions compiler/rustc_middle/src/ty/trait_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ pub struct TraitImpls {
non_blanket_impls: FxHashMap<fast_reject::SimplifiedType, Vec<DefId>>,
}

impl TraitImpls {
pub fn blanket_impls(&self) -> &[DefId] {
self.blanket_impls.as_slice()
}
}

impl<'tcx> TraitDef {
pub fn new(
def_id: DefId,
Expand Down
8 changes: 5 additions & 3 deletions src/librustdoc/clean/blanket_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
{
continue;
}
self.cx.tcx.for_each_relevant_impl(trait_def_id, ty, |impl_def_id| {
// NOTE: doesn't use `for_each_relevant_impl` to avoid looking at anything besides blanket impls
let trait_impls = self.cx.tcx.trait_impls_of(trait_def_id);
for &impl_def_id in trait_impls.blanket_impls() {
debug!(
"get_blanket_impls: Considering impl for trait '{:?}' {:?}",
trait_def_id, impl_def_id
Expand Down Expand Up @@ -86,7 +88,7 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
may_apply, trait_ref, ty
);
if !may_apply {
return;
continue;
}

self.cx.generated_synthetics.insert((ty, trait_def_id));
Expand Down Expand Up @@ -127,7 +129,7 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
blanket_impl: Some(trait_ref.self_ty().clean(self.cx)),
}),
});
});
}
}
impls
}
Expand Down

0 comments on commit 2a32abb

Please sign in to comment.