diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2019-03-09 02:27:03 +0100 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2019-03-09 02:27:03 +0100 |
| commit | 140bb5d292bb1fd0de95bca223227bad985f893f (patch) | |
| tree | 3f74bcc8343278fcaea01a0f63bff50b090c2e90 /src | |
| parent | 88f755f8a84df1d9e6b17cf10c96ae8b93481b2e (diff) | |
| download | rust-140bb5d292bb1fd0de95bca223227bad985f893f.tar.gz rust-140bb5d292bb1fd0de95bca223227bad985f893f.zip | |
Fix duplicated bounds printing in rustdoc
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 d204a179ca6..d739d696337 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; @@ -106,8 +107,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(" + ")?; } @@ -205,16 +208,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() { |
