Skip to content

Commit

Permalink
Correctly output links for primitive types which enclose their contents
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishearth committed Jan 22, 2016
1 parent cd1b845 commit 9a80bc8
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions src/librustdoc/html/format.rs
Expand Up @@ -456,23 +456,36 @@ impl fmt::Display for clean::Type {
decl.decl)
}
clean::Tuple(ref typs) => {
primitive_link(f, clean::PrimitiveTuple,
&*match &**typs {
[ref one] => format!("({},)", one),
many => format!("({})", CommaSep(&many)),
})
match &**typs {
[] => primitive_link(f, clean::PrimitiveTuple, "()"),
[ref one] => {
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) => {
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) => {
try!(primitive_link(f, clean::PrimitiveType::Array, "["));
try!(write!(f, "{}", t));
primitive_link(f, clean::PrimitiveType::Array,
&format!("[{}; {}]", **t, *s))
&format!("; {}]", *s))
}
clean::Bottom => f.write_str("!"),
clean::RawPointer(m, ref t) => {
primitive_link(f, clean::PrimitiveType::PrimitiveRawPointer,
&format!("*{}{}", RawMutableSpace(m), **t))
try!(primitive_link(f, clean::PrimitiveType::PrimitiveRawPointer,
&format!("*{}", RawMutableSpace(m))));
write!(f, "{}", t)
}
clean::BorrowedRef{ lifetime: ref l, mutability, type_: ref ty} => {
let lt = match *l {
Expand Down

0 comments on commit 9a80bc8

Please sign in to comment.