Hide synthesized type parameters
This commit is contained in:
parent
c08480fce0
commit
5dfa5f048e
2 changed files with 23 additions and 4 deletions
|
|
@ -1237,6 +1237,7 @@ pub struct TyParam {
|
|||
pub did: DefId,
|
||||
pub bounds: Vec<TyParamBound>,
|
||||
pub default: Option<Type>,
|
||||
pub synthetic: Option<hir::SyntheticTyParamKind>,
|
||||
}
|
||||
|
||||
impl Clean<TyParam> for hir::TyParam {
|
||||
|
|
@ -1246,6 +1247,7 @@ impl Clean<TyParam> 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<TyParam> 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<GenericParam> for hir::GenericParam {
|
||||
fn clean(&self, cx: &DocContext) -> GenericParam {
|
||||
match *self {
|
||||
|
|
|
|||
|
|
@ -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::<Vec<_>>();
|
||||
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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue