Skip to content

Commit c148755

Browse files
committed
Add test case for #trait-implementations-1 link
1 parent 3fd1664 commit c148755

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

library/core/src/primitive_docs.rs

+2
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,8 @@ mod prim_str {}
914914
///
915915
/// For more about tuples, see [the book](../book/ch03-02-data-types.html#the-tuple-type).
916916
///
917+
// Hardcoded anchor in src/librustdoc/html/format.rs
918+
// linked to as `#trait-implementations-1`
917919
/// # Trait implementations
918920
///
919921
/// In this documentation the shorthand `(T, ...)` is used to represent tuples of varying length.

library/std/src/primitive_docs.rs

+2
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,8 @@ mod prim_str {}
914914
///
915915
/// For more about tuples, see [the book](../book/ch03-02-data-types.html#the-tuple-type).
916916
///
917+
// Hardcoded anchor in src/librustdoc/html/format.rs
918+
// linked to as `#trait-implementations-1`
917919
/// # Trait implementations
918920
///
919921
/// In this documentation the shorthand `(T, ...)` is used to represent tuples of varying length.

src/librustdoc/html/format.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1077,6 +1077,8 @@ impl clean::Impl {
10771077
if let clean::Type::Tuple(types) = &self.for_ &&
10781078
let [clean::Type::Generic(name)] = &types[..] &&
10791079
(self.kind.is_tuple_variadic() || self.kind.is_auto()) {
1080+
// Hardcoded anchor library/core/src/primitive_docs.rs
1081+
// Link should match `# Trait implementations`
10801082
primitive_link_fragment(f, PrimitiveType::Tuple, &format!("({name}, ...)"), "#trait-implementations-1", cx)?;
10811083
} else if let Some(ty) = self.kind.as_blanket_ty() {
10821084
fmt_type(ty, f, use_absolute, cx)?;

src/test/rustdoc/primitive-tuple-auto-trait.rs

+8
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,12 @@
1111
// @has - '//div[@id="synthetic-implementations-list"]//h3' 'Sync'
1212
#[doc(primitive = "tuple")]
1313
/// this is a test!
14+
///
15+
// Hardcoded anchor to header written in library/core/src/primitive_docs.rs
16+
// @has - '//h2[@id="trait-implementations-1"]' 'Trait implementations'
17+
/// # Trait implementations
18+
///
19+
/// This header is hard-coded in the HTML format linking for `#[doc(tuple_variadics)]`.
20+
/// To make sure it gets linked correctly, we need to make sure the hardcoded anchor
21+
/// in the code matches what rustdoc generates for the header.
1422
mod tuple_prim {}

0 commit comments

Comments
 (0)