Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1681,6 +1681,21 @@ impl Type {
_ => false
}
}

pub fn generics(&self) -> Option<&[Type]> {
match *self {
ResolvedPath { ref path, .. } => {
path.segments.last().and_then(|seg| {
if let PathParameters::AngleBracketed { ref types, .. } = seg.params {
Some(&**types)
} else {
None
}
})
}
_ => None,
}
}
}

impl GetDefId for Type {
Expand Down
27 changes: 19 additions & 8 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1306,7 +1306,8 @@ impl DocFolder for Cache {
// Figure out the id of this impl. This may map to a
// primitive rather than always to a struct/enum.
// Note: matching twice to restrict the lifetime of the `i` borrow.
let did = if let clean::Item { inner: clean::ImplItem(ref i), .. } = item {
let mut dids = vec![];
if let clean::Item { inner: clean::ImplItem(ref i), .. } = item {
let masked_trait = i.trait_.def_id().map_or(false,
|d| self.masked_crates.contains(&d.krate));
if !masked_trait {
Expand All @@ -1315,23 +1316,33 @@ impl DocFolder for Cache {
clean::BorrowedRef {
type_: box clean::ResolvedPath { did, .. }, ..
} => {
Some(did)
dids.push(did);
}
ref t => {
t.primitive_type().and_then(|t| {
let did = t.primitive_type().and_then(|t| {
self.primitive_locations.get(&t).cloned()
})
});

if let Some(did) = did {
dids.push(did);
}
}
}
}

if let Some(generics) = i.trait_.as_ref().and_then(|t| t.generics()) {
for bound in generics {
if let Some(did) = bound.def_id() {
dids.push(did);
}
}
} else {
None
}
} else {
unreachable!()
};
if let Some(did) = did {
for did in dids {
self.impls.entry(did).or_insert(vec![]).push(Impl {
impl_item: item,
impl_item: item.clone(),
});
}
None
Expand Down