Skip to content

Commit 5dfa5f0

Browse files
committed
Hide synthesized type parameters
1 parent c08480f commit 5dfa5f0

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

src/librustdoc/clean/mod.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -1237,6 +1237,7 @@ pub struct TyParam {
12371237
pub did: DefId,
12381238
pub bounds: Vec<TyParamBound>,
12391239
pub default: Option<Type>,
1240+
pub synthetic: Option<hir::SyntheticTyParamKind>,
12401241
}
12411242

12421243
impl Clean<TyParam> for hir::TyParam {
@@ -1246,6 +1247,7 @@ impl Clean<TyParam> for hir::TyParam {
12461247
did: cx.tcx.hir.local_def_id(self.id),
12471248
bounds: self.bounds.clean(cx),
12481249
default: self.default.clean(cx),
1250+
synthetic: self.synthetic,
12491251
}
12501252
}
12511253
}
@@ -1261,7 +1263,8 @@ impl<'tcx> Clean<TyParam> for ty::TypeParameterDef {
12611263
Some(cx.tcx.type_of(self.def_id).clean(cx))
12621264
} else {
12631265
None
1264-
}
1266+
},
1267+
synthetic: None,
12651268
}
12661269
}
12671270
}
@@ -1629,6 +1632,16 @@ pub enum GenericParam {
16291632
Type(TyParam),
16301633
}
16311634

1635+
impl GenericParam {
1636+
pub fn is_synthetic_type_param(&self) -> bool {
1637+
if let GenericParam::Type(ref t) = *self {
1638+
t.synthetic.is_some()
1639+
} else {
1640+
false
1641+
}
1642+
}
1643+
}
1644+
16321645
impl Clean<GenericParam> for hir::GenericParam {
16331646
fn clean(&self, cx: &DocContext) -> GenericParam {
16341647
match *self {

src/librustdoc/html/format.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,17 @@ impl fmt::Display for clean::GenericParam {
148148

149149
impl fmt::Display for clean::Generics {
150150
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
151-
if self.params.is_empty() { return Ok(()) }
151+
let real_params = self.params
152+
.iter()
153+
.filter(|p| !p.is_synthetic_type_param())
154+
.collect::<Vec<_>>();
155+
if real_params.is_empty() {
156+
return Ok(());
157+
}
152158
if f.alternate() {
153-
write!(f, "<{:#}>", CommaSep(&self.params))
159+
write!(f, "<{:#}>", CommaSep(&real_params))
154160
} else {
155-
write!(f, "&lt;{}&gt;", CommaSep(&self.params))
161+
write!(f, "&lt;{}&gt;", CommaSep(&real_params))
156162
}
157163
}
158164
}

0 commit comments

Comments
 (0)