From 19e020029670ca422978c98209d1ed712a041c45 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Mon, 28 Nov 2022 10:21:19 -0700 Subject: [PATCH] rustdoc: remove `fnname` CSS class that's styled exactly like `fn` It's not obvious why this was ever a separate class name, since even in c4219a478354b464079b1b7ab081e071e8e39765 when it was first added, it was styled identically to regular `fn` links. --- src/librustdoc/html/render/mod.rs | 4 ++-- src/librustdoc/html/static/css/rustdoc.css | 1 - src/test/rustdoc-gui/item-decl-colors.goml | 2 +- src/test/rustdoc-gui/notable-trait.goml | 4 ++-- src/test/rustdoc-gui/where-whitespace.goml | 4 ++-- src/test/rustdoc/anchors.no_method_anchor.html | 2 +- .../rustdoc/anchors.no_trait_method_anchor.html | 2 +- src/test/rustdoc/anchors.no_tymethod_anchor.html | 2 +- .../decl-trailing-whitespace.declaration.html | 10 +++++----- .../extern-default-method.no_href_on_anchor.html | 2 +- src/test/rustdoc/extern-default-method.rs | 6 +++--- src/test/rustdoc/foreigntype.rs | 2 +- .../issue-24183.method_no_where_self_sized.html | 2 +- .../rustdoc/trait-impl-items-links-and-anchors.rs | 14 +++++++------- .../rustdoc/where.SWhere_TraitWhere_item-decl.html | 4 ++-- .../whitespace-after-where-clause.trait.html | 4 ++-- .../whitespace-after-where-clause.trait2.html | 4 ++-- 17 files changed, 34 insertions(+), 35 deletions(-) diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index ef28e2a855a..08f8096b07b 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -847,10 +847,10 @@ fn assoc_method( render_attributes_in_code(w, meth); (0, "", Ending::Newline) }; - w.reserve(header_len + "{".len() + "".len()); + w.reserve(header_len + "{".len() + "".len()); write!( w, - "{indent}{vis}{constness}{asyncness}{unsafety}{defaultness}{abi}fn {name}\ + "{indent}{vis}{constness}{asyncness}{unsafety}{defaultness}{abi}fn {name}\ {generics}{decl}{notable_traits}{where_clause}", indent = indent_str, vis = vis, diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 98a5b761ded..33e93225868 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -242,7 +242,6 @@ h1 a, } .content span.fn, .content a.fn, -.content .fnname, .content span.method, .content a.method, .content span.tymethod, .content a.tymethod { color: var(--function-link-color); diff --git a/src/test/rustdoc-gui/item-decl-colors.goml b/src/test/rustdoc-gui/item-decl-colors.goml index 9a46f256056..2e07f19b13d 100644 --- a/src/test/rustdoc-gui/item-decl-colors.goml +++ b/src/test/rustdoc-gui/item-decl-colors.goml @@ -30,7 +30,7 @@ define-function: ( ("assert-css", (".item-decl .primitive", {"color": |primitive_color|}, ALL)), ("goto", "file://" + |DOC_PATH| + "/test_docs/trait.TraitWithoutGenerics.html"), ("assert-css", (".item-decl .constant", {"color": |constant_color|}, ALL)), - ("assert-css", (".item-decl .fnname", {"color": |fn_color|}, ALL)), + ("assert-css", (".item-decl .fn", {"color": |fn_color|}, ALL)), ("assert-css", (".item-decl .associatedtype", {"color": |assoc_type_color|}, ALL)), ], ) diff --git a/src/test/rustdoc-gui/notable-trait.goml b/src/test/rustdoc-gui/notable-trait.goml index 7e24af47ee8..7d4bd27d42d 100644 --- a/src/test/rustdoc-gui/notable-trait.goml +++ b/src/test/rustdoc-gui/notable-trait.goml @@ -226,7 +226,7 @@ assert: "#method\.create_an_iterator_from_read .notable-traits:focus" // Now we check that the focus isn't given back to the wrong item when opening // another popover. store-window-property: (scroll, "scrollY") -click: "#method\.create_an_iterator_from_read .fnname" +click: "#method\.create_an_iterator_from_read .fn" // We ensure that the scroll position changed. assert-window-property-false: {"scrollY": |scroll|} // Store the new position. @@ -240,7 +240,7 @@ assert-window-property-false: {"scrollY": |scroll|} // Same but with Escape handling. store-window-property: (scroll, "scrollY") -click: "#method\.create_an_iterator_from_read .fnname" +click: "#method\.create_an_iterator_from_read .fn" // We ensure that the scroll position changed. assert-window-property-false: {"scrollY": |scroll|} // Store the new position. diff --git a/src/test/rustdoc-gui/where-whitespace.goml b/src/test/rustdoc-gui/where-whitespace.goml index 776c8ec721e..41596a9bccc 100644 --- a/src/test/rustdoc-gui/where-whitespace.goml +++ b/src/test/rustdoc-gui/where-whitespace.goml @@ -5,13 +5,13 @@ show-text: true // line than "pub trait Whitespace"). compare-elements-position-false: (".item-decl code", ".where.fmt-newline", ("y")) // And that the code following it isn't on the same line either. -compare-elements-position-false: (".item-decl .fnname", ".where.fmt-newline", ("y")) +compare-elements-position-false: (".item-decl .fn", ".where.fmt-newline", ("y")) goto: "file://" + |DOC_PATH| + "/lib2/struct.WhereWhitespace.html" // We make the screen a bit wider to ensure that the trait impl is on one line. size: (915, 915) -compare-elements-position-false: ("#method\.new .fnname", "#method\.new .where.fmt-newline", ("y")) +compare-elements-position-false: ("#method\.new .fn", "#method\.new .where.fmt-newline", ("y")) // We ensure that both the trait name and the struct name are on the same line in // "impl Whitespace<&K> for WhereWhitespace". compare-elements-position: ( diff --git a/src/test/rustdoc/anchors.no_method_anchor.html b/src/test/rustdoc/anchors.no_method_anchor.html index 521fdcb7877..b9ec8bf4c09 100644 --- a/src/test/rustdoc/anchors.no_method_anchor.html +++ b/src/test/rustdoc/anchors.no_method_anchor.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/test/rustdoc/anchors.no_trait_method_anchor.html b/src/test/rustdoc/anchors.no_trait_method_anchor.html index d7bd525ff0f..4308ddad412 100644 --- a/src/test/rustdoc/anchors.no_trait_method_anchor.html +++ b/src/test/rustdoc/anchors.no_trait_method_anchor.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/test/rustdoc/anchors.no_tymethod_anchor.html b/src/test/rustdoc/anchors.no_tymethod_anchor.html index e668e5e4db1..91eed8a3742 100644 --- a/src/test/rustdoc/anchors.no_tymethod_anchor.html +++ b/src/test/rustdoc/anchors.no_tymethod_anchor.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/test/rustdoc/decl-trailing-whitespace.declaration.html b/src/test/rustdoc/decl-trailing-whitespace.declaration.html index e60caaeff38..02b51b34461 100644 --- a/src/test/rustdoc/decl-trailing-whitespace.declaration.html +++ b/src/test/rustdoc/decl-trailing-whitespace.declaration.html @@ -1,7 +1,7 @@ pub trait Write { - fn poll_write(
        self: Option<String>,
        cx: &mut Option<String>,
        buf: &mut [usize]
    ) -> Option<Result<usize, Error>>; - fn poll_flush(
        self: Option<String>,
        cx: &mut Option<String>
    ) -> Option<Result<(), Error>>; - fn poll_close(
        self: Option<String>,
        cx: &mut Option<String>
    ) -> Option<Result<(), Error>>; + fn poll_write(
        self: Option<String>,
        cx: &mut Option<String>,
        buf: &mut [usize]
    ) -> Option<Result<usize, Error>>; + fn poll_flush(
        self: Option<String>,
        cx: &mut Option<String>
    ) -> Option<Result<(), Error>>; + fn poll_close(
        self: Option<String>,
        cx: &mut Option<String>
    ) -> Option<Result<(), Error>>; - fn poll_write_vectored(
        self: Option<String>,
        cx: &mut Option<String>,
        bufs: &[usize]
    ) -> Option<Result<usize, Error>> { ... } -}
