From 15b2168250f80186e267edb7e01dc7ee492aad4d Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 26 Jul 2023 15:22:48 +0200 Subject: [PATCH 1/4] Unify generation of primitive links for associated types with the rest --- src/librustdoc/html/format.rs | 117 +++++++++++++++------------------- 1 file changed, 51 insertions(+), 66 deletions(-) diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 2f611c31a0746..2a078718ea396 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -958,6 +958,24 @@ pub(crate) fn anchor<'a, 'cx: 'a>( }) } +fn fmt_slice<'cx>( + f: &mut fmt::Formatter<'_>, + t: &clean::Type, + extra: &str, + cx: &'cx Context<'_>, +) -> fmt::Result { + match *t { + clean::Generic(name) => { + primitive_link(f, PrimitiveType::Slice, &format!("{extra}[{name}]"), cx) + } + _ => { + write!(f, "{extra}[")?; + fmt::Display::fmt(&t.print(cx), f)?; + f.write_str("]") + } + } +} + fn fmt_type<'cx>( t: &clean::Type, f: &mut fmt::Formatter<'_>, @@ -1008,55 +1026,25 @@ fn fmt_type<'cx>( match &typs[..] { &[] => primitive_link(f, PrimitiveType::Unit, "()", cx), [one] => { - if let clean::Generic(name) = one { - primitive_link(f, PrimitiveType::Tuple, &format!("({name},)"), cx) - } else { - write!(f, "(")?; - // Carry `f.alternate()` into this display w/o branching manually. - fmt::Display::fmt(&one.print(cx), f)?; - write!(f, ",)") - } + write!(f, "(")?; + // Carry `f.alternate()` into this display w/o branching manually. + fmt::Display::fmt(&one.print(cx), f)?; + write!(f, ",)") } many => { - let generic_names: Vec = many - .iter() - .filter_map(|t| match t { - clean::Generic(name) => Some(*name), - _ => None, - }) - .collect(); - let is_generic = generic_names.len() == many.len(); - if is_generic { - primitive_link( - f, - PrimitiveType::Tuple, - &format!("({})", generic_names.iter().map(|s| s.as_str()).join(", ")), - cx, - ) - } else { - write!(f, "(")?; - for (i, item) in many.iter().enumerate() { - if i != 0 { - write!(f, ", ")?; - } - // Carry `f.alternate()` into this display w/o branching manually. - fmt::Display::fmt(&item.print(cx), f)?; + write!(f, "(")?; + for (i, item) in many.iter().enumerate() { + if i != 0 { + write!(f, ", ")?; } - write!(f, ")") + // Carry `f.alternate()` into this display w/o branching manually. + fmt::Display::fmt(&item.print(cx), f)?; } + write!(f, ")") } } } - clean::Slice(ref t) => match **t { - clean::Generic(name) => { - primitive_link(f, PrimitiveType::Slice, &format!("[{name}]"), cx) - } - _ => { - write!(f, "[")?; - fmt::Display::fmt(&t.print(cx), f)?; - write!(f, "]") - } - }, + clean::Slice(ref t) => fmt_slice(f, &**t, "", cx), clean::Array(ref t, ref n) => match **t { clean::Generic(name) if !f.alternate() => primitive_link( f, @@ -1070,10 +1058,9 @@ fn fmt_type<'cx>( if f.alternate() { write!(f, "; {n}")?; } else { - write!(f, "; ")?; - primitive_link(f, PrimitiveType::Array, &format!("{n}", n = Escape(n)), cx)?; + write!(f, "; {}", Escape(n))?; } - write!(f, "]") + f.write_str("]") } }, clean::RawPointer(m, ref t) => { @@ -1082,36 +1069,34 @@ fn fmt_type<'cx>( hir::Mutability::Not => "const", }; - if matches!(**t, clean::Generic(_)) || t.is_assoc_ty() { - let text = if f.alternate() { - format!("*{m} {ty:#}", ty = t.print(cx)) - } else { - format!("*{m} {ty}", ty = t.print(cx)) - }; - primitive_link(f, clean::PrimitiveType::RawPointer, &text, cx) - } else { - primitive_link(f, clean::PrimitiveType::RawPointer, &format!("*{m} "), cx)?; - fmt::Display::fmt(&t.print(cx), f) - } + primitive_link(f, clean::PrimitiveType::RawPointer, &format!("*{m} "), cx)?; + fmt::Display::fmt(&t.print(cx), f) } clean::BorrowedRef { lifetime: ref l, mutability, type_: ref ty } => { - let lt = match l { + let lifetime = match l { Some(l) => format!("{} ", l.print()), _ => String::new(), }; let m = mutability.print_with_space(); let amp = if f.alternate() { "&" } else { "&" }; - if let clean::Generic(name) = **ty { - return primitive_link( - f, - PrimitiveType::Reference, - &format!("{amp}{lt}{m}{name}"), - cx, - ); + match **ty { + clean::Generic(name) => { + primitive_link( + f, + PrimitiveType::Reference, + &format!("{amp}{lifetime}{m}"), + cx, + )?; + return write!(f, "{name}"); + } + clean::Slice(ref t) => { + return fmt_slice(f, &**t, &format!("{amp}{lifetime}{m}"), cx); + } + _ => {} } - write!(f, "{amp}{lt}{m}")?; + write!(f, "{amp}{lifetime}{m}")?; let needs_parens = match **ty { clean::DynTrait(ref bounds, ref trait_lt) @@ -1192,7 +1177,7 @@ fn fmt_type<'cx>( write!( f, "{name}", + title=\"type {path}::{name}\">{name}", shortty = ItemType::AssocType, name = assoc.name, path = join_with_double_colon(&path), From 62cbc3fc1921e3e05a0fe7302f00bf70f38ae2f2 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 26 Jul 2023 15:50:19 +0200 Subject: [PATCH 2/4] Update rustdoc tests --- tests/rustdoc/array-links.link_box_generic.html | 2 +- tests/rustdoc/array-links.link_slice_generic.html | 2 +- tests/rustdoc/issue-15318.rs | 2 +- tests/rustdoc/slice-links.link_box_generic.html | 2 +- tests/rustdoc/slice-links.link_slice_generic.html | 2 +- tests/rustdoc/tuples.link1_t.html | 2 +- tests/rustdoc/tuples.link2_t.html | 2 +- tests/rustdoc/tuples.link2_tu.html | 2 +- tests/rustdoc/where.golf_type_alias_decl.html | 2 +- tests/rustdoc/whitespace-after-where-clause.enum.html | 2 +- tests/rustdoc/whitespace-after-where-clause.enum2.html | 2 +- tests/rustdoc/whitespace-after-where-clause.struct.html | 2 +- tests/rustdoc/whitespace-after-where-clause.struct2.html | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/rustdoc/array-links.link_box_generic.html b/tests/rustdoc/array-links.link_box_generic.html index 3481bb6a02547..4616bb55138d1 100644 --- a/tests/rustdoc/array-links.link_box_generic.html +++ b/tests/rustdoc/array-links.link_box_generic.html @@ -1 +1 @@ -pub fn delta<T>() -> MyBox<[T; 1]> \ No newline at end of file +pub fn delta<T>() -> MyBox<[T; 1]> \ No newline at end of file diff --git a/tests/rustdoc/array-links.link_slice_generic.html b/tests/rustdoc/array-links.link_slice_generic.html index f1ca2f59bd7ca..1a3f2de1397f7 100644 --- a/tests/rustdoc/array-links.link_slice_generic.html +++ b/tests/rustdoc/array-links.link_slice_generic.html @@ -1 +1 @@ -pub fn beta<T>() -> &'static [T; 1] \ No newline at end of file +pub fn beta<T>() -> &'static [T; 1] \ No newline at end of file diff --git a/tests/rustdoc/issue-15318.rs b/tests/rustdoc/issue-15318.rs index 0349fe2854c8a..96d237561a23a 100644 --- a/tests/rustdoc/issue-15318.rs +++ b/tests/rustdoc/issue-15318.rs @@ -7,5 +7,5 @@ extern crate issue_15318; // @has issue_15318/fn.bar.html \ // '//*[@href="http://example.com/issue_15318/primitive.pointer.html"]' \ -// '*mut T' +// '*mut ' pub fn bar(ptr: *mut T) {} diff --git a/tests/rustdoc/slice-links.link_box_generic.html b/tests/rustdoc/slice-links.link_box_generic.html index 38aaf20808cf1..1956b72257356 100644 --- a/tests/rustdoc/slice-links.link_box_generic.html +++ b/tests/rustdoc/slice-links.link_box_generic.html @@ -1 +1 @@ -pub fn delta<T>() -> MyBox<[T]> \ No newline at end of file +pub fn delta<T>() -> MyBox<[T]> \ No newline at end of file diff --git a/tests/rustdoc/slice-links.link_slice_generic.html b/tests/rustdoc/slice-links.link_slice_generic.html index 1d0f2bf75a233..87b90aa15df08 100644 --- a/tests/rustdoc/slice-links.link_slice_generic.html +++ b/tests/rustdoc/slice-links.link_slice_generic.html @@ -1 +1 @@ -pub fn beta<T>() -> &'static [T] \ No newline at end of file +pub fn beta<T>() -> &'static [T] \ No newline at end of file diff --git a/tests/rustdoc/tuples.link1_t.html b/tests/rustdoc/tuples.link1_t.html index 1cbaec05733b5..595a89ff798d6 100644 --- a/tests/rustdoc/tuples.link1_t.html +++ b/tests/rustdoc/tuples.link1_t.html @@ -1 +1 @@ -pub fn tuple1_t<T>(x: (T,)) -> (T,) \ No newline at end of file +pub fn tuple1_t<T>(x: (T,)) -> (T,) \ No newline at end of file diff --git a/tests/rustdoc/tuples.link2_t.html b/tests/rustdoc/tuples.link2_t.html index 2477aa6be9d39..ee126fd034392 100644 --- a/tests/rustdoc/tuples.link2_t.html +++ b/tests/rustdoc/tuples.link2_t.html @@ -1 +1 @@ -pub fn tuple2_t<T>(x: (T, T)) -> (T, T) \ No newline at end of file +pub fn tuple2_t<T>(x: (T, T)) -> (T, T) \ No newline at end of file diff --git a/tests/rustdoc/tuples.link2_tu.html b/tests/rustdoc/tuples.link2_tu.html index b02f8dd8d6530..b0dcf977a4372 100644 --- a/tests/rustdoc/tuples.link2_tu.html +++ b/tests/rustdoc/tuples.link2_tu.html @@ -1 +1 @@ -pub fn tuple2_tu<T, U>(x: (T, U)) -> (T, U) \ No newline at end of file +pub fn tuple2_tu<T, U>(x: (T, U)) -> (T, U) \ No newline at end of file diff --git a/tests/rustdoc/where.golf_type_alias_decl.html b/tests/rustdoc/where.golf_type_alias_decl.html index 8da5402f90073..9cd67892a4894 100644 --- a/tests/rustdoc/where.golf_type_alias_decl.html +++ b/tests/rustdoc/where.golf_type_alias_decl.html @@ -1,2 +1,2 @@ pub type Golf<T>where - T: Clone, = (T, T); \ No newline at end of file + T: Clone, = (T, T); \ No newline at end of file diff --git a/tests/rustdoc/whitespace-after-where-clause.enum.html b/tests/rustdoc/whitespace-after-where-clause.enum.html index 20b60b68e88cf..231857f070bc3 100644 --- a/tests/rustdoc/whitespace-after-where-clause.enum.html +++ b/tests/rustdoc/whitespace-after-where-clause.enum.html @@ -1,5 +1,5 @@
pub enum Cow<'a, B>where
     B: ToOwned<dyn Clone> + ?Sized + 'a,{
-    Borrowed(&'a B),
+    Borrowed(&'a B),
     Whatever(u32),
 }
\ No newline at end of file diff --git a/tests/rustdoc/whitespace-after-where-clause.enum2.html b/tests/rustdoc/whitespace-after-where-clause.enum2.html index 065ce757de1ab..578db53bb17fe 100644 --- a/tests/rustdoc/whitespace-after-where-clause.enum2.html +++ b/tests/rustdoc/whitespace-after-where-clause.enum2.html @@ -1,4 +1,4 @@
pub enum Cow2<'a, B: ?Sized + ToOwned<dyn Clone> + 'a> {
-    Borrowed(&'a B),
+    Borrowed(&'a B),
     Whatever(u32),
 }
\ No newline at end of file diff --git a/tests/rustdoc/whitespace-after-where-clause.struct.html b/tests/rustdoc/whitespace-after-where-clause.struct.html index 948ddc499da8a..b8b548b6fd55c 100644 --- a/tests/rustdoc/whitespace-after-where-clause.struct.html +++ b/tests/rustdoc/whitespace-after-where-clause.struct.html @@ -1,5 +1,5 @@
pub struct Struct<'a, B>where
     B: ToOwned<dyn Clone> + ?Sized + 'a,{
-    pub a: &'a B,
+    pub a: &'a B,
     pub b: u32,
 }
\ No newline at end of file diff --git a/tests/rustdoc/whitespace-after-where-clause.struct2.html b/tests/rustdoc/whitespace-after-where-clause.struct2.html index c647e8d71218e..b921065d60e08 100644 --- a/tests/rustdoc/whitespace-after-where-clause.struct2.html +++ b/tests/rustdoc/whitespace-after-where-clause.struct2.html @@ -1,4 +1,4 @@
pub struct Struct2<'a, B: ?Sized + ToOwned<dyn Clone> + 'a> {
-    pub a: &'a B,
+    pub a: &'a B,
     pub b: u32,
 }
\ No newline at end of file From 2fbbf9a5ab63d92283e129235f7c7dec714e71c7 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 26 Jul 2023 15:52:41 +0200 Subject: [PATCH 3/4] Add test for changes in generics display --- tests/rustdoc/primitive-links.rs | 64 ++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 tests/rustdoc/primitive-links.rs diff --git a/tests/rustdoc/primitive-links.rs b/tests/rustdoc/primitive-links.rs new file mode 100644 index 0000000000000..f1814f9f2bc3d --- /dev/null +++ b/tests/rustdoc/primitive-links.rs @@ -0,0 +1,64 @@ +// Test to ensure that `&` are handled the same way for generics and +// for other "normal" types. + +#![crate_name = "foo"] + +// @has 'foo/trait.Trait.html' + +pub struct Struct; + +pub trait Trait { + // There should only be one `` (not linking to reference primitive). + // @count - '//*[@id="tymethod.method"]/*[@class="code-header"]/a' 1 + // @has - '//*[@id="tymethod.method"]/*[@class="code-header"]/a' 'method' + fn method(&self, other: &Rhs); + // There should only be one `` (method and `*const`). + // @count - '//*[@id="tymethod.method2"]/*[@class="code-header"]/a' 2 + // @has - '//*[@id="tymethod.method2"]/*[@class="code-header"]/a' 'method2' + // @has - '//*[@id="tymethod.method2"]/*[@class="code-header"]/a' '*const' + fn method2(&self, other: *const Rhs); + // There should be only one `` (just the method). + // @count - '//*[@id="tymethod.bar"]/*[@class="code-header"]/a' 1 + // @has - '//*[@id="tymethod.bar"]/*[@class="code-header"]/a' 'bar' + fn bar(&self, other: Rhs); + // There should be two `` (method and `Struct`). + // @count - '//*[@id="tymethod.foo"]/*[@class="code-header"]/a' 2 + // @has - '//*[@id="tymethod.foo"]/*[@class="code-header"]/a' 'foo' + // @has - '//*[@id="tymethod.foo"]/*[@class="code-header"]/a' 'Struct' + fn foo(&self, other: &Struct); + // There should be three `` (method, `Struct` and `*const`). + // @count - '//*[@id="tymethod.foo2"]/*[@class="code-header"]/a' 3 + // @has - '//*[@id="tymethod.foo2"]/*[@class="code-header"]/a' 'foo2' + // @has - '//*[@id="tymethod.foo2"]/*[@class="code-header"]/a' 'Struct' + // @has - '//*[@id="tymethod.foo2"]/*[@class="code-header"]/a' '*const' + fn foo2(&self, other: *const Struct); + // There should be only one `` (just the method). + // @count - '//*[@id="tymethod.tuple"]/*[@class="code-header"]/a' 1 + // @has - '//*[@id="tymethod.tuple"]/*[@class="code-header"]/a' 'tuple' + fn tuple(&self, other: (Rhs, Rhs)); + // There should be two `` (method and `Struct`). + // @count - '//*[@id="tymethod.tuple2"]/*[@class="code-header"]/a' 2 + // @has - '//*[@id="tymethod.tuple2"]/*[@class="code-header"]/a' 'tuple2' + // @has - '//*[@id="tymethod.tuple2"]/*[@class="code-header"]/a' 'Struct' + fn tuple2(&self, other: (Struct, Rhs)); + // There should be only one `` (just the method). + // @count - '//*[@id="tymethod.slice"]/*[@class="code-header"]/a' 1 + // @has - '//*[@id="tymethod.slice"]/*[@class="code-header"]/a' 'slice' + fn slice(&self, other: &[Rhs]); + // There should be two `` (method and `Struct`). + // @count - '//*[@id="tymethod.slice2"]/*[@class="code-header"]/a' 2 + // @has - '//*[@id="tymethod.slice2"]/*[@class="code-header"]/a' 'slice2' + // @has - '//*[@id="tymethod.slice2"]/*[@class="code-header"]/a' 'Struct' + fn slice2(&self, other: &[Struct]); + // There should be two `` (the method and one for the array primitive). + // @count - '//*[@id="tymethod.array"]/*[@class="code-header"]/a' 2 + // @has - '//*[@id="tymethod.array"]/*[@class="code-header"]/a' 'array' + // @has - '//*[@id="tymethod.array"]/*[@class="code-header"]/a' '2' + fn array(&self, other: [Rhs; 2]); + // There should be two `` (method, `Struct` and array primitive). + // @count - '//*[@id="tymethod.array2"]/*[@class="code-header"]/a' 3 + // @has - '//*[@id="tymethod.array2"]/*[@class="code-header"]/a' 'array2' + // @has - '//*[@id="tymethod.array2"]/*[@class="code-header"]/a' 'Struct' + // @has - '//*[@id="tymethod.array2"]/*[@class="code-header"]/a' '2' + fn array2(&self, other: [Struct; 2]); +} From 1ef48b1bcf90eb760f1dc51e357418d19526fe37 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 26 Jul 2023 21:28:01 +0200 Subject: [PATCH 4/4] Update rustdoc tests --- .../rustdoc/array-links.link_box_generic.html | 2 +- tests/rustdoc/array-links.link_box_u32.html | 2 +- .../array-links.link_slice_generic.html | 2 +- tests/rustdoc/array-links.link_slice_u32.html | 2 +- tests/rustdoc/primitive-links.rs | 20 +++++++++---------- .../rustdoc/slice-links.link_box_generic.html | 2 +- .../slice-links.link_slice_generic.html | 2 +- .../whitespace-after-where-clause.enum.html | 2 +- .../whitespace-after-where-clause.enum2.html | 2 +- .../whitespace-after-where-clause.struct.html | 2 +- ...whitespace-after-where-clause.struct2.html | 2 +- 11 files changed, 20 insertions(+), 20 deletions(-) diff --git a/tests/rustdoc/array-links.link_box_generic.html b/tests/rustdoc/array-links.link_box_generic.html index 4616bb55138d1..3481bb6a02547 100644 --- a/tests/rustdoc/array-links.link_box_generic.html +++ b/tests/rustdoc/array-links.link_box_generic.html @@ -1 +1 @@ -pub fn delta<T>() -> MyBox<[T; 1]> \ No newline at end of file +pub fn delta<T>() -> MyBox<[T; 1]> \ No newline at end of file diff --git a/tests/rustdoc/array-links.link_box_u32.html b/tests/rustdoc/array-links.link_box_u32.html index e864ae55c9f4b..aea53c2d7e5df 100644 --- a/tests/rustdoc/array-links.link_box_u32.html +++ b/tests/rustdoc/array-links.link_box_u32.html @@ -1 +1 @@ -pub fn gamma() -> MyBox<[u32; 1]> \ No newline at end of file +pub fn gamma() -> MyBox<[u32; 1]> \ No newline at end of file diff --git a/tests/rustdoc/array-links.link_slice_generic.html b/tests/rustdoc/array-links.link_slice_generic.html index 1a3f2de1397f7..f1ca2f59bd7ca 100644 --- a/tests/rustdoc/array-links.link_slice_generic.html +++ b/tests/rustdoc/array-links.link_slice_generic.html @@ -1 +1 @@ -pub fn beta<T>() -> &'static [T; 1] \ No newline at end of file +pub fn beta<T>() -> &'static [T; 1] \ No newline at end of file diff --git a/tests/rustdoc/array-links.link_slice_u32.html b/tests/rustdoc/array-links.link_slice_u32.html index c3943e8d32122..0e022f30ac832 100644 --- a/tests/rustdoc/array-links.link_slice_u32.html +++ b/tests/rustdoc/array-links.link_slice_u32.html @@ -1 +1 @@ -pub fn alpha() -> &'static [u32; 1] \ No newline at end of file +pub fn alpha() -> &'static [u32; 1] \ No newline at end of file diff --git a/tests/rustdoc/primitive-links.rs b/tests/rustdoc/primitive-links.rs index f1814f9f2bc3d..136e77e6a3abb 100644 --- a/tests/rustdoc/primitive-links.rs +++ b/tests/rustdoc/primitive-links.rs @@ -8,11 +8,10 @@ pub struct Struct; pub trait Trait { - // There should only be one `` (not linking to reference primitive). - // @count - '//*[@id="tymethod.method"]/*[@class="code-header"]/a' 1 + // @count - '//*[@id="tymethod.method"]/*[@class="code-header"]/a' 2 // @has - '//*[@id="tymethod.method"]/*[@class="code-header"]/a' 'method' + // @has - '//*[@id="tymethod.method"]/*[@class="code-header"]/a' '&' fn method(&self, other: &Rhs); - // There should only be one `` (method and `*const`). // @count - '//*[@id="tymethod.method2"]/*[@class="code-header"]/a' 2 // @has - '//*[@id="tymethod.method2"]/*[@class="code-header"]/a' 'method2' // @has - '//*[@id="tymethod.method2"]/*[@class="code-header"]/a' '*const' @@ -41,24 +40,25 @@ pub trait Trait { // @has - '//*[@id="tymethod.tuple2"]/*[@class="code-header"]/a' 'tuple2' // @has - '//*[@id="tymethod.tuple2"]/*[@class="code-header"]/a' 'Struct' fn tuple2(&self, other: (Struct, Rhs)); - // There should be only one `` (just the method). - // @count - '//*[@id="tymethod.slice"]/*[@class="code-header"]/a' 1 + // @count - '//*[@id="tymethod.slice"]/*[@class="code-header"]/a' 2 // @has - '//*[@id="tymethod.slice"]/*[@class="code-header"]/a' 'slice' + // @has - '//*[@id="tymethod.slice"]/*[@class="code-header"]/a' '&[Rhs]' fn slice(&self, other: &[Rhs]); + // @count - '//*[@id="tymethod.ref_array"]/*[@class="code-header"]/a' 2 + // @has - '//*[@id="tymethod.ref_array"]/*[@class="code-header"]/a' 'ref_array' + // @has - '//*[@id="tymethod.ref_array"]/*[@class="code-header"]/a' '[Rhs; 2]' + fn ref_array(&self, other: &[Rhs; 2]); // There should be two `` (method and `Struct`). // @count - '//*[@id="tymethod.slice2"]/*[@class="code-header"]/a' 2 // @has - '//*[@id="tymethod.slice2"]/*[@class="code-header"]/a' 'slice2' // @has - '//*[@id="tymethod.slice2"]/*[@class="code-header"]/a' 'Struct' fn slice2(&self, other: &[Struct]); - // There should be two `` (the method and one for the array primitive). // @count - '//*[@id="tymethod.array"]/*[@class="code-header"]/a' 2 // @has - '//*[@id="tymethod.array"]/*[@class="code-header"]/a' 'array' - // @has - '//*[@id="tymethod.array"]/*[@class="code-header"]/a' '2' + // @has - '//*[@id="tymethod.array"]/*[@class="code-header"]/a' '[Rhs; 2]' fn array(&self, other: [Rhs; 2]); - // There should be two `` (method, `Struct` and array primitive). - // @count - '//*[@id="tymethod.array2"]/*[@class="code-header"]/a' 3 + // @count - '//*[@id="tymethod.array2"]/*[@class="code-header"]/a' 2 // @has - '//*[@id="tymethod.array2"]/*[@class="code-header"]/a' 'array2' // @has - '//*[@id="tymethod.array2"]/*[@class="code-header"]/a' 'Struct' - // @has - '//*[@id="tymethod.array2"]/*[@class="code-header"]/a' '2' fn array2(&self, other: [Struct; 2]); } diff --git a/tests/rustdoc/slice-links.link_box_generic.html b/tests/rustdoc/slice-links.link_box_generic.html index 1956b72257356..38aaf20808cf1 100644 --- a/tests/rustdoc/slice-links.link_box_generic.html +++ b/tests/rustdoc/slice-links.link_box_generic.html @@ -1 +1 @@ -pub fn delta<T>() -> MyBox<[T]> \ No newline at end of file +pub fn delta<T>() -> MyBox<[T]> \ No newline at end of file diff --git a/tests/rustdoc/slice-links.link_slice_generic.html b/tests/rustdoc/slice-links.link_slice_generic.html index 87b90aa15df08..fe79ca7a82da3 100644 --- a/tests/rustdoc/slice-links.link_slice_generic.html +++ b/tests/rustdoc/slice-links.link_slice_generic.html @@ -1 +1 @@ -pub fn beta<T>() -> &'static [T] \ No newline at end of file +pub fn beta<T>() -> &'static [T] \ No newline at end of file diff --git a/tests/rustdoc/whitespace-after-where-clause.enum.html b/tests/rustdoc/whitespace-after-where-clause.enum.html index 231857f070bc3..db3d3999dd56c 100644 --- a/tests/rustdoc/whitespace-after-where-clause.enum.html +++ b/tests/rustdoc/whitespace-after-where-clause.enum.html @@ -1,5 +1,5 @@
pub enum Cow<'a, B>where
     B: ToOwned<dyn Clone> + ?Sized + 'a,{
-    Borrowed(&'a B),
+    Borrowed(&'a B),
     Whatever(u32),
 }
\ No newline at end of file diff --git a/tests/rustdoc/whitespace-after-where-clause.enum2.html b/tests/rustdoc/whitespace-after-where-clause.enum2.html index 578db53bb17fe..d1d5dea582bea 100644 --- a/tests/rustdoc/whitespace-after-where-clause.enum2.html +++ b/tests/rustdoc/whitespace-after-where-clause.enum2.html @@ -1,4 +1,4 @@
pub enum Cow2<'a, B: ?Sized + ToOwned<dyn Clone> + 'a> {
-    Borrowed(&'a B),
+    Borrowed(&'a B),
     Whatever(u32),
 }
\ No newline at end of file diff --git a/tests/rustdoc/whitespace-after-where-clause.struct.html b/tests/rustdoc/whitespace-after-where-clause.struct.html index b8b548b6fd55c..d62432fe562f7 100644 --- a/tests/rustdoc/whitespace-after-where-clause.struct.html +++ b/tests/rustdoc/whitespace-after-where-clause.struct.html @@ -1,5 +1,5 @@
pub struct Struct<'a, B>where
     B: ToOwned<dyn Clone> + ?Sized + 'a,{
-    pub a: &'a B,
+    pub a: &'a B,
     pub b: u32,
 }
\ No newline at end of file diff --git a/tests/rustdoc/whitespace-after-where-clause.struct2.html b/tests/rustdoc/whitespace-after-where-clause.struct2.html index b921065d60e08..9e13bc688fdda 100644 --- a/tests/rustdoc/whitespace-after-where-clause.struct2.html +++ b/tests/rustdoc/whitespace-after-where-clause.struct2.html @@ -1,4 +1,4 @@
pub struct Struct2<'a, B: ?Sized + ToOwned<dyn Clone> + 'a> {
-    pub a: &'a B,
+    pub a: &'a B,
     pub b: u32,
 }
\ No newline at end of file