about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Howell <michael@notriddle.com>2022-06-11 09:37:40 -0700
committerMichael Howell <michael@notriddle.com>2022-06-11 09:54:23 -0700
commitc1487550ca75c2bcd4cb4da038ef1d18d86a857a (patch)
tree91709b5942e2e7f2818be4a27c43850e02c518af
parent3fd16648fe7c7373965d9a14bc8c832589518361 (diff)
downloadrust-c1487550ca75c2bcd4cb4da038ef1d18d86a857a.tar.gz
rust-c1487550ca75c2bcd4cb4da038ef1d18d86a857a.zip
Add test case for #trait-implementations-1 link
-rw-r--r--library/core/src/primitive_docs.rs2
-rw-r--r--library/std/src/primitive_docs.rs2
-rw-r--r--src/librustdoc/html/format.rs2
-rw-r--r--src/test/rustdoc/primitive-tuple-auto-trait.rs8
4 files changed, 14 insertions, 0 deletions
diff --git a/library/core/src/primitive_docs.rs b/library/core/src/primitive_docs.rs
index be3953692fa..c423acd7047 100644
--- a/library/core/src/primitive_docs.rs
+++ b/library/core/src/primitive_docs.rs
@@ -914,6 +914,8 @@ mod prim_str {}
 ///
 /// For more about tuples, see [the book](../book/ch03-02-data-types.html#the-tuple-type).
 ///
+// Hardcoded anchor in src/librustdoc/html/format.rs
+// linked to as `#trait-implementations-1`
 /// # Trait implementations
 ///
 /// In this documentation the shorthand `(T, ...)` is used to represent tuples of varying length.
diff --git a/library/std/src/primitive_docs.rs b/library/std/src/primitive_docs.rs
index be3953692fa..c423acd7047 100644
--- a/library/std/src/primitive_docs.rs
+++ b/library/std/src/primitive_docs.rs
@@ -914,6 +914,8 @@ mod prim_str {}
 ///
 /// For more about tuples, see [the book](../book/ch03-02-data-types.html#the-tuple-type).
 ///
+// Hardcoded anchor in src/librustdoc/html/format.rs
+// linked to as `#trait-implementations-1`
 /// # Trait implementations
 ///
 /// In this documentation the shorthand `(T, ...)` is used to represent tuples of varying length.
diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs
index 69bd0744a10..c714549d0f5 100644
--- a/src/librustdoc/html/format.rs
+++ b/src/librustdoc/html/format.rs
@@ -1077,6 +1077,8 @@ impl clean::Impl {
             if let clean::Type::Tuple(types) = &self.for_ &&
                 let [clean::Type::Generic(name)] = &types[..] &&
                 (self.kind.is_tuple_variadic() || self.kind.is_auto()) {
+                // Hardcoded anchor library/core/src/primitive_docs.rs
+                // Link should match `# Trait implementations`
                 primitive_link_fragment(f, PrimitiveType::Tuple, &format!("({name}, ...)"), "#trait-implementations-1", cx)?;
             } else if let Some(ty) = self.kind.as_blanket_ty() {
                 fmt_type(ty, f, use_absolute, cx)?;
diff --git a/src/test/rustdoc/primitive-tuple-auto-trait.rs b/src/test/rustdoc/primitive-tuple-auto-trait.rs
index 249ff1b20e3..71b0b077009 100644
--- a/src/test/rustdoc/primitive-tuple-auto-trait.rs
+++ b/src/test/rustdoc/primitive-tuple-auto-trait.rs
@@ -11,4 +11,12 @@
 // @has - '//div[@id="synthetic-implementations-list"]//h3' 'Sync'
 #[doc(primitive = "tuple")]
 /// this is a test!
+///
+// Hardcoded anchor to header written in library/core/src/primitive_docs.rs
+// @has - '//h2[@id="trait-implementations-1"]' 'Trait implementations'
+/// # Trait implementations
+///
+/// This header is hard-coded in the HTML format linking for `#[doc(tuple_variadics)]`.
+/// To make sure it gets linked correctly, we need to make sure the hardcoded anchor
+/// in the code matches what rustdoc generates for the header.
 mod tuple_prim {}