+ fn poll_write_vectored(
        self: Option<String>,
        cx: &mut Option<String>,
        bufs: &[usize]
    ) -> Option<Result<usize, Error>> { ... } +} \ No newline at end of file diff --git a/src/test/rustdoc/extern-default-method.no_href_on_anchor.html b/src/test/rustdoc/extern-default-method.no_href_on_anchor.html index dab0a649529..ef14836ccb8 100644 --- a/src/test/rustdoc/extern-default-method.no_href_on_anchor.html +++ b/src/test/rustdoc/extern-default-method.no_href_on_anchor.html @@ -1 +1 @@ -provided(&self) \ No newline at end of file +provided(&self) \ No newline at end of file diff --git a/src/test/rustdoc/extern-default-method.rs b/src/test/rustdoc/extern-default-method.rs index 8139f5b2619..fc28b230a5f 100644 --- a/src/test/rustdoc/extern-default-method.rs +++ b/src/test/rustdoc/extern-default-method.rs @@ -11,13 +11,13 @@ // However, the method in the trait impl should *not* have a link (an `href` attribute) to // its corresponding item in the trait declaration since it would otherwise be broken. // -// In older versions of rustdoc, the impl item (`a[@class="fnname"]`) used to link to +// In older versions of rustdoc, the impl item (`a[@class="fn"]`) used to link to // `#method.provided` – i.e. "to itself". Put in quotes since that was actually incorrect in // general: If the type `Struct` also had an inherent method called `provided`, the impl item // would link to that one even though those two methods are distinct items! // @count extern_default_method/struct.Struct.html '//*[@id="method.provided"]' 1 -// @count extern_default_method/struct.Struct.html '//*[@id="method.provided"]//a[@class="fnname"]' 1 -// @snapshot no_href_on_anchor - '//*[@id="method.provided"]//a[@class="fnname"]' +// @count extern_default_method/struct.Struct.html '//*[@id="method.provided"]//a[@class="fn"]' 1 +// @snapshot no_href_on_anchor - '//*[@id="method.provided"]//a[@class="fn"]' // @has extern_default_method/struct.Struct.html '//*[@id="method.provided"]//a[@class="anchor"]/@href' #method.provided pub use ext::Struct; diff --git a/src/test/rustdoc/foreigntype.rs b/src/test/rustdoc/foreigntype.rs index 891cdd5fed7..29f9c2926e9 100644 --- a/src/test/rustdoc/foreigntype.rs +++ b/src/test/rustdoc/foreigntype.rs @@ -6,7 +6,7 @@ } impl ExtType { - // @has - '//a[@class="fnname"]' 'do_something' + // @has - '//a[@class="fn"]' 'do_something' pub fn do_something(&self) {} } diff --git a/src/test/rustdoc/inline_cross/issue-24183.method_no_where_self_sized.html b/src/test/rustdoc/inline_cross/issue-24183.method_no_where_self_sized.html index 6955a961499..f3c1c045202 100644 --- a/src/test/rustdoc/inline_cross/issue-24183.method_no_where_self_sized.html +++ b/src/test/rustdoc/inline_cross/issue-24183.method_no_where_self_sized.html @@ -1 +1 @@ -

