1
Fork 0

rustdoc: render higher-rank trait bounds

Fix #19915
This commit is contained in:
Tom Jakubowski 2014-12-16 08:50:52 -08:00
parent b39e99cfc7
commit 37225288be
3 changed files with 78 additions and 26 deletions

View file

@ -142,6 +142,22 @@ impl fmt::Show for clean::Lifetime {
}
}
impl fmt::Show for clean::PolyTrait {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if self.lifetimes.len() > 0 {
try!(f.write("for<".as_bytes()));
for (i, lt) in self.lifetimes.iter().enumerate() {
if i > 0 {
try!(f.write(", ".as_bytes()));
}
try!(write!(f, "{}", lt));
}
try!(f.write("> ".as_bytes()));
}
write!(f, "{}", self.trait_)
}
}
impl fmt::Show for clean::TyParamBound {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
@ -389,15 +405,6 @@ impl fmt::Show for clean::Type {
try!(resolved_path(f, did, path, false));
tybounds(f, typarams)
}
clean::PolyTraitRef(ref bounds) => {
for (i, bound) in bounds.iter().enumerate() {
if i != 0 {
try!(write!(f, " + "));
}
try!(write!(f, "{}", *bound));
}
Ok(())
}
clean::Infer => write!(f, "_"),
clean::Self(..) => f.write("Self".as_bytes()),
clean::Primitive(prim) => primitive_link(f, prim, prim.to_string()),
@ -505,6 +512,15 @@ impl fmt::Show for clean::Type {
}
}
}
clean::PolyTraitRef(ref bounds) => {
for (i, bound) in bounds.iter().enumerate() {
if i != 0 {
try!(write!(f, " + "));
}
try!(write!(f, "{}", *bound));
}
Ok(())
}
clean::QPath { ref name, ref self_type, ref trait_ } => {
write!(f, "<{} as {}>::{}", self_type, trait_, name)
}