diff options
| author | bors <bors@rust-lang.org> | 2019-06-03 14:02:15 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-06-03 14:02:15 +0000 |
| commit | 61d286e9d0530bea8fb1ae24be3989baa9ea08eb (patch) | |
| tree | 4856ecf9de5556ec31f8c7eb85909624d3d8a9d6 /src | |
| parent | 7096ff0ce16b0544b717986ec335798b3151dd8e (diff) | |
| parent | 140bb5d292bb1fd0de95bca223227bad985f893f (diff) | |
Auto merge of #59033 - GuillaumeGomez:duplicated-bounds, r=Dylan-DPC
Fix duplicated bounds printing in rustdoc Fixes #56331. Once again, I couldn't find out how to reproduce it with a small code so no test... :-/ r? @QuietMisdreavus
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustdoc/html/format.rs | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 58e55d570a4..1b38d487905 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -9,6 +9,7 @@ use std::borrow::Cow; use std::fmt; use rustc::hir::def_id::DefId; +use rustc::util::nodemap::FxHashSet; use rustc_target::spec::abi::Abi; use rustc::hir; @@ -107,8 +108,10 @@ impl<'a, T: fmt::Display> fmt::Display for CommaSep<'a, T> { 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(" + ")?; } @@ -206,16 +209,13 @@ impl<'a> fmt::Display for WhereClause<'a> { 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::<Vec<_>>() + .join(" + "))); } &clean::WherePredicate::EqPredicate { ref lhs, ref rhs } => { if f.alternate() { |
