diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs
index d204a179ca62cb68098cbe9b2dd5ac5b6bf13da7..d739d696337161b7487abf136de64d243ba90b29 100644
--- a/src/librustdoc/html/format.rs
+++ b/src/librustdoc/html/format.rs
@@ -9,6 +9,7 @@
use std::fmt;
use rustc::hir::def_id::DefId;
+use rustc::util::nodemap::FxHashSet;
use rustc_target::spec::abi::Abi;
use rustc::hir;
@@ -106,8 +107,10 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
impl<'a> fmt::Display for GenericBounds<'a> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ let mut bounds_dup = FxHashSet::default();
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 {
f.write_str(" + ")?;
}
@@ -205,16 +208,13 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
clause.push_str(&format!("{}: {}", ty, GenericBounds(bounds)));
}
}
- &clean::WherePredicate::RegionPredicate { ref lifetime,
- ref bounds } => {
- clause.push_str(&format!("{}: ", lifetime));
- for (i, lifetime) in bounds.iter().enumerate() {
- if i > 0 {
- clause.push_str(" + ");
- }
-
- clause.push_str(&lifetime.to_string());
- }
+ &clean::WherePredicate::RegionPredicate { ref lifetime, ref bounds } => {
+ clause.push_str(&format!("{}: {}",
+ lifetime,
+ bounds.iter()
+ .map(|b| b.to_string())
+ .collect::>()
+ .join(" + ")));
}
&clean::WherePredicate::EqPredicate { ref lhs, ref rhs } => {
if f.alternate() {