Add test case for #trait-implementations-1 link

This commit is contained in:
Michael Howell 2022-06-11 09:37:40 -07:00
parent 3fd16648fe
commit c1487550ca
4 changed files with 14 additions and 0 deletions

View File

@ -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.

View File

@ -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.

View File

@ -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)?;

View File

@ -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 {}