Auto merge of #49304 - sinkuu:impl_trait_rustdoc, r=QuietMisdreavus
Rustdoc support for universal_impl_trait Hides type parameters synthesized by `impl Trait`-in-argument-position, and enables links to trait names. <img alt="before" src="https://user-images.githubusercontent.com/7091080/37831646-a61413c6-2ee9-11e8-8ec2-a6137956d922.png" width="450"/> ↓ <img alt="after" src="https://user-images.githubusercontent.com/7091080/37831657-b2ff0ae6-2ee9-11e8-8797-fdad904782bf.png" width="450"/> Fixes #49309
This commit is contained in:
commit
e58df0d8c5
4 changed files with 127 additions and 28 deletions
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -575,7 +581,7 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt:
|
|||
}
|
||||
many => {
|
||||
primitive_link(f, PrimitiveType::Tuple, "(")?;
|
||||
fmt::Display::fmt(&CommaSep(&many), f)?;
|
||||
fmt::Display::fmt(&CommaSep(many), f)?;
|
||||
primitive_link(f, PrimitiveType::Tuple, ")")
|
||||
}
|
||||
}
|
||||
|
|
@ -661,18 +667,7 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt:
|
|||
}
|
||||
}
|
||||
clean::ImplTrait(ref bounds) => {
|
||||
write!(f, "impl ")?;
|
||||
for (i, bound) in bounds.iter().enumerate() {
|
||||
if i != 0 {
|
||||
write!(f, " + ")?;
|
||||
}
|
||||
if f.alternate() {
|
||||
write!(f, "{:#}", *bound)?;
|
||||
} else {
|
||||
write!(f, "{}", *bound)?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
write!(f, "impl {}", TyParamBounds(bounds))
|
||||
}
|
||||
clean::QPath { ref name, ref self_type, ref trait_ } => {
|
||||
let should_show_cast = match *trait_ {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue