1
Fork 0

rustdoc: remove orphaned link on array bracket

This is 682889fb06, but for arrays instead.

For non-generics, this retains links to the array page, but instead of
trying to link it all, it only links the length part, which distinguishes
arrays from slices.

For generics, the entire thing becomes a link, just like slices.
This commit is contained in:
Michael Howell 2022-09-30 14:19:19 -07:00
parent 75d3027fb5
commit 598a02c6ad
6 changed files with 50 additions and 8 deletions

View file

@ -1010,15 +1010,25 @@ fn fmt_type<'cx>(
write!(f, "]")
}
},
clean::Array(ref t, ref n) => {
primitive_link(f, PrimitiveType::Array, "[", cx)?;
fmt::Display::fmt(&t.print(cx), f)?;
if f.alternate() {
primitive_link(f, PrimitiveType::Array, &format!("; {}]", n), cx)
} else {
primitive_link(f, PrimitiveType::Array, &format!("; {}]", Escape(n)), cx)
clean::Array(ref t, ref n) => match **t {
clean::Generic(name) if !f.alternate() => primitive_link(
f,
PrimitiveType::Array,
&format!("[{name}; {n}]", n = Escape(n)),
cx,
),
_ => {
write!(f, "[")?;
fmt::Display::fmt(&t.print(cx), f)?;
if f.alternate() {
write!(f, "; {n}")?;
} else {
write!(f, "; ")?;
primitive_link(f, PrimitiveType::Array, &format!("{n}", n = Escape(n)), cx)?;
}
write!(f, "]")
}
}
},
clean::RawPointer(m, ref t) => {
let m = match m {
hir::Mutability::Mut => "mut",