use crate::core::DocContext;
use crate::formats::item_type::ItemType;
-type Attrs<'hir> = rustc_middle::ty::Attributes<'hir>;
+type Attrs<'hir> = &'hir [ast::Attribute];
/// Attempt to inline a definition into this AST.
///
Res::Def(DefKind::TyAlias, did) => {
record_extern_fqn(cx, did, ItemType::Typedef);
build_impls(cx, Some(parent_module), did, attrs, &mut ret);
- clean::TypedefItem(build_type_alias(cx, did), false)
+ clean::TypedefItem(build_type_alias(cx, did))
}
Res::Def(DefKind::Enum, did) => {
record_extern_fqn(cx, did, ItemType::Enum);
}
crate fn load_attrs<'hir>(cx: &DocContext<'hir>, did: DefId) -> Attrs<'hir> {
- cx.tcx.get_attrs(did)
+ cx.tcx.get_attrs_unchecked(did)
}
/// Record an external fully qualified name in the external_paths cache.
None => (
tcx.associated_items(did)
.in_definition_order()
- .filter_map(|item| {
- if associated_trait.is_some() || item.vis.is_public() {
- Some(item.clean(cx))
+ .filter(|item| {
+ // If this is a trait impl, filter out associated items whose corresponding item
+ // in the associated trait is marked `doc(hidden)`.
+ // If this is an inherent impl, filter out private associated items.
+ if let Some(associated_trait) = associated_trait {
+ let trait_item = tcx
+ .associated_items(associated_trait.def_id)
+ .find_by_name_and_kind(
+ tcx,
+ item.ident(tcx),
+ item.kind,
+ associated_trait.def_id,
+ )
+ .unwrap(); // corresponding associated item has to exist
+ !tcx.is_doc_hidden(trait_item.def_id)
} else {
- None
+ item.vis.is_public()
}
})
+ .map(|item| item.clean(cx))
.collect::<Vec<_>>(),
clean::enter_impl_trait(cx, |cx| {
clean_ty_generics(cx, tcx.generics_of(did), predicates)
items.push(clean::Item {
name: None,
attrs: box clean::Attributes::default(),
- def_id: ItemId::Primitive(prim_ty, did.krate),
+ item_id: ItemId::Primitive(prim_ty, did.krate),
visibility: clean::Public,
kind: box clean::ImportItem(clean::Import::new_simple(
item.ident.name,
let trait_ = clean::TraitWithExtraInfo {
trait_,
- is_notable: clean::utils::has_doc_flag(cx.tcx.get_attrs(did), sym::notable_trait),
+ is_notable: clean::utils::has_doc_flag(cx.tcx, did, sym::notable_trait),
};
cx.external_traits.borrow_mut().insert(did, trait_);
cx.active_extern_traits.remove(&did);