mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-01 03:03:40 +00:00
Remove unnecessary provided_trait_methods
field from Impl
It can be calculated on-demand.
This commit is contained in:
parent
8a9fa3682d
commit
b1f5917930
@ -118,7 +118,6 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
|
||||
span: Span::dummy(),
|
||||
unsafety: hir::Unsafety::Normal,
|
||||
generics: new_generics,
|
||||
provided_trait_methods: Default::default(),
|
||||
trait_: Some(trait_ref.clean(self.cx).get_trait_type().unwrap()),
|
||||
for_: ty.clean(self.cx),
|
||||
items: Vec::new(),
|
||||
|
@ -92,12 +92,6 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
|
||||
}
|
||||
|
||||
self.cx.generated_synthetics.insert((ty, trait_def_id));
|
||||
let provided_trait_methods = self
|
||||
.cx
|
||||
.tcx
|
||||
.provided_trait_methods(trait_def_id)
|
||||
.map(|meth| meth.ident.name)
|
||||
.collect();
|
||||
|
||||
impls.push(Item {
|
||||
name: None,
|
||||
@ -112,7 +106,6 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
|
||||
self.cx.tcx.explicit_predicates_of(impl_def_id),
|
||||
)
|
||||
.clean(self.cx),
|
||||
provided_trait_methods,
|
||||
// FIXME(eddyb) compute both `trait_` and `for_` from
|
||||
// the post-inference `trait_ref`, as it's more accurate.
|
||||
trait_: Some(trait_ref.clean(self.cx).get_trait_type().unwrap()),
|
||||
|
@ -414,16 +414,10 @@ crate fn build_impl(
|
||||
record_extern_trait(cx, trait_did);
|
||||
}
|
||||
|
||||
let provided = trait_
|
||||
.def_id()
|
||||
.map(|did| tcx.provided_trait_methods(did).map(|meth| meth.ident.name).collect())
|
||||
.unwrap_or_default();
|
||||
|
||||
debug!("build_impl: impl {:?} for {:?}", trait_.def_id(), for_.def_id());
|
||||
|
||||
let (merged_attrs, cfg) = merge_attrs(cx, parent_module.into(), load_attrs(cx, did), attrs);
|
||||
debug!("merged_attrs={:?}", merged_attrs);
|
||||
|
||||
debug!("build_impl: impl {:?} for {:?}", trait_.def_id(), for_.def_id());
|
||||
ret.push(clean::Item::from_def_id_and_attrs_and_parts(
|
||||
did,
|
||||
None,
|
||||
@ -431,7 +425,6 @@ crate fn build_impl(
|
||||
span: clean::types::rustc_span(did, cx.tcx),
|
||||
unsafety: hir::Unsafety::Normal,
|
||||
generics,
|
||||
provided_trait_methods: provided,
|
||||
trait_,
|
||||
for_,
|
||||
items: trait_items,
|
||||
|
@ -1930,11 +1930,6 @@ fn clean_impl(impl_: &hir::Impl<'_>, hir_id: hir::HirId, cx: &mut DocContext<'_>
|
||||
build_deref_target_impls(cx, &items, &mut ret);
|
||||
}
|
||||
|
||||
let provided: FxHashSet<Symbol> = trait_
|
||||
.def_id()
|
||||
.map(|did| tcx.provided_trait_methods(did).map(|meth| meth.ident.name).collect())
|
||||
.unwrap_or_default();
|
||||
|
||||
let for_ = impl_.self_ty.clean(cx);
|
||||
let type_alias = for_.def_id().and_then(|did| match tcx.def_kind(did) {
|
||||
DefKind::TyAlias => Some(tcx.type_of(did).clean(cx)),
|
||||
@ -1945,7 +1940,6 @@ fn clean_impl(impl_: &hir::Impl<'_>, hir_id: hir::HirId, cx: &mut DocContext<'_>
|
||||
span: types::rustc_span(tcx.hir().local_def_id(hir_id).to_def_id(), tcx),
|
||||
unsafety: impl_.unsafety,
|
||||
generics: impl_.generics.clean(cx),
|
||||
provided_trait_methods: provided.clone(),
|
||||
trait_,
|
||||
for_,
|
||||
items,
|
||||
|
@ -2150,7 +2150,6 @@ crate struct Impl {
|
||||
crate span: Span,
|
||||
crate unsafety: hir::Unsafety,
|
||||
crate generics: Generics,
|
||||
crate provided_trait_methods: FxHashSet<Symbol>,
|
||||
crate trait_: Option<Type>,
|
||||
crate for_: Type,
|
||||
crate items: Vec<Item>,
|
||||
@ -2159,6 +2158,15 @@ crate struct Impl {
|
||||
crate blanket_impl: Option<Type>,
|
||||
}
|
||||
|
||||
impl Impl {
|
||||
crate fn provided_trait_methods(&self, tcx: TyCtxt<'_>) -> FxHashSet<Symbol> {
|
||||
self.trait_
|
||||
.def_id()
|
||||
.map(|did| tcx.provided_trait_methods(did).map(|meth| meth.ident.name).collect())
|
||||
.unwrap_or_default()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
crate struct Import {
|
||||
crate kind: ImportKind,
|
||||
|
@ -726,7 +726,8 @@ fn render_impls(
|
||||
.iter()
|
||||
.map(|i| {
|
||||
let did = i.trait_did_full(cache).unwrap();
|
||||
let assoc_link = AssocItemLink::GotoSource(did, &i.inner_impl().provided_trait_methods);
|
||||
let provided_trait_methods = i.inner_impl().provided_trait_methods(tcx);
|
||||
let assoc_link = AssocItemLink::GotoSource(did, &provided_trait_methods);
|
||||
let mut buffer = if w.is_for_html() { Buffer::html() } else { Buffer::new() };
|
||||
render_impl(
|
||||
&mut buffer,
|
||||
@ -1490,7 +1491,8 @@ fn render_impl(
|
||||
continue;
|
||||
}
|
||||
let did = i.trait_.as_ref().unwrap().def_id_full(cx.cache()).unwrap();
|
||||
let assoc_link = AssocItemLink::GotoSource(did, &i.provided_trait_methods);
|
||||
let provided_methods = i.provided_trait_methods(cx.tcx());
|
||||
let assoc_link = AssocItemLink::GotoSource(did, &provided_methods);
|
||||
|
||||
doc_impl_item(
|
||||
w,
|
||||
|
@ -669,10 +669,9 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
|
||||
write_small_section_header(w, "foreign-impls", "Implementations on Foreign Types", "");
|
||||
|
||||
for implementor in foreign {
|
||||
let assoc_link = AssocItemLink::GotoSource(
|
||||
implementor.impl_item.def_id,
|
||||
&implementor.inner_impl().provided_trait_methods,
|
||||
);
|
||||
let provided_methods = implementor.inner_impl().provided_trait_methods(cx.tcx());
|
||||
let assoc_link =
|
||||
AssocItemLink::GotoSource(implementor.impl_item.def_id, &provided_methods);
|
||||
render_impl(
|
||||
w,
|
||||
cx,
|
||||
|
@ -453,10 +453,10 @@ impl FromWithTcx<clean::Trait> for Trait {
|
||||
|
||||
impl FromWithTcx<clean::Impl> for Impl {
|
||||
fn from_tcx(impl_: clean::Impl, tcx: TyCtxt<'_>) -> Self {
|
||||
let provided_trait_methods = impl_.provided_trait_methods(tcx);
|
||||
let clean::Impl {
|
||||
unsafety,
|
||||
generics,
|
||||
provided_trait_methods,
|
||||
trait_,
|
||||
for_,
|
||||
items,
|
||||
|
Loading…
Reference in New Issue
Block a user