diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 1a42b02140cd..7701dd2fd990 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1237,6 +1237,7 @@ pub struct TyParam { pub did: DefId, pub bounds: Vec, pub default: Option, + pub synthetic: Option, } impl Clean for hir::TyParam { @@ -1246,6 +1247,7 @@ impl Clean for hir::TyParam { did: cx.tcx.hir.local_def_id(self.id), bounds: self.bounds.clean(cx), default: self.default.clean(cx), + synthetic: self.synthetic, } } } @@ -1261,7 +1263,8 @@ impl<'tcx> Clean for ty::TypeParameterDef { Some(cx.tcx.type_of(self.def_id).clean(cx)) } else { None - } + }, + synthetic: None, } } } @@ -1629,6 +1632,16 @@ pub enum GenericParam { Type(TyParam), } +impl GenericParam { + pub fn is_synthetic_type_param(&self) -> bool { + if let GenericParam::Type(ref t) = *self { + t.synthetic.is_some() + } else { + false + } + } +} + impl Clean for hir::GenericParam { fn clean(&self, cx: &DocContext) -> GenericParam { match *self { diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 2913ea6a78ec..0c4cd3accf61 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -148,11 +148,17 @@ impl fmt::Display for clean::GenericParam { impl fmt::Display for clean::Generics { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - if self.params.is_empty() { return Ok(()) } + let real_params = self.params + .iter() + .filter(|p| !p.is_synthetic_type_param()) + .collect::>(); + if real_params.is_empty() { + return Ok(()); + } if f.alternate() { - write!(f, "<{:#}>", CommaSep(&self.params)) + write!(f, "<{:#}>", CommaSep(&real_params)) } else { - write!(f, "<{}>", CommaSep(&self.params)) + write!(f, "<{}>", CommaSep(&real_params)) } } }