Rollup merge of #97668 - notriddle:notriddle/slice-link, r=jsha
rustdoc: clean up primitive.slice.html links Before: <a href="https://doc.rust-lang.org/stable/std/boxed/struct.Box.html">Box</a><<a href="https://doc.rust-lang.org/stable/std/primitive.slice.html">[</a>T<a href="https://doc.rust-lang.org/stable/std/primitive.slice.html">]</a>> After: <a href="https://doc.rust-lang.org/stable/std/boxed/struct.Box.html">Box</a><<a href="https://doc.rust-lang.org/stable/std/primitive.slice.html">[T]</a>>
This commit is contained in:
commit
d6f35b3454
@ -423,6 +423,8 @@ def check_snapshot(snapshot_name, actual_tree, normalize_to_text):
|
|||||||
else:
|
else:
|
||||||
actual_str = flatten(actual_tree)
|
actual_str = flatten(actual_tree)
|
||||||
|
|
||||||
|
expected_str = expected_str.replace("{{channel}}", channel)
|
||||||
|
|
||||||
# Conditions:
|
# Conditions:
|
||||||
# 1. Is --bless
|
# 1. Is --bless
|
||||||
# 2. Are actual and expected tree different
|
# 2. Are actual and expected tree different
|
||||||
|
@ -881,11 +881,16 @@ fn fmt_type<'cx>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
clean::Slice(ref t) => {
|
clean::Slice(ref t) => match **t {
|
||||||
|
clean::Generic(name) => {
|
||||||
|
primitive_link(f, PrimitiveType::Slice, &format!("[{name}]"), cx)
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
primitive_link(f, PrimitiveType::Slice, "[", cx)?;
|
primitive_link(f, PrimitiveType::Slice, "[", cx)?;
|
||||||
fmt::Display::fmt(&t.print(cx), f)?;
|
fmt::Display::fmt(&t.print(cx), f)?;
|
||||||
primitive_link(f, PrimitiveType::Slice, "]", cx)
|
primitive_link(f, PrimitiveType::Slice, "]", cx)
|
||||||
}
|
}
|
||||||
|
},
|
||||||
clean::Array(ref t, ref n) => {
|
clean::Array(ref t, ref n) => {
|
||||||
primitive_link(f, PrimitiveType::Array, "[", cx)?;
|
primitive_link(f, PrimitiveType::Array, "[", cx)?;
|
||||||
fmt::Display::fmt(&t.print(cx), f)?;
|
fmt::Display::fmt(&t.print(cx), f)?;
|
||||||
@ -924,23 +929,12 @@ fn fmt_type<'cx>(
|
|||||||
clean::Slice(ref bt) => {
|
clean::Slice(ref bt) => {
|
||||||
// `BorrowedRef{ ... Slice(T) }` is `&[T]`
|
// `BorrowedRef{ ... Slice(T) }` is `&[T]`
|
||||||
match **bt {
|
match **bt {
|
||||||
clean::Generic(_) => {
|
clean::Generic(name) => primitive_link(
|
||||||
if f.alternate() {
|
|
||||||
primitive_link(
|
|
||||||
f,
|
f,
|
||||||
PrimitiveType::Slice,
|
PrimitiveType::Slice,
|
||||||
&format!("{}{}{}[{:#}]", amp, lt, m, bt.print(cx)),
|
&format!("{amp}{lt}{m}[{name}]"),
|
||||||
cx,
|
cx,
|
||||||
)
|
),
|
||||||
} else {
|
|
||||||
primitive_link(
|
|
||||||
f,
|
|
||||||
PrimitiveType::Slice,
|
|
||||||
&format!("{}{}{}[{}]", amp, lt, m, bt.print(cx)),
|
|
||||||
cx,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => {
|
_ => {
|
||||||
primitive_link(
|
primitive_link(
|
||||||
f,
|
f,
|
||||||
|
1
src/test/rustdoc/slice-links.link_box_generic.html
Normal file
1
src/test/rustdoc/slice-links.link_box_generic.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<code>pub fn delta<T>() -> <a class="struct" href="struct.MyBox.html" title="struct foo::MyBox">MyBox</a><<a class="primitive" href="{{channel}}/core/primitive.slice.html">[T]</a>></code>
|
1
src/test/rustdoc/slice-links.link_box_u32.html
Normal file
1
src/test/rustdoc/slice-links.link_box_u32.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<code>pub fn gamma() -> <a class="struct" href="struct.MyBox.html" title="struct foo::MyBox">MyBox</a><<a class="primitive" href="{{channel}}/core/primitive.slice.html">[</a><a class="primitive" href="{{channel}}/core/primitive.u32.html">u32</a><a class="primitive" href="{{channel}}/core/primitive.slice.html">]</a>></code>
|
1
src/test/rustdoc/slice-links.link_slice_generic.html
Normal file
1
src/test/rustdoc/slice-links.link_slice_generic.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<code>pub fn beta<T>() -> <a class="primitive" href="{{channel}}/core/primitive.slice.html">&'static [T]</a></code>
|
1
src/test/rustdoc/slice-links.link_slice_u32.html
Normal file
1
src/test/rustdoc/slice-links.link_slice_u32.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<code>pub fn alpha() -> <a class="primitive" href="{{channel}}/core/primitive.slice.html">&'static [</a><a class="primitive" href="{{channel}}/core/primitive.u32.html">u32</a><a class="primitive" href="{{channel}}/core/primitive.slice.html">]</a></code>
|
28
src/test/rustdoc/slice-links.rs
Normal file
28
src/test/rustdoc/slice-links.rs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#![crate_name = "foo"]
|
||||||
|
#![no_std]
|
||||||
|
|
||||||
|
pub struct MyBox<T: ?Sized>(*const T);
|
||||||
|
|
||||||
|
// @has 'foo/fn.alpha.html'
|
||||||
|
// @snapshot link_slice_u32 - '//pre[@class="rust fn"]/code'
|
||||||
|
pub fn alpha() -> &'static [u32] {
|
||||||
|
loop {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// @has 'foo/fn.beta.html'
|
||||||
|
// @snapshot link_slice_generic - '//pre[@class="rust fn"]/code'
|
||||||
|
pub fn beta<T>() -> &'static [T] {
|
||||||
|
loop {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// @has 'foo/fn.gamma.html'
|
||||||
|
// @snapshot link_box_u32 - '//pre[@class="rust fn"]/code'
|
||||||
|
pub fn gamma() -> MyBox<[u32]> {
|
||||||
|
loop {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// @has 'foo/fn.delta.html'
|
||||||
|
// @snapshot link_box_generic - '//pre[@class="rust fn"]/code'
|
||||||
|
pub fn delta<T>() -> MyBox<[T]> {
|
||||||
|
loop {}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user