diff --git a/src/etc/htmldocck.py b/src/etc/htmldocck.py
index 269b6868e29..5eb70ab13db 100644
--- a/src/etc/htmldocck.py
+++ b/src/etc/htmldocck.py
@@ -423,6 +423,8 @@ def check_snapshot(snapshot_name, actual_tree, normalize_to_text):
else:
actual_str = flatten(actual_tree)
+ expected_str = expected_str.replace("{{channel}}", channel)
+
# Conditions:
# 1. Is --bless
# 2. Are actual and expected tree different
diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs
index 30946834583..b7789493df6 100644
--- a/src/librustdoc/html/format.rs
+++ b/src/librustdoc/html/format.rs
@@ -881,11 +881,16 @@ fn fmt_type<'cx>(
}
}
}
- clean::Slice(ref t) => {
- primitive_link(f, PrimitiveType::Slice, "[", cx)?;
- fmt::Display::fmt(&t.print(cx), f)?;
- primitive_link(f, PrimitiveType::Slice, "]", cx)
- }
+ clean::Slice(ref t) => match **t {
+ clean::Generic(name) => {
+ primitive_link(f, PrimitiveType::Slice, &format!("[{name}]"), cx)
+ }
+ _ => {
+ primitive_link(f, PrimitiveType::Slice, "[", cx)?;
+ fmt::Display::fmt(&t.print(cx), f)?;
+ primitive_link(f, PrimitiveType::Slice, "]", cx)
+ }
+ },
clean::Array(ref t, ref n) => {
primitive_link(f, PrimitiveType::Array, "[", cx)?;
fmt::Display::fmt(&t.print(cx), f)?;
@@ -924,23 +929,12 @@ fn fmt_type<'cx>(
clean::Slice(ref bt) => {
// `BorrowedRef{ ... Slice(T) }` is `&[T]`
match **bt {
- clean::Generic(_) => {
- if f.alternate() {
- primitive_link(
- f,
- PrimitiveType::Slice,
- &format!("{}{}{}[{:#}]", amp, lt, m, bt.print(cx)),
- cx,
- )
- } else {
- primitive_link(
- f,
- PrimitiveType::Slice,
- &format!("{}{}{}[{}]", amp, lt, m, bt.print(cx)),
- cx,
- )
- }
- }
+ clean::Generic(name) => primitive_link(
+ f,
+ PrimitiveType::Slice,
+ &format!("{amp}{lt}{m}[{name}]"),
+ cx,
+ ),
_ => {
primitive_link(
f,
diff --git a/src/test/rustdoc/slice-links.link_box_generic.html b/src/test/rustdoc/slice-links.link_box_generic.html
new file mode 100644
index 00000000000..38aaf20808c
--- /dev/null
+++ b/src/test/rustdoc/slice-links.link_box_generic.html
@@ -0,0 +1 @@
+pub fn delta<T>() -> MyBox<[T]>
\ No newline at end of file
diff --git a/src/test/rustdoc/slice-links.link_box_u32.html b/src/test/rustdoc/slice-links.link_box_u32.html
new file mode 100644
index 00000000000..42fd721a4ac
--- /dev/null
+++ b/src/test/rustdoc/slice-links.link_box_u32.html
@@ -0,0 +1 @@
+pub fn gamma() -> MyBox<[u32]>
\ No newline at end of file
diff --git a/src/test/rustdoc/slice-links.link_slice_generic.html b/src/test/rustdoc/slice-links.link_slice_generic.html
new file mode 100644
index 00000000000..fe79ca7a82d
--- /dev/null
+++ b/src/test/rustdoc/slice-links.link_slice_generic.html
@@ -0,0 +1 @@
+pub fn beta<T>() -> &'static [T]
\ No newline at end of file
diff --git a/src/test/rustdoc/slice-links.link_slice_u32.html b/src/test/rustdoc/slice-links.link_slice_u32.html
new file mode 100644
index 00000000000..c7e430b0607
--- /dev/null
+++ b/src/test/rustdoc/slice-links.link_slice_u32.html
@@ -0,0 +1 @@
+pub fn alpha() -> &'static [u32]
\ No newline at end of file
diff --git a/src/test/rustdoc/slice-links.rs b/src/test/rustdoc/slice-links.rs
new file mode 100644
index 00000000000..9a78e963e30
--- /dev/null
+++ b/src/test/rustdoc/slice-links.rs
@@ -0,0 +1,28 @@
+#![crate_name = "foo"]
+#![no_std]
+
+pub struct MyBox(*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() -> &'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() -> MyBox<[T]> {
+ loop {}
+}