Fix duplicated bounds printing in rustdoc
This commit is contained in:
parent
88f755f8a8
commit
140bb5d292
1 changed files with 11 additions and 11 deletions
|
@ -9,6 +9,7 @@ use std::borrow::Cow;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
use rustc::hir::def_id::DefId;
|
use rustc::hir::def_id::DefId;
|
||||||
|
use rustc::util::nodemap::FxHashSet;
|
||||||
use rustc_target::spec::abi::Abi;
|
use rustc_target::spec::abi::Abi;
|
||||||
use rustc::hir;
|
use rustc::hir;
|
||||||
|
|
||||||
|
@ -106,8 +107,10 @@ impl<'a, T: fmt::Display> fmt::Display for CommaSep<'a, T> {
|
||||||
|
|
||||||
impl<'a> fmt::Display for GenericBounds<'a> {
|
impl<'a> fmt::Display for GenericBounds<'a> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
let mut bounds_dup = FxHashSet::default();
|
||||||
let &GenericBounds(bounds) = self;
|
let &GenericBounds(bounds) = self;
|
||||||
for (i, bound) in bounds.iter().enumerate() {
|
|
||||||
|
for (i, bound) in bounds.iter().filter(|b| bounds_dup.insert(b.to_string())).enumerate() {
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
f.write_str(" + ")?;
|
f.write_str(" + ")?;
|
||||||
}
|
}
|
||||||
|
@ -205,16 +208,13 @@ impl<'a> fmt::Display for WhereClause<'a> {
|
||||||
clause.push_str(&format!("{}: {}", ty, GenericBounds(bounds)));
|
clause.push_str(&format!("{}: {}", ty, GenericBounds(bounds)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&clean::WherePredicate::RegionPredicate { ref lifetime,
|
&clean::WherePredicate::RegionPredicate { ref lifetime, ref bounds } => {
|
||||||
ref bounds } => {
|
clause.push_str(&format!("{}: {}",
|
||||||
clause.push_str(&format!("{}: ", lifetime));
|
lifetime,
|
||||||
for (i, lifetime) in bounds.iter().enumerate() {
|
bounds.iter()
|
||||||
if i > 0 {
|
.map(|b| b.to_string())
|
||||||
clause.push_str(" + ");
|
.collect::<Vec<_>>()
|
||||||
}
|
.join(" + ")));
|
||||||
|
|
||||||
clause.push_str(&lifetime.to_string());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
&clean::WherePredicate::EqPredicate { ref lhs, ref rhs } => {
|
&clean::WherePredicate::EqPredicate { ref lhs, ref rhs } => {
|
||||||
if f.alternate() {
|
if f.alternate() {
|
||||||
|
|
Loading…
Reference in a new issue