Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly output links for primitive types which enclose their contents #31121

Merged
merged 2 commits into from
Jan 23, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 30 additions & 9 deletions src/librustdoc/html/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,23 +456,44 @@ 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))
match **t {
clean::Generic(_) | clean::ResolvedPath {is_generic: true, ..} => {
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