Skip to content

Commit 1571c69

Browse files
committed
Auto merge of #31121 - Manishearth:prim-link, r=alexcrichton
We currently nest `<a>` tags which is doubleplusungood. So, for example, `(u8, u8)` will show up with the left paren linked to the tuple primitive page, and the right paren unlinked, which looks ugly.
2 parents 332e345 + 5a26a52 commit 1571c69

File tree

1 file changed

+30
-9
lines changed

1 file changed

+30
-9
lines changed

src/librustdoc/html/format.rs

+30-9
Original file line numberDiff line numberDiff line change
@@ -456,23 +456,44 @@ impl fmt::Display for clean::Type {
456456
decl.decl)
457457
}
458458
clean::Tuple(ref typs) => {
459-
primitive_link(f, clean::PrimitiveTuple,
460-
&*match &**typs {
461-
[ref one] => format!("({},)", one),
462-
many => format!("({})", CommaSep(&many)),
463-
})
459+
match &**typs {
460+
[] => primitive_link(f, clean::PrimitiveTuple, "()"),
461+
[ref one] => {
462+
try!(primitive_link(f, clean::PrimitiveTuple, "("));
463+
try!(write!(f, "{}", one));
464+
primitive_link(f, clean::PrimitiveTuple, ")")
465+
}
466+
many => {
467+
try!(primitive_link(f, clean::PrimitiveTuple, "("));
468+
try!(write!(f, "{}", CommaSep(&many)));
469+
primitive_link(f, clean::PrimitiveTuple, ")")
470+
}
471+
}
464472
}
465473
clean::Vector(ref t) => {
466-
primitive_link(f, clean::Slice, &format!("[{}]", **t))
474+
try!(primitive_link(f, clean::Slice, &format!("[")));
475+
try!(write!(f, "{}", t));
476+
primitive_link(f, clean::Slice, &format!("]"))
467477
}
468478
clean::FixedVector(ref t, ref s) => {
479+
try!(primitive_link(f, clean::PrimitiveType::Array, "["));
480+
try!(write!(f, "{}", t));
469481
primitive_link(f, clean::PrimitiveType::Array,
470-
&format!("[{}; {}]", **t, *s))
482+
&format!("; {}]", *s))
471483
}
472484
clean::Bottom => f.write_str("!"),
473485
clean::RawPointer(m, ref t) => {
474-
primitive_link(f, clean::PrimitiveType::PrimitiveRawPointer,
475-
&format!("*{}{}", RawMutableSpace(m), **t))
486+
match **t {
487+
clean::Generic(_) | clean::ResolvedPath {is_generic: true, ..} => {
488+
primitive_link(f, clean::PrimitiveType::PrimitiveRawPointer,
489+
&format!("*{}{}", RawMutableSpace(m), t))
490+
}
491+
_ => {
492+
try!(primitive_link(f, clean::PrimitiveType::PrimitiveRawPointer,
493+
&format!("*{}", RawMutableSpace(m))));
494+
write!(f, "{}", t)
495+
}
496+
}
476497
}
477498
clean::BorrowedRef{ lifetime: ref l, mutability, type_: ref ty} => {
478499
let lt = match *l {

0 commit comments

Comments
 (0)