Remove cache usage wherever possible
This commit is contained in:
parent
c448270099
commit
19630ead41
@ -368,7 +368,7 @@ crate fn build_impl(
|
||||
// Only inline impl if the implementing type is
|
||||
// reachable in rustdoc generated documentation
|
||||
if !did.is_local() {
|
||||
if let Some(did) = for_.def_id(&cx.cache) {
|
||||
if let Some(did) = for_.def_id() {
|
||||
if !cx.renderinfo.borrow().access_levels.is_public(did) {
|
||||
return;
|
||||
}
|
||||
@ -410,19 +410,19 @@ crate fn build_impl(
|
||||
clean::GenericBound::TraitBound(polyt, _) => polyt.trait_,
|
||||
clean::GenericBound::Outlives(..) => unreachable!(),
|
||||
});
|
||||
if trait_.def_id(&cx.cache) == tcx.lang_items().deref_trait() {
|
||||
if trait_.def_id() == tcx.lang_items().deref_trait() {
|
||||
super::build_deref_target_impls(cx, &trait_items, ret);
|
||||
}
|
||||
if let Some(trait_did) = trait_.def_id(&cx.cache) {
|
||||
if let Some(trait_did) = trait_.def_id() {
|
||||
record_extern_trait(cx, trait_did);
|
||||
}
|
||||
|
||||
let provided = trait_
|
||||
.def_id(&cx.cache)
|
||||
.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(&cx.cache), for_.def_id(&cx.cache));
|
||||
debug!("build_impl: impl {:?} for {:?}", trait_.def_id(), for_.def_id());
|
||||
|
||||
let mut item = clean::Item::from_def_id_and_parts(
|
||||
did,
|
||||
|
@ -2089,17 +2089,17 @@ fn clean_impl(impl_: &hir::Impl<'_>, hir_id: hir::HirId, cx: &DocContext<'_>) ->
|
||||
|
||||
// If this impl block is an implementation of the Deref trait, then we
|
||||
// need to try inlining the target's inherent impl blocks as well.
|
||||
if trait_.def_id(&cx.cache) == cx.tcx.lang_items().deref_trait() {
|
||||
if trait_.def_id() == cx.tcx.lang_items().deref_trait() {
|
||||
build_deref_target_impls(cx, &items, &mut ret);
|
||||
}
|
||||
|
||||
let provided: FxHashSet<Symbol> = trait_
|
||||
.def_id(&cx.cache)
|
||||
.def_id()
|
||||
.map(|did| cx.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(&cx.cache).and_then(|did| match cx.tcx.def_kind(did) {
|
||||
let type_alias = for_.def_id().and_then(|did| match cx.tcx.def_kind(did) {
|
||||
DefKind::TyAlias => Some(cx.tcx.type_of(did).clean(cx)),
|
||||
_ => None,
|
||||
});
|
||||
|
@ -958,7 +958,7 @@ impl GenericBound {
|
||||
crate fn is_sized_bound(&self, cx: &DocContext<'_>) -> bool {
|
||||
use rustc_hir::TraitBoundModifier as TBM;
|
||||
if let GenericBound::TraitBound(PolyTrait { ref trait_, .. }, TBM::None) = *self {
|
||||
if trait_.def_id(&cx.cache) == cx.tcx.lang_items().sized_trait() {
|
||||
if trait_.def_id() == cx.tcx.lang_items().sized_trait() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1171,9 +1171,16 @@ crate enum FnRetTy {
|
||||
}
|
||||
|
||||
impl GetDefId for FnRetTy {
|
||||
fn def_id(&self, cache: &Cache) -> Option<DefId> {
|
||||
fn def_id(&self) -> Option<DefId> {
|
||||
match *self {
|
||||
Return(ref ty) => ty.def_id(cache),
|
||||
Return(ref ty) => ty.def_id(),
|
||||
DefaultReturn => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn def_id_full(&self, cache: &Cache) -> Option<DefId> {
|
||||
match *self {
|
||||
Return(ref ty) => ty.def_id_full(cache),
|
||||
DefaultReturn => None,
|
||||
}
|
||||
}
|
||||
@ -1299,12 +1306,20 @@ crate enum TypeKind {
|
||||
}
|
||||
|
||||
crate trait GetDefId {
|
||||
fn def_id(&self, cache: &Cache) -> Option<DefId>;
|
||||
/// Doesn't retrieve primitive types `DefId`. Use `def_id_full` if you want it.
|
||||
fn def_id(&self) -> Option<DefId>;
|
||||
/// Retrieves all types' `DefId` (including primitives). If you're not interested about
|
||||
/// primitives, use `def_id`.
|
||||
fn def_id_full(&self, cache: &Cache) -> Option<DefId>;
|
||||
}
|
||||
|
||||
impl<T: GetDefId> GetDefId for Option<T> {
|
||||
fn def_id(&self, cache: &Cache) -> Option<DefId> {
|
||||
self.as_ref().and_then(|d| d.def_id(cache))
|
||||
fn def_id(&self) -> Option<DefId> {
|
||||
self.as_ref().and_then(|d| d.def_id())
|
||||
}
|
||||
|
||||
fn def_id_full(&self, cache: &Cache) -> Option<DefId> {
|
||||
self.as_ref().and_then(|d| d.def_id_full(cache))
|
||||
}
|
||||
}
|
||||
|
||||
@ -1393,33 +1408,50 @@ impl Type {
|
||||
}
|
||||
}
|
||||
|
||||
impl GetDefId for Type {
|
||||
fn def_id(&self, cache: &Cache) -> Option<DefId> {
|
||||
impl Type {
|
||||
fn inner_def_id(&self, cache: Option<&Cache>) -> Option<DefId> {
|
||||
fn inner<T: GetDefId>(t: &T, cache: Option<&Cache>) -> Option<DefId> {
|
||||
match cache {
|
||||
Some(c) => t.def_id_full(c),
|
||||
None => t.def_id(),
|
||||
}
|
||||
}
|
||||
|
||||
match *self {
|
||||
ResolvedPath { did, .. } => Some(did),
|
||||
Primitive(p) => cache.primitive_locations.get(&p).cloned(),
|
||||
Primitive(p) => cache.and_then(|c| c.primitive_locations.get(&p).cloned()),
|
||||
BorrowedRef { type_: box Generic(..), .. } => {
|
||||
Primitive(PrimitiveType::Reference).def_id(cache)
|
||||
inner(&Primitive(PrimitiveType::Reference), cache)
|
||||
}
|
||||
BorrowedRef { ref type_, .. } => type_.def_id(cache),
|
||||
BorrowedRef { ref type_, .. } => inner(&**type_, cache),
|
||||
Tuple(ref tys) => {
|
||||
if tys.is_empty() {
|
||||
Primitive(PrimitiveType::Unit).def_id(cache)
|
||||
inner(&Primitive(PrimitiveType::Unit), cache)
|
||||
} else {
|
||||
Primitive(PrimitiveType::Tuple).def_id(cache)
|
||||
inner(&Primitive(PrimitiveType::Tuple), cache)
|
||||
}
|
||||
}
|
||||
BareFunction(..) => Primitive(PrimitiveType::Fn).def_id(cache),
|
||||
Never => Primitive(PrimitiveType::Never).def_id(cache),
|
||||
Slice(..) => Primitive(PrimitiveType::Slice).def_id(cache),
|
||||
Array(..) => Primitive(PrimitiveType::Array).def_id(cache),
|
||||
RawPointer(..) => Primitive(PrimitiveType::RawPointer).def_id(cache),
|
||||
QPath { ref self_type, .. } => self_type.def_id(cache),
|
||||
BareFunction(..) => inner(&Primitive(PrimitiveType::Fn), cache),
|
||||
Never => inner(&Primitive(PrimitiveType::Never), cache),
|
||||
Slice(..) => inner(&Primitive(PrimitiveType::Slice), cache),
|
||||
Array(..) => inner(&Primitive(PrimitiveType::Array), cache),
|
||||
RawPointer(..) => inner(&Primitive(PrimitiveType::RawPointer), cache),
|
||||
QPath { ref self_type, .. } => inner(&**self_type, cache),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl GetDefId for Type {
|
||||
fn def_id(&self) -> Option<DefId> {
|
||||
self.inner_def_id(None)
|
||||
}
|
||||
|
||||
fn def_id_full(&self, cache: &Cache) -> Option<DefId> {
|
||||
self.inner_def_id(Some(cache))
|
||||
}
|
||||
}
|
||||
|
||||
impl PrimitiveType {
|
||||
crate fn from_hir(prim: hir::PrimTy) -> PrimitiveType {
|
||||
match prim {
|
||||
@ -1814,8 +1846,12 @@ crate struct Typedef {
|
||||
}
|
||||
|
||||
impl GetDefId for Typedef {
|
||||
fn def_id(&self, cache: &Cache) -> Option<DefId> {
|
||||
self.type_.def_id(cache)
|
||||
fn def_id(&self) -> Option<DefId> {
|
||||
self.type_.def_id()
|
||||
}
|
||||
|
||||
fn def_id_full(&self, cache: &Cache) -> Option<DefId> {
|
||||
self.type_.def_id_full(cache)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -179,9 +179,7 @@ crate fn get_real_types(
|
||||
if arg.is_full_generic() {
|
||||
let arg_s = Symbol::intern(&arg.print(&cx.cache).to_string());
|
||||
if let Some(where_pred) = generics.where_predicates.iter().find(|g| match g {
|
||||
WherePredicate::BoundPredicate { ty, .. } => {
|
||||
ty.def_id(&cx.cache) == arg.def_id(&cx.cache)
|
||||
}
|
||||
WherePredicate::BoundPredicate { ty, .. } => ty.def_id() == arg.def_id(),
|
||||
_ => false,
|
||||
}) {
|
||||
let bounds = where_pred.get_bounds().unwrap_or_else(|| &[]);
|
||||
@ -197,7 +195,7 @@ crate fn get_real_types(
|
||||
res.extend(adds);
|
||||
} else if !ty.is_full_generic() {
|
||||
if let Some(kind) =
|
||||
ty.def_id(&cx.cache).map(|did| cx.tcx.def_kind(did).clean(cx))
|
||||
ty.def_id().map(|did| cx.tcx.def_kind(did).clean(cx))
|
||||
{
|
||||
res.insert((ty, kind));
|
||||
}
|
||||
@ -214,9 +212,7 @@ crate fn get_real_types(
|
||||
if !adds.is_empty() {
|
||||
res.extend(adds);
|
||||
} else if !ty.is_full_generic() {
|
||||
if let Some(kind) =
|
||||
ty.def_id(&cx.cache).map(|did| cx.tcx.def_kind(did).clean(cx))
|
||||
{
|
||||
if let Some(kind) = ty.def_id().map(|did| cx.tcx.def_kind(did).clean(cx)) {
|
||||
res.insert((ty.clone(), kind));
|
||||
}
|
||||
}
|
||||
@ -224,7 +220,7 @@ crate fn get_real_types(
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if let Some(kind) = arg.def_id(&cx.cache).map(|did| cx.tcx.def_kind(did).clean(cx)) {
|
||||
if let Some(kind) = arg.def_id().map(|did| cx.tcx.def_kind(did).clean(cx)) {
|
||||
res.insert((arg.clone(), kind));
|
||||
}
|
||||
if let Some(gens) = arg.generics() {
|
||||
@ -234,9 +230,7 @@ crate fn get_real_types(
|
||||
if !adds.is_empty() {
|
||||
res.extend(adds);
|
||||
}
|
||||
} else if let Some(kind) =
|
||||
gen.def_id(&cx.cache).map(|did| cx.tcx.def_kind(did).clean(cx))
|
||||
{
|
||||
} else if let Some(kind) = gen.def_id().map(|did| cx.tcx.def_kind(did).clean(cx)) {
|
||||
res.insert((gen.clone(), kind));
|
||||
}
|
||||
}
|
||||
@ -263,9 +257,7 @@ crate fn get_all_types(
|
||||
if !args.is_empty() {
|
||||
all_types.extend(args);
|
||||
} else {
|
||||
if let Some(kind) =
|
||||
arg.type_.def_id(&cx.cache).map(|did| cx.tcx.def_kind(did).clean(cx))
|
||||
{
|
||||
if let Some(kind) = arg.type_.def_id().map(|did| cx.tcx.def_kind(did).clean(cx)) {
|
||||
all_types.insert((arg.type_.clone(), kind));
|
||||
}
|
||||
}
|
||||
@ -275,9 +267,7 @@ crate fn get_all_types(
|
||||
FnRetTy::Return(ref return_type) => {
|
||||
let mut ret = get_real_types(generics, &return_type, cx, 0);
|
||||
if ret.is_empty() {
|
||||
if let Some(kind) =
|
||||
return_type.def_id(&cx.cache).map(|did| cx.tcx.def_kind(did).clean(cx))
|
||||
{
|
||||
if let Some(kind) = return_type.def_id().map(|did| cx.tcx.def_kind(did).clean(cx)) {
|
||||
ret.insert((return_type.clone(), kind));
|
||||
}
|
||||
}
|
||||
|
@ -194,10 +194,7 @@ impl Cache {
|
||||
|
||||
cache.stack.push(krate.name.to_string());
|
||||
|
||||
krate = {
|
||||
let mut cache_wrapper = CacheWrapper { cache: &mut cache, tmp_cache: Cache::default() };
|
||||
cache_wrapper.fold_crate(krate)
|
||||
};
|
||||
krate = cache.fold_crate(krate);
|
||||
|
||||
for (trait_did, dids, impl_) in cache.orphan_trait_impls.drain(..) {
|
||||
if cache.traits.contains_key(&trait_did) {
|
||||
@ -211,15 +208,7 @@ impl Cache {
|
||||
}
|
||||
}
|
||||
|
||||
/// This struct is needed because we need to use an empty `Cache` for all functions requiring
|
||||
/// a `Cache`. If we use the already filled one (`cache` in here), it'll provide information
|
||||
/// about implementations that aren't related to the type being checked.
|
||||
struct CacheWrapper<'a> {
|
||||
cache: &'a mut Cache,
|
||||
tmp_cache: Cache,
|
||||
}
|
||||
|
||||
impl<'a> DocFolder for CacheWrapper<'a> {
|
||||
impl DocFolder for Cache {
|
||||
fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
|
||||
if item.def_id.is_local() {
|
||||
debug!("folding {} \"{:?}\", id {:?}", item.type_(), item.name, item.def_id);
|
||||
@ -229,21 +218,17 @@ impl<'a> DocFolder for CacheWrapper<'a> {
|
||||
// we don't want it or its children in the search index.
|
||||
let orig_stripped_mod = match *item.kind {
|
||||
clean::StrippedItem(box clean::ModuleItem(..)) => {
|
||||
mem::replace(&mut self.cache.stripped_mod, true)
|
||||
mem::replace(&mut self.stripped_mod, true)
|
||||
}
|
||||
_ => self.cache.stripped_mod,
|
||||
_ => self.stripped_mod,
|
||||
};
|
||||
|
||||
// If the impl is from a masked crate or references something from a
|
||||
// masked crate then remove it completely.
|
||||
if let clean::ImplItem(ref i) = *item.kind {
|
||||
if self.cache.masked_crates.contains(&item.def_id.krate)
|
||||
|| i.trait_
|
||||
.def_id(&self.tmp_cache)
|
||||
.map_or(false, |d| self.cache.masked_crates.contains(&d.krate))
|
||||
|| i.for_
|
||||
.def_id(&self.tmp_cache)
|
||||
.map_or(false, |d| self.cache.masked_crates.contains(&d.krate))
|
||||
if self.masked_crates.contains(&item.def_id.krate)
|
||||
|| i.trait_.def_id().map_or(false, |d| self.masked_crates.contains(&d.krate))
|
||||
|| i.for_.def_id().map_or(false, |d| self.masked_crates.contains(&d.krate))
|
||||
{
|
||||
return None;
|
||||
}
|
||||
@ -252,15 +237,14 @@ impl<'a> DocFolder for CacheWrapper<'a> {
|
||||
// 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());
|
||||
self.traits.entry(item.def_id).or_insert_with(|| t.clone());
|
||||
}
|
||||
|
||||
// Collect all the implementors of traits.
|
||||
if let clean::ImplItem(ref i) = *item.kind {
|
||||
if let Some(did) = i.trait_.def_id(&self.tmp_cache) {
|
||||
if let Some(did) = i.trait_.def_id() {
|
||||
if i.blanket_impl.is_none() {
|
||||
self.cache
|
||||
.implementors
|
||||
self.implementors
|
||||
.entry(did)
|
||||
.or_default()
|
||||
.push(Impl { impl_item: item.clone() });
|
||||
@ -273,7 +257,7 @@ impl<'a> DocFolder for CacheWrapper<'a> {
|
||||
let (parent, is_inherent_impl_item) = match *item.kind {
|
||||
clean::StrippedItem(..) => ((None, None), false),
|
||||
clean::AssocConstItem(..) | clean::TypedefItem(_, true)
|
||||
if self.cache.parent_is_trait_impl =>
|
||||
if self.parent_is_trait_impl =>
|
||||
{
|
||||
// skip associated items in trait impls
|
||||
((None, None), false)
|
||||
@ -283,18 +267,18 @@ impl<'a> DocFolder for CacheWrapper<'a> {
|
||||
| clean::StructFieldItem(..)
|
||||
| clean::VariantItem(..) => (
|
||||
(
|
||||
Some(*self.cache.parent_stack.last().expect("parent_stack is empty")),
|
||||
Some(&self.cache.stack[..self.cache.stack.len() - 1]),
|
||||
Some(*self.parent_stack.last().expect("parent_stack is empty")),
|
||||
Some(&self.stack[..self.stack.len() - 1]),
|
||||
),
|
||||
false,
|
||||
),
|
||||
clean::MethodItem(..) | clean::AssocConstItem(..) => {
|
||||
if self.cache.parent_stack.is_empty() {
|
||||
if self.parent_stack.is_empty() {
|
||||
((None, None), false)
|
||||
} else {
|
||||
let last = self.cache.parent_stack.last().expect("parent_stack is empty 2");
|
||||
let last = self.parent_stack.last().expect("parent_stack is empty 2");
|
||||
let did = *last;
|
||||
let path = match self.cache.paths.get(&did) {
|
||||
let path = match self.paths.get(&did) {
|
||||
// The current stack not necessarily has correlation
|
||||
// for where the type was defined. On the other
|
||||
// hand, `paths` always has the right
|
||||
@ -306,24 +290,24 @@ impl<'a> DocFolder for CacheWrapper<'a> {
|
||||
| ItemType::Union
|
||||
| ItemType::Enum,
|
||||
)) => Some(&fqp[..fqp.len() - 1]),
|
||||
Some(..) => Some(&*self.cache.stack),
|
||||
Some(..) => Some(&*self.stack),
|
||||
None => None,
|
||||
};
|
||||
((Some(*last), path), true)
|
||||
}
|
||||
}
|
||||
_ => ((None, Some(&*self.cache.stack)), false),
|
||||
_ => ((None, Some(&*self.stack)), false),
|
||||
};
|
||||
|
||||
match parent {
|
||||
(parent, Some(path)) if is_inherent_impl_item || !self.cache.stripped_mod => {
|
||||
(parent, Some(path)) if is_inherent_impl_item || !self.stripped_mod => {
|
||||
debug_assert!(!item.is_stripped());
|
||||
|
||||
// A crate has a module at its root, containing all items,
|
||||
// which should not be indexed. The crate-item itself is
|
||||
// inserted later on when serializing the search-index.
|
||||
if item.def_id.index != CRATE_DEF_INDEX {
|
||||
self.cache.search_index.push(IndexItem {
|
||||
self.search_index.push(IndexItem {
|
||||
ty: item.type_(),
|
||||
name: s.to_string(),
|
||||
path: path.join("::"),
|
||||
@ -332,22 +316,21 @@ impl<'a> DocFolder for CacheWrapper<'a> {
|
||||
.map_or_else(String::new, |x| short_markdown_summary(&x.as_str())),
|
||||
parent,
|
||||
parent_idx: None,
|
||||
search_type: get_index_search_type(&item, &self.tmp_cache),
|
||||
search_type: get_index_search_type(&item, None),
|
||||
});
|
||||
|
||||
for alias in item.attrs.get_doc_aliases() {
|
||||
self.cache
|
||||
.aliases
|
||||
self.aliases
|
||||
.entry(alias.to_lowercase())
|
||||
.or_insert(Vec::new())
|
||||
.push(self.cache.search_index.len() - 1);
|
||||
.push(self.search_index.len() - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
(Some(parent), None) if is_inherent_impl_item => {
|
||||
// We have a parent, but we don't know where they're
|
||||
// defined yet. Wait for later to index this item.
|
||||
self.cache.orphan_impl_items.push((parent, item.clone()));
|
||||
self.orphan_impl_items.push((parent, item.clone()));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
@ -356,7 +339,7 @@ impl<'a> DocFolder for CacheWrapper<'a> {
|
||||
// Keep track of the fully qualified path for this item.
|
||||
let pushed = match item.name {
|
||||
Some(n) if !n.is_empty() => {
|
||||
self.cache.stack.push(n.to_string());
|
||||
self.stack.push(n.to_string());
|
||||
true
|
||||
}
|
||||
_ => false,
|
||||
@ -378,7 +361,7 @@ impl<'a> DocFolder for CacheWrapper<'a> {
|
||||
| clean::MacroItem(..)
|
||||
| clean::ProcMacroItem(..)
|
||||
| clean::VariantItem(..)
|
||||
if !self.cache.stripped_mod =>
|
||||
if !self.stripped_mod =>
|
||||
{
|
||||
// Re-exported items mean that the same id can show up twice
|
||||
// in the rustdoc ast that we're looking at. We know,
|
||||
@ -386,21 +369,21 @@ impl<'a> DocFolder for CacheWrapper<'a> {
|
||||
// `public_items` map, so we can skip inserting into the
|
||||
// paths map if there was already an entry present and we're
|
||||
// not a public item.
|
||||
if !self.cache.paths.contains_key(&item.def_id)
|
||||
|| self.cache.access_levels.is_public(item.def_id)
|
||||
if !self.paths.contains_key(&item.def_id)
|
||||
|| self.access_levels.is_public(item.def_id)
|
||||
{
|
||||
self.cache.paths.insert(item.def_id, (self.cache.stack.clone(), item.type_()));
|
||||
self.paths.insert(item.def_id, (self.stack.clone(), item.type_()));
|
||||
}
|
||||
}
|
||||
clean::PrimitiveItem(..) => {
|
||||
self.cache.paths.insert(item.def_id, (self.cache.stack.clone(), item.type_()));
|
||||
self.paths.insert(item.def_id, (self.stack.clone(), item.type_()));
|
||||
}
|
||||
|
||||
_ => {}
|
||||
}
|
||||
|
||||
// Maintain the parent stack
|
||||
let orig_parent_is_trait_impl = self.cache.parent_is_trait_impl;
|
||||
let orig_parent_is_trait_impl = self.parent_is_trait_impl;
|
||||
let parent_pushed = match *item.kind {
|
||||
clean::TraitItem(..)
|
||||
| clean::EnumItem(..)
|
||||
@ -408,24 +391,24 @@ impl<'a> DocFolder for CacheWrapper<'a> {
|
||||
| clean::StructItem(..)
|
||||
| clean::UnionItem(..)
|
||||
| clean::VariantItem(..) => {
|
||||
self.cache.parent_stack.push(item.def_id);
|
||||
self.cache.parent_is_trait_impl = false;
|
||||
self.parent_stack.push(item.def_id);
|
||||
self.parent_is_trait_impl = false;
|
||||
true
|
||||
}
|
||||
clean::ImplItem(ref i) => {
|
||||
self.cache.parent_is_trait_impl = i.trait_.is_some();
|
||||
self.parent_is_trait_impl = i.trait_.is_some();
|
||||
match i.for_ {
|
||||
clean::ResolvedPath { did, .. } => {
|
||||
self.cache.parent_stack.push(did);
|
||||
self.parent_stack.push(did);
|
||||
true
|
||||
}
|
||||
ref t => {
|
||||
let prim_did = t
|
||||
.primitive_type()
|
||||
.and_then(|t| self.cache.primitive_locations.get(&t).cloned());
|
||||
.and_then(|t| self.primitive_locations.get(&t).cloned());
|
||||
match prim_did {
|
||||
Some(did) => {
|
||||
self.cache.parent_stack.push(did);
|
||||
self.parent_stack.push(did);
|
||||
true
|
||||
}
|
||||
None => false,
|
||||
@ -450,9 +433,8 @@ impl<'a> DocFolder for CacheWrapper<'a> {
|
||||
dids.insert(did);
|
||||
}
|
||||
ref t => {
|
||||
let did = t
|
||||
.primitive_type()
|
||||
.and_then(|t| self.cache.primitive_locations.get(&t).cloned());
|
||||
let did =
|
||||
t.primitive_type().and_then(|t| self.primitive_locations.get(&t).cloned());
|
||||
|
||||
if let Some(did) = did {
|
||||
dids.insert(did);
|
||||
@ -462,22 +444,19 @@ impl<'a> DocFolder for CacheWrapper<'a> {
|
||||
|
||||
if let Some(generics) = i.trait_.as_ref().and_then(|t| t.generics()) {
|
||||
for bound in generics {
|
||||
if let Some(did) = bound.def_id(&self.tmp_cache) {
|
||||
if let Some(did) = bound.def_id() {
|
||||
dids.insert(did);
|
||||
}
|
||||
}
|
||||
}
|
||||
let impl_item = Impl { impl_item: item };
|
||||
if impl_item
|
||||
.trait_did(&self.tmp_cache)
|
||||
.map_or(true, |d| self.cache.traits.contains_key(&d))
|
||||
{
|
||||
if impl_item.trait_did().map_or(true, |d| self.traits.contains_key(&d)) {
|
||||
for did in dids {
|
||||
self.cache.impls.entry(did).or_insert(vec![]).push(impl_item.clone());
|
||||
self.impls.entry(did).or_insert(vec![]).push(impl_item.clone());
|
||||
}
|
||||
} else {
|
||||
let trait_did = impl_item.trait_did(&self.tmp_cache).expect("no trait did");
|
||||
self.cache.orphan_trait_impls.push((trait_did, dids, impl_item));
|
||||
let trait_did = impl_item.trait_did().expect("no trait did");
|
||||
self.orphan_trait_impls.push((trait_did, dids, impl_item));
|
||||
}
|
||||
None
|
||||
} else {
|
||||
@ -485,13 +464,13 @@ impl<'a> DocFolder for CacheWrapper<'a> {
|
||||
};
|
||||
|
||||
if pushed {
|
||||
self.cache.stack.pop().expect("stack already empty");
|
||||
self.stack.pop().expect("stack already empty");
|
||||
}
|
||||
if parent_pushed {
|
||||
self.cache.parent_stack.pop().expect("parent stack already empty");
|
||||
self.parent_stack.pop().expect("parent stack already empty");
|
||||
}
|
||||
self.cache.stripped_mod = orig_stripped_mod;
|
||||
self.cache.parent_is_trait_impl = orig_parent_is_trait_impl;
|
||||
self.stripped_mod = orig_stripped_mod;
|
||||
self.parent_is_trait_impl = orig_parent_is_trait_impl;
|
||||
ret
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,11 @@ impl Impl {
|
||||
}
|
||||
}
|
||||
|
||||
crate fn trait_did(&self, cache: &Cache) -> Option<DefId> {
|
||||
self.inner_impl().trait_.def_id(cache)
|
||||
crate fn trait_did(&self) -> Option<DefId> {
|
||||
self.inner_impl().trait_.def_id()
|
||||
}
|
||||
|
||||
crate fn trait_did_full(&self, cache: &Cache) -> Option<DefId> {
|
||||
self.inner_impl().trait_.def_id_full(cache)
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ crate fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String {
|
||||
desc: item.doc_value().map_or_else(String::new, |s| short_markdown_summary(&s)),
|
||||
parent: Some(did),
|
||||
parent_idx: None,
|
||||
search_type: get_index_search_type(&item, cache),
|
||||
search_type: get_index_search_type(&item, Some(cache)),
|
||||
});
|
||||
for alias in item.attrs.get_doc_aliases() {
|
||||
cache
|
||||
@ -164,7 +164,10 @@ crate fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String {
|
||||
)
|
||||
}
|
||||
|
||||
crate fn get_index_search_type(item: &clean::Item, cache: &Cache) -> Option<IndexItemFunctionType> {
|
||||
crate fn get_index_search_type(
|
||||
item: &clean::Item,
|
||||
cache: Option<&Cache>,
|
||||
) -> Option<IndexItemFunctionType> {
|
||||
let (all_types, ret_types) = match *item.kind {
|
||||
clean::FunctionItem(ref f) => (&f.all_types, &f.ret_types),
|
||||
clean::MethodItem(ref m, _) => (&m.all_types, &m.ret_types),
|
||||
@ -174,12 +177,12 @@ crate fn get_index_search_type(item: &clean::Item, cache: &Cache) -> Option<Inde
|
||||
|
||||
let inputs = all_types
|
||||
.iter()
|
||||
.map(|(ty, kind)| TypeWithKind::from((get_index_type(&ty, cache), *kind)))
|
||||
.map(|(ty, kind)| TypeWithKind::from((get_index_type(&ty, &cache), *kind)))
|
||||
.filter(|a| a.ty.name.is_some())
|
||||
.collect();
|
||||
let output = ret_types
|
||||
.iter()
|
||||
.map(|(ty, kind)| TypeWithKind::from((get_index_type(&ty, cache), *kind)))
|
||||
.map(|(ty, kind)| TypeWithKind::from((get_index_type(&ty, &cache), *kind)))
|
||||
.filter(|a| a.ty.name.is_some())
|
||||
.collect::<Vec<_>>();
|
||||
let output = if output.is_empty() { None } else { Some(output) };
|
||||
@ -187,9 +190,9 @@ crate fn get_index_search_type(item: &clean::Item, cache: &Cache) -> Option<Inde
|
||||
Some(IndexItemFunctionType { inputs, output })
|
||||
}
|
||||
|
||||
fn get_index_type(clean_type: &clean::Type, cache: &Cache) -> RenderType {
|
||||
fn get_index_type(clean_type: &clean::Type, cache: &Option<&Cache>) -> RenderType {
|
||||
RenderType {
|
||||
ty: clean_type.def_id(cache),
|
||||
ty: cache.map_or_else(|| clean_type.def_id(), |cache| clean_type.def_id_full(cache)),
|
||||
idx: None,
|
||||
name: get_index_type_name(clean_type, true).map(|s| s.as_str().to_ascii_lowercase()),
|
||||
generics: get_generics(clean_type, cache),
|
||||
@ -216,14 +219,14 @@ fn get_index_type_name(clean_type: &clean::Type, accept_generic: bool) -> Option
|
||||
}
|
||||
}
|
||||
|
||||
fn get_generics(clean_type: &clean::Type, cache: &Cache) -> Option<Vec<Generic>> {
|
||||
fn get_generics(clean_type: &clean::Type, cache: &Option<&Cache>) -> Option<Vec<Generic>> {
|
||||
clean_type.generics().and_then(|types| {
|
||||
let r = types
|
||||
.iter()
|
||||
.filter_map(|t| {
|
||||
get_index_type_name(t, false).map(|name| Generic {
|
||||
name: name.as_str().to_ascii_lowercase(),
|
||||
defid: t.def_id(cache),
|
||||
defid: cache.map_or_else(|| t.def_id(), |cache| t.def_id_full(cache)),
|
||||
idx: None,
|
||||
})
|
||||
})
|
||||
|
@ -2515,7 +2515,7 @@ fn render_impls(
|
||||
let mut impls = traits
|
||||
.iter()
|
||||
.map(|i| {
|
||||
let did = i.trait_did(cx.cache()).unwrap();
|
||||
let did = i.trait_did_full(cx.cache()).unwrap();
|
||||
let assoc_link = AssocItemLink::GotoSource(did, &i.inner_impl().provided_trait_methods);
|
||||
let mut buffer = if w.is_for_html() { Buffer::html() } else { Buffer::new() };
|
||||
render_impl(
|
||||
@ -2755,7 +2755,10 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
|
||||
}
|
||||
|
||||
let (local, foreign) = implementors.iter().partition::<Vec<_>, _>(|i| {
|
||||
i.inner_impl().for_.def_id(cx.cache()).map_or(true, |d| cx.cache.paths.contains_key(&d))
|
||||
i.inner_impl()
|
||||
.for_
|
||||
.def_id_full(cx.cache())
|
||||
.map_or(true, |d| cx.cache.paths.contains_key(&d))
|
||||
});
|
||||
|
||||
let (mut synthetic, mut concrete): (Vec<&&Impl>, Vec<&&Impl>) =
|
||||
@ -3518,7 +3521,9 @@ fn render_assoc_items(
|
||||
"deref-methods-{:#}",
|
||||
type_.print(cx.cache())
|
||||
)));
|
||||
cx.deref_id_map.borrow_mut().insert(type_.def_id(cx.cache()).unwrap(), id.clone());
|
||||
cx.deref_id_map
|
||||
.borrow_mut()
|
||||
.insert(type_.def_id_full(cx.cache()).unwrap(), id.clone());
|
||||
write!(
|
||||
w,
|
||||
"<h2 id=\"{id}\" class=\"small-section-header\">\
|
||||
@ -3553,11 +3558,11 @@ fn render_assoc_items(
|
||||
if !traits.is_empty() {
|
||||
let deref_impl = traits
|
||||
.iter()
|
||||
.find(|t| t.inner_impl().trait_.def_id(cx.cache()) == cx.cache.deref_trait_did);
|
||||
.find(|t| t.inner_impl().trait_.def_id_full(cx.cache()) == cx.cache.deref_trait_did);
|
||||
if let Some(impl_) = deref_impl {
|
||||
let has_deref_mut = traits
|
||||
.iter()
|
||||
.any(|t| t.inner_impl().trait_.def_id(cx.cache()) == cx.cache.deref_mut_trait_did);
|
||||
let has_deref_mut = traits.iter().any(|t| {
|
||||
t.inner_impl().trait_.def_id_full(cx.cache()) == cx.cache.deref_mut_trait_did
|
||||
});
|
||||
render_deref_methods(w, cx, impl_, containing_item, has_deref_mut);
|
||||
}
|
||||
|
||||
@ -3636,8 +3641,8 @@ fn render_deref_methods(
|
||||
.expect("Expected associated type binding");
|
||||
let what =
|
||||
AssocItemRender::DerefFor { trait_: deref_type, type_: real_target, deref_mut_: deref_mut };
|
||||
if let Some(did) = target.def_id(cx.cache()) {
|
||||
if let Some(type_did) = impl_.inner_impl().for_.def_id(cx.cache()) {
|
||||
if let Some(did) = target.def_id_full(cx.cache()) {
|
||||
if let Some(type_did) = impl_.inner_impl().for_.def_id_full(cx.cache()) {
|
||||
// `impl Deref<Target = S> for S`
|
||||
if did == type_did {
|
||||
// Avoid infinite cycles
|
||||
@ -3684,11 +3689,11 @@ fn spotlight_decl(decl: &clean::FnDecl, c: &Cache) -> String {
|
||||
let mut out = Buffer::html();
|
||||
let mut trait_ = String::new();
|
||||
|
||||
if let Some(did) = decl.output.def_id(c) {
|
||||
if let Some(did) = decl.output.def_id_full(c) {
|
||||
if let Some(impls) = c.impls.get(&did) {
|
||||
for i in impls {
|
||||
let impl_ = i.inner_impl();
|
||||
if impl_.trait_.def_id(c).map_or(false, |d| c.traits[&d].is_spotlight) {
|
||||
if impl_.trait_.def_id_full(c).map_or(false, |d| c.traits[&d].is_spotlight) {
|
||||
if out.is_empty() {
|
||||
out.push_str(&format!(
|
||||
"<h3 class=\"notable\">Notable traits for {}</h3>\
|
||||
@ -3703,7 +3708,7 @@ fn spotlight_decl(decl: &clean::FnDecl, c: &Cache) -> String {
|
||||
"<span class=\"where fmt-newline\">{}</span>",
|
||||
impl_.print(c)
|
||||
));
|
||||
let t_did = impl_.trait_.def_id(c).unwrap();
|
||||
let t_did = impl_.trait_.def_id_full(c).unwrap();
|
||||
for it in &impl_.items {
|
||||
if let clean::TypedefItem(ref tydef, _) = *it.kind {
|
||||
out.push_str("<span class=\"where fmt-newline\"> ");
|
||||
@ -3754,7 +3759,7 @@ fn render_impl(
|
||||
aliases: &[String],
|
||||
) {
|
||||
let traits = &cx.cache.traits;
|
||||
let trait_ = i.trait_did(cx.cache()).map(|did| &traits[&did]);
|
||||
let trait_ = i.trait_did_full(cx.cache()).map(|did| &traits[&did]);
|
||||
|
||||
if render_mode == RenderMode::Normal {
|
||||
let id = cx.derive_id(match i.inner_impl().trait_ {
|
||||
@ -3998,7 +4003,7 @@ fn render_impl(
|
||||
if i.items.iter().any(|m| m.name == n) {
|
||||
continue;
|
||||
}
|
||||
let did = i.trait_.as_ref().unwrap().def_id(cx.cache()).unwrap();
|
||||
let did = i.trait_.as_ref().unwrap().def_id_full(cx.cache()).unwrap();
|
||||
let assoc_link = AssocItemLink::GotoSource(did, &i.provided_trait_methods);
|
||||
|
||||
doc_impl_item(
|
||||
@ -4309,7 +4314,7 @@ fn sidebar_assoc_items(cx: &Context<'_>, it: &clean::Item) -> String {
|
||||
if let Some(impl_) = v
|
||||
.iter()
|
||||
.filter(|i| i.inner_impl().trait_.is_some())
|
||||
.find(|i| i.inner_impl().trait_.def_id(cx.cache()) == cx.cache.deref_trait_did)
|
||||
.find(|i| i.inner_impl().trait_.def_id_full(cx.cache()) == cx.cache.deref_trait_did)
|
||||
{
|
||||
out.push_str(&sidebar_deref_methods(cx, impl_, v));
|
||||
}
|
||||
@ -4396,9 +4401,9 @@ fn sidebar_deref_methods(cx: &Context<'_>, impl_: &Impl, v: &Vec<Impl>) -> Strin
|
||||
let deref_mut = v
|
||||
.iter()
|
||||
.filter(|i| i.inner_impl().trait_.is_some())
|
||||
.any(|i| i.inner_impl().trait_.def_id(cx.cache()) == c.deref_mut_trait_did);
|
||||
.any(|i| i.inner_impl().trait_.def_id_full(cx.cache()) == c.deref_mut_trait_did);
|
||||
let inner_impl = target
|
||||
.def_id(cx.cache())
|
||||
.def_id_full(cx.cache())
|
||||
.or_else(|| {
|
||||
target.primitive_type().and_then(|prim| c.primitive_locations.get(&prim).cloned())
|
||||
})
|
||||
@ -4414,7 +4419,7 @@ fn sidebar_deref_methods(cx: &Context<'_>, impl_: &Impl, v: &Vec<Impl>) -> Strin
|
||||
if !ret.is_empty() {
|
||||
let deref_id_map = cx.deref_id_map.borrow();
|
||||
let id = deref_id_map
|
||||
.get(&real_target.def_id(cx.cache()).unwrap())
|
||||
.get(&real_target.def_id_full(cx.cache()).unwrap())
|
||||
.expect("Deref section without derived id");
|
||||
out.push_str(&format!(
|
||||
"<a class=\"sidebar-title\" href=\"#{}\">Methods from {}<Target={}></a>",
|
||||
@ -4429,14 +4434,14 @@ fn sidebar_deref_methods(cx: &Context<'_>, impl_: &Impl, v: &Vec<Impl>) -> Strin
|
||||
}
|
||||
|
||||
// Recurse into any further impls that might exist for `target`
|
||||
if let Some(target_did) = target.def_id(cx.cache()) {
|
||||
if let Some(target_did) = target.def_id_full(cx.cache()) {
|
||||
if let Some(target_impls) = c.impls.get(&target_did) {
|
||||
if let Some(target_deref_impl) = target_impls
|
||||
.iter()
|
||||
.filter(|i| i.inner_impl().trait_.is_some())
|
||||
.find(|i| i.inner_impl().trait_.def_id(cx.cache()) == c.deref_trait_did)
|
||||
.find(|i| i.inner_impl().trait_.def_id_full(cx.cache()) == c.deref_trait_did)
|
||||
{
|
||||
if let Some(type_did) = impl_.inner_impl().for_.def_id(cx.cache()) {
|
||||
if let Some(type_did) = impl_.inner_impl().for_.def_id_full(cx.cache()) {
|
||||
// `impl Deref<Target = S> for S`
|
||||
if target_did == type_did {
|
||||
// Avoid infinite cycles
|
||||
@ -4580,7 +4585,7 @@ fn sidebar_trait(cx: &Context<'_>, buf: &mut Buffer, it: &clean::Item, t: &clean
|
||||
.filter(|i| {
|
||||
i.inner_impl()
|
||||
.for_
|
||||
.def_id(cx.cache())
|
||||
.def_id_full(cx.cache())
|
||||
.map_or(false, |d| !cx.cache.paths.contains_key(&d))
|
||||
})
|
||||
.filter_map(|i| extract_for_impl_name(&i.impl_item, cx.cache()))
|
||||
|
@ -2,7 +2,6 @@ use super::Pass;
|
||||
use crate::clean::*;
|
||||
use crate::core::DocContext;
|
||||
use crate::fold::DocFolder;
|
||||
use crate::formats::cache::Cache;
|
||||
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
|
||||
@ -97,12 +96,12 @@ crate fn collect_trait_impls(krate: Crate, cx: &DocContext<'_>) -> Crate {
|
||||
// Gather all type to `Deref` target edges.
|
||||
for it in &new_items {
|
||||
if let ImplItem(Impl { ref for_, ref trait_, ref items, .. }) = *it.kind {
|
||||
if trait_.def_id(&cx.cache) == cx.tcx.lang_items().deref_trait() {
|
||||
if trait_.def_id() == cx.tcx.lang_items().deref_trait() {
|
||||
let target = items.iter().find_map(|item| match *item.kind {
|
||||
TypedefItem(ref t, true) => Some(&t.type_),
|
||||
_ => None,
|
||||
});
|
||||
if let (Some(for_did), Some(target)) = (for_.def_id(&cx.cache), target) {
|
||||
if let (Some(for_did), Some(target)) = (for_.def_id(), target) {
|
||||
type_did_to_deref_target.insert(for_did, target);
|
||||
}
|
||||
}
|
||||
@ -113,20 +112,19 @@ crate fn collect_trait_impls(krate: Crate, cx: &DocContext<'_>) -> Crate {
|
||||
map: &FxHashMap<DefId, &Type>,
|
||||
cleaner: &mut BadImplStripper,
|
||||
type_did: &DefId,
|
||||
cache: &Cache,
|
||||
) {
|
||||
if let Some(target) = map.get(type_did) {
|
||||
debug!("add_deref_target: type {:?}, target {:?}", type_did, target);
|
||||
if let Some(target_prim) = target.primitive_type() {
|
||||
cleaner.prims.insert(target_prim);
|
||||
} else if let Some(target_did) = target.def_id(cache) {
|
||||
} else if let Some(target_did) = target.def_id() {
|
||||
// `impl Deref<Target = S> for S`
|
||||
if target_did == *type_did {
|
||||
// Avoid infinite cycles
|
||||
return;
|
||||
}
|
||||
cleaner.items.insert(target_did);
|
||||
add_deref_target(map, cleaner, &target_did, cache);
|
||||
add_deref_target(map, cleaner, &target_did);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -135,14 +133,14 @@ crate fn collect_trait_impls(krate: Crate, cx: &DocContext<'_>) -> Crate {
|
||||
// `Deref` target type and the impl for type positions, this map of types is keyed by
|
||||
// `DefId` and for convenience uses a special cleaner that accepts `DefId`s directly.
|
||||
if cleaner.keep_impl_with_def_id(type_did) {
|
||||
add_deref_target(&type_did_to_deref_target, &mut cleaner, type_did, &cx.cache);
|
||||
add_deref_target(&type_did_to_deref_target, &mut cleaner, type_did);
|
||||
}
|
||||
}
|
||||
|
||||
new_items.retain(|it| {
|
||||
if let ImplItem(Impl { ref for_, ref trait_, ref blanket_impl, .. }) = *it.kind {
|
||||
cleaner.keep_impl(for_, &cx.cache)
|
||||
|| trait_.as_ref().map_or(false, |t| cleaner.keep_impl(t, &cx.cache))
|
||||
cleaner.keep_impl(for_)
|
||||
|| trait_.as_ref().map_or(false, |t| cleaner.keep_impl(t))
|
||||
|| blanket_impl.is_some()
|
||||
} else {
|
||||
true
|
||||
@ -218,13 +216,13 @@ struct BadImplStripper {
|
||||
}
|
||||
|
||||
impl BadImplStripper {
|
||||
fn keep_impl(&self, ty: &Type, cache: &Cache) -> bool {
|
||||
fn keep_impl(&self, ty: &Type) -> bool {
|
||||
if let Generic(_) = ty {
|
||||
// keep impls made on generics
|
||||
true
|
||||
} else if let Some(prim) = ty.primitive_type() {
|
||||
self.prims.contains(&prim)
|
||||
} else if let Some(did) = ty.def_id(cache) {
|
||||
} else if let Some(did) = ty.def_id() {
|
||||
self.keep_impl_with_def_id(&did)
|
||||
} else {
|
||||
false
|
||||
|
@ -15,7 +15,7 @@ crate const STRIP_HIDDEN: Pass = Pass {
|
||||
};
|
||||
|
||||
/// Strip items marked `#[doc(hidden)]`
|
||||
crate fn strip_hidden(krate: clean::Crate, cx: &DocContext<'_>) -> clean::Crate {
|
||||
crate fn strip_hidden(krate: clean::Crate, _: &DocContext<'_>) -> clean::Crate {
|
||||
let mut retained = DefIdSet::default();
|
||||
|
||||
// strip all #[doc(hidden)] items
|
||||
@ -25,7 +25,7 @@ crate fn strip_hidden(krate: clean::Crate, cx: &DocContext<'_>) -> clean::Crate
|
||||
};
|
||||
|
||||
// strip all impls referencing stripped items
|
||||
let mut stripper = ImplStripper { retained: &retained, cache: &cx.cache };
|
||||
let mut stripper = ImplStripper { retained: &retained };
|
||||
stripper.fold_crate(krate)
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,6 @@ crate fn strip_private(mut krate: clean::Crate, cx: &DocContext<'_>) -> clean::C
|
||||
}
|
||||
|
||||
// strip all impls referencing private items
|
||||
let mut stripper = ImplStripper { retained: &retained, cache: &cx.cache };
|
||||
let mut stripper = ImplStripper { retained: &retained };
|
||||
stripper.fold_crate(krate)
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ use std::mem;
|
||||
|
||||
use crate::clean::{self, GetDefId, Item};
|
||||
use crate::fold::{DocFolder, StripItem};
|
||||
use crate::formats::cache::Cache;
|
||||
|
||||
crate struct Stripper<'a> {
|
||||
crate retained: &'a mut DefIdSet,
|
||||
@ -118,7 +117,6 @@ impl<'a> DocFolder for Stripper<'a> {
|
||||
/// This stripper discards all impls which reference stripped items
|
||||
crate struct ImplStripper<'a> {
|
||||
crate retained: &'a DefIdSet,
|
||||
crate cache: &'a Cache,
|
||||
}
|
||||
|
||||
impl<'a> DocFolder for ImplStripper<'a> {
|
||||
@ -128,13 +126,13 @@ impl<'a> DocFolder for ImplStripper<'a> {
|
||||
if imp.trait_.is_none() && imp.items.is_empty() {
|
||||
return None;
|
||||
}
|
||||
if let Some(did) = imp.for_.def_id(&self.cache) {
|
||||
if let Some(did) = imp.for_.def_id() {
|
||||
if did.is_local() && !imp.for_.is_generic() && !self.retained.contains(&did) {
|
||||
debug!("ImplStripper: impl item for stripped type; removing");
|
||||
return None;
|
||||
}
|
||||
}
|
||||
if let Some(did) = imp.trait_.def_id(&self.cache) {
|
||||
if let Some(did) = imp.trait_.def_id() {
|
||||
if did.is_local() && !self.retained.contains(&did) {
|
||||
debug!("ImplStripper: impl item for stripped trait; removing");
|
||||
return None;
|
||||
@ -142,7 +140,7 @@ impl<'a> DocFolder for ImplStripper<'a> {
|
||||
}
|
||||
if let Some(generics) = imp.trait_.as_ref().and_then(|t| t.generics()) {
|
||||
for typaram in generics {
|
||||
if let Some(did) = typaram.def_id(&self.cache) {
|
||||
if let Some(did) = typaram.def_id() {
|
||||
if did.is_local() && !self.retained.contains(&did) {
|
||||
debug!(
|
||||
"ImplStripper: stripped item in trait's generics; removing impl"
|
||||
|
Loading…
x
Reference in New Issue
Block a user