debug!("record_extern_trait: {:?}", did);
let trait_ = build_external_trait(cx, did);
- cx.external_traits
- .borrow_mut()
- .insert(did, (trait_, clean::utils::has_doc_flag(cx.tcx.get_attrs(did), sym::spotlight)));
+ cx.external_traits.borrow_mut().insert(
+ did,
+ clean::TraitWithExtraInfo {
+ trait_,
+ is_spotlight: clean::utils::has_doc_flag(cx.tcx.get_attrs(did), sym::spotlight),
+ },
+ );
cx.active_extern_traits.remove(&did);
}
crate primitives: Vec<(DefId, PrimitiveType)>,
// These are later on moved into `CACHEKEY`, leaving the map empty.
// Only here so that they can be filtered through the rustdoc passes.
- crate external_traits: Rc<RefCell<FxHashMap<DefId, (Trait, bool)>>>,
+ crate external_traits: Rc<RefCell<FxHashMap<DefId, TraitWithExtraInfo>>>,
crate masked_crates: FxHashSet<CrateNum>,
crate collapsed: bool,
}
+/// This struct is used to wrap additional information added by rustdoc on a `trait` item.
+#[derive(Clone, Debug)]
+crate struct TraitWithExtraInfo {
+ crate trait_: Trait,
+ crate is_spotlight: bool,
+}
+
#[derive(Clone, Debug)]
crate struct ExternalCrate {
crate name: Symbol,
/// Later on moved into `cache`
crate renderinfo: RenderInfo,
/// Later on moved through `clean::Crate` into `cache`
- crate external_traits: Rc<RefCell<FxHashMap<DefId, (clean::Trait, bool)>>>,
+ crate external_traits: Rc<RefCell<FxHashMap<DefId, clean::TraitWithExtraInfo>>>,
/// Used while populating `external_traits` to ensure we don't process the same trait twice at
/// the same time.
crate active_extern_traits: FxHashSet<DefId>,
{
let external_traits = { std::mem::take(&mut *c.external_traits.borrow_mut()) };
- for (k, (mut v, is_spotlight)) in external_traits {
- v.items = v.items.into_iter().filter_map(|i| self.fold_item(i)).collect();
- c.external_traits.borrow_mut().insert(k, (v, is_spotlight));
+ for (k, mut v) in external_traits {
+ v.trait_.items =
+ v.trait_.items.into_iter().filter_map(|i| self.fold_item(i)).collect();
+ c.external_traits.borrow_mut().insert(k, v);
}
}
c
/// Implementations of a crate should inherit the documentation of the
/// parent trait if no extra documentation is specified, and default methods
/// should show up in documentation about trait implementations.
- ///
- /// The `bool` parameter is about if the trait is `spotlight`.
- crate traits: FxHashMap<DefId, (clean::Trait, bool)>,
+ crate traits: FxHashMap<DefId, clean::TraitWithExtraInfo>,
/// When rendering traits, it's often useful to be able to list all
/// implementors of the trait, and this mapping is exactly, that: a mapping
// Propagate a trait method's documentation to all implementors of the
// trait.
if let clean::TraitItem(ref t) = *item.kind {
- self.cache.traits.entry(item.def_id).or_insert_with(|| {
- (t.clone(), clean::utils::has_doc_flag(tcx.get_attrs(item.def_id), sym::spotlight))
+ self.cache.traits.entry(item.def_id).or_insert_with(|| clean::TraitWithExtraInfo {
+ trait_: t.clone(),
+ is_spotlight: clean::utils::has_doc_flag(
+ tcx.get_attrs(item.def_id),
+ sym::spotlight,
+ ),
});
}
for i in impls {
let impl_ = i.inner_impl();
if impl_.trait_.def_id().map_or(false, |d| {
- cache.traits.get(&d).map(|(_, is_spotlight)| *is_spotlight).unwrap_or(false)
+ cache.traits.get(&d).map(|t| t.is_spotlight).unwrap_or(false)
}) {
if out.is_empty() {
write!(
false,
outer_version,
outer_const_version,
- trait_.map(|(t, _)| t),
+ trait_.map(|t| &t.trait_),
show_def_docs,
);
}
// We don't emit documentation for default items if they appear in the
// Implementations on Foreign Types or Implementors sections.
if show_default_items {
- if let Some((t, _)) = trait_ {
+ if let Some(t) = trait_ {
render_default_items(
w,
cx,
- t,
+ &t.trait_,
&i.inner_impl(),
&i.impl_item,
render_mode,
Rc::clone(&self.cache)
.traits
.iter()
- .filter_map(|(&id, (trait_item, _))| {
+ .filter_map(|(&id, trait_item)| {
// only need to synthesize items for external traits
if !id.is_local() {
+ let trait_item = &trait_item.trait_;
trait_item.items.clone().into_iter().for_each(|i| self.item(i).unwrap());
Some((
from_def_id(id),