Correctly output links for primitive types which enclose their contents

This commit is contained in:
Manish Goregaokar
2016-01-22 23:15:47 +05:30
parent cd1b845492
commit 9a80bc8530

View File

@@ -456,23 +456,36 @@ impl fmt::Display for clean::Type {
decl.decl) decl.decl)
} }
clean::Tuple(ref typs) => { clean::Tuple(ref typs) => {
primitive_link(f, clean::PrimitiveTuple, match &**typs {
&*match &**typs { [] => primitive_link(f, clean::PrimitiveTuple, "()"),
[ref one] => format!("({},)", one), [ref one] => {
many => format!("({})", CommaSep(&many)), try!(primitive_link(f, clean::PrimitiveTuple, "("));
}) try!(write!(f, "{}", one));
primitive_link(f, clean::PrimitiveTuple, ")")
}
many => {
try!(primitive_link(f, clean::PrimitiveTuple, "("));
try!(write!(f, "{}", CommaSep(&many)));
primitive_link(f, clean::PrimitiveTuple, ")")
}
}
} }
clean::Vector(ref t) => { clean::Vector(ref t) => {
primitive_link(f, clean::Slice, &format!("[{}]", **t)) try!(primitive_link(f, clean::Slice, &format!("[")));
try!(write!(f, "{}", t));
primitive_link(f, clean::Slice, &format!("]"))
} }
clean::FixedVector(ref t, ref s) => { clean::FixedVector(ref t, ref s) => {
try!(primitive_link(f, clean::PrimitiveType::Array, "["));
try!(write!(f, "{}", t));
primitive_link(f, clean::PrimitiveType::Array, primitive_link(f, clean::PrimitiveType::Array,
&format!("[{}; {}]", **t, *s)) &format!("; {}]", *s))
} }
clean::Bottom => f.write_str("!"), clean::Bottom => f.write_str("!"),
clean::RawPointer(m, ref t) => { clean::RawPointer(m, ref t) => {
primitive_link(f, clean::PrimitiveType::PrimitiveRawPointer, try!(primitive_link(f, clean::PrimitiveType::PrimitiveRawPointer,
&format!("*{}{}", RawMutableSpace(m), **t)) &format!("*{}", RawMutableSpace(m))));
write!(f, "{}", t)
} }
clean::BorrowedRef{ lifetime: ref l, mutability, type_: ref ty} => { clean::BorrowedRef{ lifetime: ref l, mutability, type_: ref ty} => {
let lt = match *l { let lt = match *l {