fn touch(&self)

\ No newline at end of file +

fn touch(&self)

\ No newline at end of file diff --git a/src/test/rustdoc/trait-impl-items-links-and-anchors.rs b/src/test/rustdoc/trait-impl-items-links-and-anchors.rs index fba594c3827..a125fa03679 100644 --- a/src/test/rustdoc/trait-impl-items-links-and-anchors.rs +++ b/src/test/rustdoc/trait-impl-items-links-and-anchors.rs @@ -13,10 +13,10 @@ impl MyTrait for String { // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedconstant.VALUE-1"]//a[@class="constant"]/@href' #associatedconstant.VALUE // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedconstant.VALUE-1"]//a[@class="anchor"]/@href' #associatedconstant.VALUE-1 const VALUE: u32 = 5; - // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.trait_function"]//a[@class="fnname"]/@href' #tymethod.trait_function + // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.trait_function"]//a[@class="fn"]/@href' #tymethod.trait_function // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.trait_function"]//a[@class="anchor"]/@href' #method.trait_function fn trait_function(&self) {} - // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.defaulted_override-1"]//a[@class="fnname"]/@href' #method.defaulted_override + // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.defaulted_override-1"]//a[@class="fn"]/@href' #method.defaulted_override // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.defaulted_override-1"]//a[@class="anchor"]/@href' #method.defaulted_override-1 fn defaulted_override(&self) {} } @@ -28,10 +28,10 @@ impl MyTrait for Vec { // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedconstant.VALUE-2"]//a[@class="constant"]/@href' #associatedconstant.VALUE // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedconstant.VALUE-2"]//a[@class="anchor"]/@href' #associatedconstant.VALUE-2 const VALUE: u32 = 5; - // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.trait_function"]//a[@class="fnname"]/@href' #tymethod.trait_function + // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.trait_function"]//a[@class="fn"]/@href' #tymethod.trait_function // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.trait_function-1"]//a[@class="anchor"]/@href' #method.trait_function-1 fn trait_function(&self) {} - // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.defaulted_override-2"]//a[@class="fnname"]/@href' #method.defaulted_override + // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.defaulted_override-2"]//a[@class="fn"]/@href' #method.defaulted_override // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.defaulted_override-2"]//a[@class="anchor"]/@href' #method.defaulted_override-2 fn defaulted_override(&self) {} } @@ -45,13 +45,13 @@ impl MyTrait for MyStruct { // @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="associatedconstant.VALUE"]//a[@class="constant"]/@href' trait.MyTrait.html#associatedconstant.VALUE // @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="associatedconstant.VALUE"]//a[@class="anchor"]/@href' #associatedconstant.VALUE const VALUE: u32 = 20; - // @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="method.trait_function"]//a[@class="fnname"]/@href' trait.MyTrait.html#tymethod.trait_function + // @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="method.trait_function"]//a[@class="fn"]/@href' trait.MyTrait.html#tymethod.trait_function // @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="method.trait_function"]//a[@class="anchor"]/@href' #method.trait_function fn trait_function(&self) {} - // @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="method.defaulted_override"]//a[@class="fnname"]/@href' trait.MyTrait.html#method.defaulted_override + // @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="method.defaulted_override"]//a[@class="fn"]/@href' trait.MyTrait.html#method.defaulted_override // @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="method.defaulted_override"]//a[@class="anchor"]/@href' #method.defaulted_override fn defaulted_override(&self) {} - // @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="method.defaulted"]//a[@class="fnname"]/@href' trait.MyTrait.html#method.defaulted + // @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="method.defaulted"]//a[@class="fn"]/@href' trait.MyTrait.html#method.defaulted // @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="method.defaulted"]//a[@class="anchor"]/@href' #method.defaulted } diff --git a/src/test/rustdoc/where.SWhere_TraitWhere_item-decl.html b/src/test/rustdoc/where.SWhere_TraitWhere_item-decl.html index 24ab77703d1..d5d6c556d80 100644 --- a/src/test/rustdoc/where.SWhere_TraitWhere_item-decl.html +++ b/src/test/rustdoc/where.SWhere_TraitWhere_item-decl.html @@ -1,8 +1,8 @@
pub trait TraitWhere {
     type Item<'a>
    where
        Self: 'a
; - fn func(self)
    where
        Self: Sized
, + fn func(self)
    where
        Self: Sized
, { ... } - fn lines(self) -> Lines<Self>
    where
        Self: Sized
, + fn lines(self) -> Lines<Self>
    where
        Self: Sized
, { ... } }
\ No newline at end of file diff --git a/src/test/rustdoc/whitespace-after-where-clause.trait.html b/src/test/rustdoc/whitespace-after-where-clause.trait.html index 16b55823703..50cfe362328 100644 --- a/src/test/rustdoc/whitespace-after-where-clause.trait.html +++ b/src/test/rustdoc/whitespace-after-where-clause.trait.html @@ -1,6 +1,6 @@
pub trait ToOwned<T>where
    T: Clone,
{ type Owned; - fn to_owned(&self) -> Self::Owned; - fn whatever(&self) -> T; + fn to_owned(&self) -> Self::Owned; + fn whatever(&self) -> T; }
\ No newline at end of file diff --git a/src/test/rustdoc/whitespace-after-where-clause.trait2.html b/src/test/rustdoc/whitespace-after-where-clause.trait2.html index eeca6e1f500..21eb89b7501 100644 --- a/src/test/rustdoc/whitespace-after-where-clause.trait2.html +++ b/src/test/rustdoc/whitespace-after-where-clause.trait2.html @@ -1,6 +1,6 @@
pub trait ToOwned2<T: Clone> {
     type Owned;
 
-    fn to_owned(&self) -> Self::Owned;
-    fn whatever(&self) -> T;
+    fn to_owned(&self) -> Self::Owned;
+    fn whatever(&self) -> T;
 }
\ No newline at end of file