Auto merge of #38414 - estebank:doc-dissambiguate, r=steveklabnik
Rustdoc: disambiguate Implementors when the type name is not unique Presentation [goes from](https://doc.rust-lang.org/stable/std/iter/trait.ExactSizeIterator.html#implementors): <img width="492" alt="" src="https://cloud.githubusercontent.com/assets/1606434/21276752/b2b50474-c387-11e6-96e1-9766851da269.png"> to: <img width="787" alt="" src="https://cloud.githubusercontent.com/assets/1606434/21276763/bb37f6b0-c387-11e6-8596-9163cb254674.png"> on cases where there're multiple implementors with the same name. Fixes #37762.
This commit is contained in:
@@ -2122,9 +2122,25 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||
<ul class='item-list' id='implementors-list'>
|
||||
")?;
|
||||
if let Some(implementors) = cache.implementors.get(&it.def_id) {
|
||||
for i in implementors {
|
||||
let mut implementor_count: FxHashMap<&str, usize> = FxHashMap();
|
||||
for implementor in implementors {
|
||||
if let clean::Type::ResolvedPath {ref path, ..} = implementor.impl_.for_ {
|
||||
*implementor_count.entry(path.last_name()).or_insert(0) += 1;
|
||||
}
|
||||
}
|
||||
|
||||
for implementor in implementors {
|
||||
write!(w, "<li><code>")?;
|
||||
fmt_impl_for_trait_page(&i.impl_, w)?;
|
||||
// If there's already another implementor that has the same abbridged name, use the
|
||||
// full path, for example in `std::iter::ExactSizeIterator`
|
||||
let use_absolute = if let clean::Type::ResolvedPath {
|
||||
ref path, ..
|
||||
} = implementor.impl_.for_ {
|
||||
implementor_count[path.last_name()] > 1
|
||||
} else {
|
||||
false
|
||||
};
|
||||
fmt_impl_for_trait_page(&implementor.impl_, w, use_absolute)?;
|
||||
writeln!(w, "</code></li>")?;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user