diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 1c3f9b56b474e..3e3302f8f4db7 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -1963,16 +1963,12 @@ fn sidebar_assoc_items(cx: &Context<'_>, out: &mut Buffer, it: &clean::Item) { // We want links' order to be reproducible so we don't use unstable sort. assoc_consts.sort(); - out.push_str( - "

\ - Associated Constants\ -

\ -
", + print_sidebar_block( + out, + "implementations", + "Associated Constants", + assoc_consts.iter(), ); - for line in assoc_consts { - write!(out, "{}", line); - } - out.push_str("
"); } let mut methods = v .iter() @@ -1983,14 +1979,7 @@ fn sidebar_assoc_items(cx: &Context<'_>, out: &mut Buffer, it: &clean::Item) { // We want links' order to be reproducible so we don't use unstable sort. methods.sort(); - out.push_str( - "

Methods

\ -
", - ); - for line in methods { - write!(out, "{}", line); - } - out.push_str("
"); + print_sidebar_block(out, "implementations", "Methods", methods.iter()); } } @@ -2029,14 +2018,6 @@ fn sidebar_assoc_items(cx: &Context<'_>, out: &mut Buffer, it: &clean::Item) { ret }; - let write_sidebar_links = |out: &mut Buffer, links: Vec| { - out.push_str("
"); - for link in links { - out.push_str(&link); - } - out.push_str("
"); - }; - let (synthetic, concrete): (Vec<&Impl>, Vec<&Impl>) = v.iter().partition::, _>(|i| i.inner_impl().kind.is_auto()); let (blanket_impl, concrete): (Vec<&Impl>, Vec<&Impl>) = @@ -2047,27 +2028,30 @@ fn sidebar_assoc_items(cx: &Context<'_>, out: &mut Buffer, it: &clean::Item) { let blanket_format = format_impls(blanket_impl); if !concrete_format.is_empty() { - out.push_str( - "

\ - Trait Implementations

", + print_sidebar_block( + out, + "trait-implementations", + "Trait Implementations", + concrete_format.iter(), ); - write_sidebar_links(out, concrete_format); } if !synthetic_format.is_empty() { - out.push_str( - "

\ - Auto Trait Implementations

", + print_sidebar_block( + out, + "synthetic-implementations", + "Auto Trait Implementations", + synthetic_format.iter(), ); - write_sidebar_links(out, synthetic_format); } if !blanket_format.is_empty() { - out.push_str( - "

\ - Blanket Implementations

", + print_sidebar_block( + out, + "blanket-implementations", + "Blanket Implementations", + blanket_format.iter(), ); - write_sidebar_links(out, blanket_format); } } } @@ -2127,20 +2111,14 @@ fn sidebar_deref_methods( } else { "deref-methods" }; - write!( - out, - "

Methods from {}<Target={}>

", - id, + let title = format!( + "Methods from {}<Target={}>", Escape(&format!("{:#}", impl_.inner_impl().trait_.as_ref().unwrap().print(cx))), Escape(&format!("{:#}", real_target.print(cx))), ); // We want links' order to be reproducible so we don't use unstable sort. ret.sort(); - out.push_str("
"); - for link in ret { - write!(out, "{}", link); - } - out.push_str("
"); + print_sidebar_block(out, id, &title, ret.iter()); } } @@ -2166,27 +2144,19 @@ fn sidebar_struct(cx: &Context<'_>, buf: &mut Buffer, it: &clean::Item, s: &clea let fields = get_struct_fields_name(&s.fields); if !fields.is_empty() { - if let CtorKind::Fictive = s.struct_type { - sidebar.push_str( - "

Fields

\ -
", - ); - - for field in fields { - sidebar.push_str(&field); + match s.struct_type { + CtorKind::Fictive => { + print_sidebar_block(&mut sidebar, "fields", "Fields", fields.iter()); } - - sidebar.push_str("
"); - } else if let CtorKind::Fn = s.struct_type { - sidebar - .push_str("

Tuple Fields

"); + CtorKind::Fn => print_sidebar_title(&mut sidebar, "fields", "Tuple Fields"), + CtorKind::Const => {} } } sidebar_assoc_items(cx, &mut sidebar, it); if !sidebar.is_empty() { - write!(buf, "
{}
", sidebar.into_inner()); + write!(buf, "
{}
", sidebar.into_inner()); } } @@ -2214,18 +2184,50 @@ fn extract_for_impl_name(item: &clean::Item, cx: &Context<'_>) -> Option<(String } } +/// Don't call this function directly!!! Use `print_sidebar_title` or `print_sidebar_block` instead! +fn print_sidebar_title_inner(buf: &mut Buffer, id: &str, title: &str) { + write!( + buf, + "

\ + {}\ +

", + id, title + ); +} + +fn print_sidebar_title(buf: &mut Buffer, id: &str, title: &str) { + buf.push_str("
"); + print_sidebar_title_inner(buf, id, title); + buf.push_str("
"); +} + +fn print_sidebar_block( + buf: &mut Buffer, + id: &str, + title: &str, + items: impl Iterator, +) { + buf.push_str("
"); + print_sidebar_title_inner(buf, id, title); + buf.push_str("
    "); + for item in items { + write!(buf, "
  • {}
  • ", item); + } + buf.push_str("
"); +} + fn sidebar_trait(cx: &Context<'_>, buf: &mut Buffer, it: &clean::Item, t: &clean::Trait) { - buf.write_str("
"); + buf.write_str("
"); fn print_sidebar_section( out: &mut Buffer, items: &[clean::Item], - before: &str, + id: &str, + title: &str, filter: impl Fn(&clean::Item) -> bool, - write: impl Fn(&mut Buffer, &str), - after: &str, + mapper: impl Fn(&str) -> String, ) { - let mut items = items + let mut items: Vec<&str> = items .iter() .filter_map(|m| match m.name { Some(ref name) if filter(m) => Some(name.as_str()), @@ -2235,52 +2237,44 @@ fn sidebar_trait(cx: &Context<'_>, buf: &mut Buffer, it: &clean::Item, t: &clean if !items.is_empty() { items.sort_unstable(); - out.push_str(before); - for item in items.into_iter() { - write(out, &item); - } - out.push_str(after); + print_sidebar_block(out, id, title, items.into_iter().map(mapper)); } } print_sidebar_section( buf, &t.items, - "

\ - Associated Types

", + "associated-types", + "Associated Types", |m| m.is_associated_type(), - |out, sym| write!(out, "{0}", sym), - "
", + |sym| format!("{0}", sym), ); print_sidebar_section( buf, &t.items, - "

\ - Associated Constants

", + "associated-const", + "Associated Constants", |m| m.is_associated_const(), - |out, sym| write!(out, "{0}", sym), - "
", + |sym| format!("{0}", sym), ); print_sidebar_section( buf, &t.items, - "

\ - Required Methods

", + "required-methods", + "Required Methods", |m| m.is_ty_method(), - |out, sym| write!(out, "{0}", sym), - "
", + |sym| format!("{0}", sym), ); print_sidebar_section( buf, &t.items, - "

\ - Provided Methods

", + "provided-methods", + "Provided Methods", |m| m.is_method(), - |out, sym| write!(out, "{0}", sym), - "
", + |sym| format!("{0}", sym), ); let cache = cx.cache(); @@ -2295,29 +2289,23 @@ fn sidebar_trait(cx: &Context<'_>, buf: &mut Buffer, it: &clean::Item, t: &clean if !res.is_empty() { res.sort(); - buf.push_str( - "

\ - Implementations on Foreign Types

\ -
", + print_sidebar_block( + buf, + "foreign-impls", + "Implementations on Foreign Types", + res.iter().map(|(name, id)| format!("{}", id, Escape(&name))), ); - for (name, id) in res.into_iter() { - write!(buf, "{}", id, Escape(&name)); - } - buf.push_str("
"); } } sidebar_assoc_items(cx, buf, it); - buf.push_str("

Implementors

"); + print_sidebar_title(buf, "implementors", "Implementors"); if t.is_auto { - buf.push_str( - "

Auto Implementors

", - ); + print_sidebar_title(buf, "synthetic-implementors", "Auto Implementors"); } - buf.push_str("
") + buf.push_str("") } fn sidebar_primitive(cx: &Context<'_>, buf: &mut Buffer, it: &clean::Item) { @@ -2325,7 +2313,7 @@ fn sidebar_primitive(cx: &Context<'_>, buf: &mut Buffer, it: &clean::Item) { sidebar_assoc_items(cx, &mut sidebar, it); if !sidebar.is_empty() { - write!(buf, "
{}
", sidebar.into_inner()); + write!(buf, "
{}
", sidebar.into_inner()); } } @@ -2334,7 +2322,7 @@ fn sidebar_typedef(cx: &Context<'_>, buf: &mut Buffer, it: &clean::Item) { sidebar_assoc_items(cx, &mut sidebar, it); if !sidebar.is_empty() { - write!(buf, "
{}
", sidebar.into_inner()); + write!(buf, "
{}
", sidebar.into_inner()); } } @@ -2355,22 +2343,13 @@ fn sidebar_union(cx: &Context<'_>, buf: &mut Buffer, it: &clean::Item, u: &clean let fields = get_struct_fields_name(&u.fields); if !fields.is_empty() { - sidebar.push_str( - "

Fields

\ -
", - ); - - for field in fields { - sidebar.push_str(&field); - } - - sidebar.push_str("
"); + print_sidebar_block(&mut sidebar, "fields", "Fields", fields.iter()); } sidebar_assoc_items(cx, &mut sidebar, it); if !sidebar.is_empty() { - write!(buf, "
{}
", sidebar.into_inner()); + write!(buf, "
{}
", sidebar.into_inner()); } } @@ -2388,17 +2367,13 @@ fn sidebar_enum(cx: &Context<'_>, buf: &mut Buffer, it: &clean::Item, e: &clean: .collect::>(); if !variants.is_empty() { variants.sort_unstable(); - sidebar.push_str(&format!( - "

Variants

\ -
{}
", - variants.join(""), - )); + print_sidebar_block(&mut sidebar, "variants", "Variants", variants.iter()); } sidebar_assoc_items(cx, &mut sidebar, it); if !sidebar.is_empty() { - write!(buf, "
{}
", sidebar.into_inner()); + write!(buf, "
{}
", sidebar.into_inner()); } } @@ -2569,7 +2544,15 @@ fn sidebar_module(buf: &mut Buffer, items: &[clean::Item]) { } if !sidebar.is_empty() { - write!(buf, "
    {}
", sidebar); + write!( + buf, + "
\ +
\ +
    {}
\ +
\ +
", + sidebar + ); } } @@ -2578,7 +2561,7 @@ fn sidebar_foreign_type(cx: &Context<'_>, buf: &mut Buffer, it: &clean::Item) { sidebar_assoc_items(cx, &mut sidebar, it); if !sidebar.is_empty() { - write!(buf, "
{}
", sidebar.into_inner()); + write!(buf, "
{}
", sidebar.into_inner()); } } diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 662221ae773a7..f1e0a89883ab8 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -484,10 +484,6 @@ h2.location a { overflow: hidden; } -.sidebar-links a { - white-space: nowrap; -} - .sidebar h2 { border-bottom: none; font-weight: 500; @@ -504,11 +500,14 @@ h2.location a { margin: 0; } -.sidebar-links, -.block { +.sidebar-elems .block { margin-bottom: 2em; } +.sidebar-elems .block li a { + white-space: nowrap; +} + .mobile-topbar { display: none; } diff --git a/src/test/rustdoc-gui/hash-item-expansion.goml b/src/test/rustdoc-gui/hash-item-expansion.goml index 2885978ce1f21..a680635ef8ae4 100644 --- a/src/test/rustdoc-gui/hash-item-expansion.goml +++ b/src/test/rustdoc-gui/hash-item-expansion.goml @@ -5,7 +5,7 @@ assert-attribute: ("#blanket-implementations-list > details:nth-child(2)", {"ope // We first check that the impl block is open by default. assert-attribute: ("#implementations + details", {"open": ""}) // To ensure that we will click on the currently hidden method. -assert-text: (".sidebar-links > a", "must_use") -click: ".sidebar-links > a" +assert-text: (".sidebar-elems section .block li > a", "must_use") +click: ".sidebar-elems section .block li > a" // We check that the impl block was opened as expected so that we can see the method. assert-attribute: ("#implementations + details", {"open": ""}) diff --git a/src/test/rustdoc-gui/sidebar-mobile.goml b/src/test/rustdoc-gui/sidebar-mobile.goml index 9581aa74b0f64..79f18db8fc7cd 100644 --- a/src/test/rustdoc-gui/sidebar-mobile.goml +++ b/src/test/rustdoc-gui/sidebar-mobile.goml @@ -33,7 +33,7 @@ assert-property: (".mobile-topbar", {"clientHeight": "45"}) // Check that clicking an element from the sidebar scrolls to the right place // so the target is not obscured by the topbar. click: ".sidebar-menu-toggle" -click: ".sidebar-links a" +click: ".sidebar-elems section .block li > a" assert-position: ("#method\.must_use", {"y": 45}) // Check that the bottom-most item on the sidebar menu can be scrolled fully into view. diff --git a/src/test/rustdoc-gui/sidebar.goml b/src/test/rustdoc-gui/sidebar.goml index 9505e00512f4c..6b79b00d3f786 100644 --- a/src/test/rustdoc-gui/sidebar.goml +++ b/src/test/rustdoc-gui/sidebar.goml @@ -13,15 +13,15 @@ assert-css: ("#all-types", {"color": "rgb(53, 109, 164)"}) // We check that we have the crates list and that the "current" on is "test_docs". assert-text: (".sidebar-elems .crate > ul > li > a.current", "test_docs") // And we're also supposed to have the list of items in the current module. -assert-text: (".sidebar-elems .items > ul > li:nth-child(1)", "Modules") -assert-text: (".sidebar-elems .items > ul > li:nth-child(2)", "Macros") -assert-text: (".sidebar-elems .items > ul > li:nth-child(3)", "Structs") -assert-text: (".sidebar-elems .items > ul > li:nth-child(4)", "Enums") -assert-text: (".sidebar-elems .items > ul > li:nth-child(5)", "Traits") -assert-text: (".sidebar-elems .items > ul > li:nth-child(6)", "Functions") -assert-text: (".sidebar-elems .items > ul > li:nth-child(7)", "Type Definitions") -assert-text: (".sidebar-elems .items > ul > li:nth-child(8)", "Unions") -assert-text: (".sidebar-elems .items > ul > li:nth-child(9)", "Keywords") +assert-text: (".sidebar-elems section ul > li:nth-child(1)", "Modules") +assert-text: (".sidebar-elems section ul > li:nth-child(2)", "Macros") +assert-text: (".sidebar-elems section ul > li:nth-child(3)", "Structs") +assert-text: (".sidebar-elems section ul > li:nth-child(4)", "Enums") +assert-text: (".sidebar-elems section ul > li:nth-child(5)", "Traits") +assert-text: (".sidebar-elems section ul > li:nth-child(6)", "Functions") +assert-text: (".sidebar-elems section ul > li:nth-child(7)", "Type Definitions") +assert-text: (".sidebar-elems section ul > li:nth-child(8)", "Unions") +assert-text: (".sidebar-elems section ul > li:nth-child(9)", "Keywords") assert-text: ("#structs + .item-table .item-left > a", "Foo") click: "#structs + .item-table .item-left > a" @@ -30,7 +30,7 @@ assert-count: (".sidebar .location", 2) // We check that there is no crate listed outside of the top level. assert-false: ".sidebar-elems > .crate" -click: ".sidebar-links a" +click: ".sidebar-elems section .block li > a" assert-property-false: ("html", {"scrollTop": "0"}) click: ".sidebar h2.location a" @@ -47,11 +47,11 @@ assert-text: (".sidebar > .location", "Crate lib2") // We check that we have the crates list and that the "current" on is now "lib2". assert-text: (".sidebar-elems .crate > ul > li > a.current", "lib2") // We now go to the "foobar" function page. -assert-text: (".sidebar-elems > .items > ul > li:nth-child(1)", "Modules") -assert-text: (".sidebar-elems > .items > ul > li:nth-child(2)", "Structs") -assert-text: (".sidebar-elems > .items > ul > li:nth-child(3)", "Traits") -assert-text: (".sidebar-elems > .items > ul > li:nth-child(4)", "Functions") -assert-text: (".sidebar-elems > .items > ul > li:nth-child(5)", "Type Definitions") +assert-text: (".sidebar-elems > section .block ul > li:nth-child(1)", "Modules") +assert-text: (".sidebar-elems > section .block ul > li:nth-child(2)", "Structs") +assert-text: (".sidebar-elems > section .block ul > li:nth-child(3)", "Traits") +assert-text: (".sidebar-elems > section .block ul > li:nth-child(4)", "Functions") +assert-text: (".sidebar-elems > section .block ul > li:nth-child(5)", "Type Definitions") assert-text: ("#functions + .item-table .item-left > a", "foobar") click: "#functions + .item-table .item-left > a" @@ -72,12 +72,12 @@ goto: ./sub_module/sub_sub_module/index.html assert-text: (".sidebar > .location", "Module sub_sub_module") // We check that we don't have the crate list. assert-false: ".sidebar-elems .crate" -assert-text: (".sidebar-elems .items > ul > li:nth-child(1)", "Functions") +assert-text: (".sidebar-elems > section ul > li:nth-child(1)", "Functions") assert-text: ("#functions + .item-table .item-left > a", "foo") // Links to trait implementations in the sidebar should not wrap even if they are long. goto: file://|DOC_PATH|/lib2/struct.HasALongTraitWithParams.html -assert-property: (".sidebar-links a", {"offsetHeight": 29}) +assert-property: (".sidebar-elems section .block li > a", {"offsetHeight": 29}) // Test that clicking on of the "In " headings in the sidebar links to the // appropriate anchor in index.html. diff --git a/src/test/rustdoc-gui/trait-sidebar-item-order.goml b/src/test/rustdoc-gui/trait-sidebar-item-order.goml index 38942baa0b597..d77d1dca483e0 100644 --- a/src/test/rustdoc-gui/trait-sidebar-item-order.goml +++ b/src/test/rustdoc-gui/trait-sidebar-item-order.goml @@ -1,8 +1,8 @@ // Checks that the elements in the sidebar are alphabetically sorted. goto: file://|DOC_PATH|/test_docs/trait.AnotherOne.html -assert-text: (".sidebar-links a:nth-of-type(1)", "another") -assert-text: (".sidebar-links a:nth-of-type(2)", "func1") -assert-text: (".sidebar-links a:nth-of-type(3)", "func2") -assert-text: (".sidebar-links a:nth-of-type(4)", "func3") -assert-text: (".sidebar-links a:nth-of-type(5)", "hello") -assert-text: (".sidebar-links a:nth-of-type(6)", "why_not") +assert-text: (".sidebar-elems section .block li:nth-of-type(1) > a", "another") +assert-text: (".sidebar-elems section .block li:nth-of-type(2) > a", "func1") +assert-text: (".sidebar-elems section .block li:nth-of-type(3) > a", "func2") +assert-text: (".sidebar-elems section .block li:nth-of-type(4) > a", "func3") +assert-text: (".sidebar-elems section .block li:nth-of-type(5) > a", "hello") +assert-text: (".sidebar-elems section .block li:nth-of-type(6) > a", "why_not") diff --git a/src/test/rustdoc/associated-consts.rs b/src/test/rustdoc/associated-consts.rs index 6ae5e20632e52..da50fb86cd581 100644 --- a/src/test/rustdoc/associated-consts.rs +++ b/src/test/rustdoc/associated-consts.rs @@ -10,7 +10,7 @@ pub struct Bar; // @has 'foo/struct.Bar.html' // @has - '//h3[@class="sidebar-title"]' 'Associated Constants' -// @has - '//div[@class="sidebar-elems"]//div[@class="sidebar-links"]/a' 'FOO' +// @has - '//div[@class="sidebar-elems"]//a' 'FOO' impl Trait for Bar { const FOO: u32 = 1; @@ -23,7 +23,7 @@ pub enum Foo { // @has 'foo/enum.Foo.html' // @has - '//h3[@class="sidebar-title"]' 'Associated Constants' -// @has - '//div[@class="sidebar-elems"]//div[@class="sidebar-links"]/a' 'FOO' +// @has - '//div[@class="sidebar-elems"]//a' 'FOO' impl Trait for Foo { const FOO: u32 = 1; diff --git a/src/test/rustdoc/deref-mut-methods.rs b/src/test/rustdoc/deref-mut-methods.rs index 0e27fc90b69a6..fdf8434224f83 100644 --- a/src/test/rustdoc/deref-mut-methods.rs +++ b/src/test/rustdoc/deref-mut-methods.rs @@ -9,7 +9,7 @@ impl Foo { } // @has foo/struct.Bar.html -// @has - '//div[@class="sidebar-links"]/a[@href="#method.foo"]' 'foo' +// @has - '//*[@class="sidebar-elems"]//*[@class="block"]//a[@href="#method.foo"]' 'foo' pub struct Bar { foo: Foo, } diff --git a/src/test/rustdoc/deref-recursive-pathbuf.rs b/src/test/rustdoc/deref-recursive-pathbuf.rs index 9ab338ca9b1d1..746df9c804ebb 100644 --- a/src/test/rustdoc/deref-recursive-pathbuf.rs +++ b/src/test/rustdoc/deref-recursive-pathbuf.rs @@ -8,9 +8,9 @@ // @has '-' '//*[@id="deref-methods-Path"]' 'Methods from Deref' // @has '-' '//*[@class="impl-items"]//*[@id="method.exists"]' 'pub fn exists(&self)' // @has '-' '//*[@class="sidebar-title"]/a[@href="#deref-methods-PathBuf"]' 'Methods from Deref' -// @has '-' '//*[@class="sidebar-links"]/a[@href="#method.as_path"]' 'as_path' +// @has '-' '//*[@class="sidebar-elems"]//*[@class="block"]//a[@href="#method.as_path"]' 'as_path' // @has '-' '//*[@class="sidebar-title"]/a[@href="#deref-methods-Path"]' 'Methods from Deref' -// @has '-' '//*[@class="sidebar-links"]/a[@href="#method.exists"]' 'exists' +// @has '-' '//*[@class="sidebar-elems"]//*[@class="block"]//a[@href="#method.exists"]' 'exists' #![crate_name = "foo"] diff --git a/src/test/rustdoc/deref-recursive.rs b/src/test/rustdoc/deref-recursive.rs index c07e048b0651c..d5f8473f2842d 100644 --- a/src/test/rustdoc/deref-recursive.rs +++ b/src/test/rustdoc/deref-recursive.rs @@ -8,9 +8,9 @@ // @has '-' '//*[@id="deref-methods-Baz"]' 'Methods from Deref' // @has '-' '//*[@class="impl-items"]//*[@id="method.baz"]' 'pub fn baz(&self)' // @has '-' '//*[@class="sidebar-title"]/a[@href="#deref-methods-Bar"]' 'Methods from Deref' -// @has '-' '//*[@class="sidebar-links"]/a[@href="#method.bar"]' 'bar' +// @has '-' '//*[@class="sidebar-elems"]//section//a[@href="#method.bar"]' 'bar' // @has '-' '//*[@class="sidebar-title"]/a[@href="#deref-methods-Baz"]' 'Methods from Deref' -// @has '-' '//*[@class="sidebar-links"]/a[@href="#method.baz"]' 'baz' +// @has '-' '//*[@class="sidebar-elems"]//section//a[@href="#method.baz"]' 'baz' #![crate_name = "foo"] diff --git a/src/test/rustdoc/deref-typedef.rs b/src/test/rustdoc/deref-typedef.rs index ad7a96c5dad1f..28f977e315abf 100644 --- a/src/test/rustdoc/deref-typedef.rs +++ b/src/test/rustdoc/deref-typedef.rs @@ -7,10 +7,10 @@ // @has '-' '//*[@class="impl-items"]//*[@id="method.foo_c"]' 'pub fn foo_c(&self)' // @has '-' '//*[@class="impl-items"]//*[@id="method.foo_j"]' 'pub fn foo_j(&self)' // @has '-' '//*[@class="sidebar-title"]/a[@href="#deref-methods-FooJ"]' 'Methods from Deref' -// @has '-' '//*[@class="sidebar-links"]/a[@href="#method.foo_a"]' 'foo_a' -// @has '-' '//*[@class="sidebar-links"]/a[@href="#method.foo_b"]' 'foo_b' -// @has '-' '//*[@class="sidebar-links"]/a[@href="#method.foo_c"]' 'foo_c' -// @has '-' '//*[@class="sidebar-links"]/a[@href="#method.foo_j"]' 'foo_j' +// @has '-' '//*[@class="sidebar-elems"]//section//a[@href="#method.foo_a"]' 'foo_a' +// @has '-' '//*[@class="sidebar-elems"]//section//a[@href="#method.foo_b"]' 'foo_b' +// @has '-' '//*[@class="sidebar-elems"]//section//a[@href="#method.foo_c"]' 'foo_c' +// @has '-' '//*[@class="sidebar-elems"]//section//a[@href="#method.foo_j"]' 'foo_j' pub struct FooA; pub type FooB = FooA; diff --git a/src/test/rustdoc/double-quote-escape.rs b/src/test/rustdoc/double-quote-escape.rs index 546af2c121adb..b7bbf140cfd00 100644 --- a/src/test/rustdoc/double-quote-escape.rs +++ b/src/test/rustdoc/double-quote-escape.rs @@ -8,5 +8,5 @@ pub trait Foo { pub struct Bar; // @has foo/struct.Bar.html -// @has - '//*[@class="sidebar-links"]/a[@href="#impl-Foo%3Cunsafe%20extern%20%22C%22%20fn()%3E"]' 'Foo' +// @has - '//*[@class="sidebar-elems"]//section//a[@href="#impl-Foo%3Cunsafe%20extern%20%22C%22%20fn()%3E"]' 'Foo' impl Foo for Bar {} diff --git a/src/test/rustdoc/generic-impl.rs b/src/test/rustdoc/generic-impl.rs index 0f6cba93f9569..1268c9587f847 100644 --- a/src/test/rustdoc/generic-impl.rs +++ b/src/test/rustdoc/generic-impl.rs @@ -7,7 +7,7 @@ pub struct Bar; // @has foo/struct.Foo.html '//*[@id="impl-ToString"]//h3[@class="code-header in-band"]' 'impl ToString for T' pub struct Foo; -// @has foo/struct.Foo.html '//div[@class="sidebar-links"]/a[@href="#impl-ToString"]' 'ToString' +// @has foo/struct.Foo.html '//*[@class="sidebar-elems"]//section//a[@href="#impl-ToString"]' 'ToString' impl fmt::Display for Foo { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { diff --git a/src/test/rustdoc/method-list.rs b/src/test/rustdoc/method-list.rs index 9f24e817fd3eb..50f4af3aaafef 100644 --- a/src/test/rustdoc/method-list.rs +++ b/src/test/rustdoc/method-list.rs @@ -1,8 +1,8 @@ #![crate_name = "foo"] // @has foo/struct.Foo.html -// @has - '//*[@class="sidebar-links"]/a' 'super_long_name' -// @has - '//*[@class="sidebar-links"]/a' 'Disp' +// @has - '//*[@class="sidebar-elems"]//section//a' 'super_long_name' +// @has - '//*[@class="sidebar-elems"]//section//a' 'Disp' pub struct Foo(usize); impl Foo { diff --git a/src/test/rustdoc/negative-impl-sidebar.rs b/src/test/rustdoc/negative-impl-sidebar.rs index d63ab346045ee..b995fff1f9aa7 100644 --- a/src/test/rustdoc/negative-impl-sidebar.rs +++ b/src/test/rustdoc/negative-impl-sidebar.rs @@ -5,5 +5,5 @@ pub struct Foo; // @has foo/struct.Foo.html // @has - '//*[@class="sidebar-title"]/a[@href="#trait-implementations"]' 'Trait Implementations' -// @has - '//*[@class="sidebar-links"]/a' '!Sync' +// @has - '//*[@class="sidebar-elems"]//section//a' '!Sync' impl !Sync for Foo {} diff --git a/src/test/rustdoc/recursive-deref-sidebar.rs b/src/test/rustdoc/recursive-deref-sidebar.rs index 65a7debc2538d..619f40eff8984 100644 --- a/src/test/rustdoc/recursive-deref-sidebar.rs +++ b/src/test/rustdoc/recursive-deref-sidebar.rs @@ -9,13 +9,13 @@ impl B { pub fn foo_b(&self) {} } pub struct C {} impl C { pub fn foo_c(&self) {} } -// @has recursive_deref_sidebar/struct.A.html '//div[@class="sidebar-links"]' 'foo_b' +// @has recursive_deref_sidebar/struct.A.html '//*[@class="sidebar-elems"]//section' 'foo_b' impl Deref for A { type Target = B; fn deref(&self) -> &B { todo!() } } -// @has recursive_deref_sidebar/struct.A.html '//div[@class="sidebar-links"]' 'foo_c' +// @has recursive_deref_sidebar/struct.A.html '//*[@class="sidebar-elems"]//section' 'foo_c' impl Deref for B { type Target = C; fn deref(&self) -> &C { todo!() } diff --git a/src/test/rustdoc/sidebar-items.rs b/src/test/rustdoc/sidebar-items.rs index ee670e88b5cb4..375cad9da7f88 100644 --- a/src/test/rustdoc/sidebar-items.rs +++ b/src/test/rustdoc/sidebar-items.rs @@ -2,13 +2,13 @@ // @has foo/trait.Foo.html // @has - '//*[@class="sidebar-title"]/a[@href="#required-methods"]' 'Required Methods' -// @has - '//*[@class="sidebar-links"]/a' 'bar' +// @has - '//*[@class="sidebar-elems"]//section//a' 'bar' // @has - '//*[@class="sidebar-title"]/a[@href="#provided-methods"]' 'Provided Methods' -// @has - '//*[@class="sidebar-links"]/a' 'foo' +// @has - '//*[@class="sidebar-elems"]//section//a' 'foo' // @has - '//*[@class="sidebar-title"]/a[@href="#associated-const"]' 'Associated Constants' -// @has - '//*[@class="sidebar-links"]/a' 'BAR' +// @has - '//*[@class="sidebar-elems"]//section//a' 'BAR' // @has - '//*[@class="sidebar-title"]/a[@href="#associated-types"]' 'Associated Types' -// @has - '//*[@class="sidebar-links"]/a' 'Output' +// @has - '//*[@class="sidebar-elems"]//section//a' 'Output' pub trait Foo { const BAR: u32 = 0; type Output: ?Sized; @@ -19,9 +19,9 @@ pub trait Foo { // @has foo/struct.Bar.html // @has - '//*[@class="sidebar-title"]/a[@href="#fields"]' 'Fields' -// @has - '//*[@class="sidebar-links"]/a[@href="#structfield.f"]' 'f' -// @has - '//*[@class="sidebar-links"]/a[@href="#structfield.u"]' 'u' -// @!has - '//*[@class="sidebar-links"]/a' 'waza' +// @has - '//*[@class="sidebar-elems"]//section//a[@href="#structfield.f"]' 'f' +// @has - '//*[@class="sidebar-elems"]//section//a[@href="#structfield.u"]' 'u' +// @!has - '//*[@class="sidebar-elems"]//section//a' 'waza' pub struct Bar { pub f: u32, pub u: u32, @@ -30,8 +30,8 @@ pub struct Bar { // @has foo/enum.En.html // @has - '//*[@class="sidebar-title"]/a[@href="#variants"]' 'Variants' -// @has - '//*[@class="sidebar-links"]/a' 'Foo' -// @has - '//*[@class="sidebar-links"]/a' 'Bar' +// @has - '//*[@class="sidebar-elems"]//section//a' 'Foo' +// @has - '//*[@class="sidebar-elems"]//section//a' 'Bar' pub enum En { Foo, Bar, @@ -39,9 +39,9 @@ pub enum En { // @has foo/union.MyUnion.html // @has - '//*[@class="sidebar-title"]/a[@href="#fields"]' 'Fields' -// @has - '//*[@class="sidebar-links"]/a[@href="#structfield.f1"]' 'f1' -// @has - '//*[@class="sidebar-links"]/a[@href="#structfield.f2"]' 'f2' -// @!has - '//*[@class="sidebar-links"]/a' 'waza' +// @has - '//*[@class="sidebar-elems"]//section//a[@href="#structfield.f1"]' 'f1' +// @has - '//*[@class="sidebar-elems"]//section//a[@href="#structfield.f2"]' 'f2' +// @!has - '//*[@class="sidebar-elems"]//section//a' 'waza' pub union MyUnion { pub f1: u32, pub f2: f32, diff --git a/src/test/rustdoc/sidebar-link-generation.rs b/src/test/rustdoc/sidebar-link-generation.rs index 76b77b9bcbb6b..7858f35a2616e 100644 --- a/src/test/rustdoc/sidebar-link-generation.rs +++ b/src/test/rustdoc/sidebar-link-generation.rs @@ -1,6 +1,6 @@ #![crate_name = "foo"] -// @has foo/struct.SomeStruct.html '//*[@class="sidebar-links"]/a[@href="#method.some_fn-1"]' \ +// @has foo/struct.SomeStruct.html '//*[@class="sidebar-elems"]//section//li/a[@href="#method.some_fn-1"]' \ // "some_fn" pub struct SomeStruct { _inner: T } diff --git a/src/test/rustdoc/sidebar-links-to-foreign-impl.rs b/src/test/rustdoc/sidebar-links-to-foreign-impl.rs index 63e486b8834e4..1551503965999 100644 --- a/src/test/rustdoc/sidebar-links-to-foreign-impl.rs +++ b/src/test/rustdoc/sidebar-links-to-foreign-impl.rs @@ -5,9 +5,9 @@ // @has foo/trait.Foo.html // @has - '//*[@class="sidebar-title"]/a[@href="#foreign-impls"]' 'Implementations on Foreign Types' // @has - '//h2[@id="foreign-impls"]' 'Implementations on Foreign Types' -// @has - '//*[@class="sidebar-links"]/a[@href="#impl-Foo-for-u32"]' 'u32' +// @has - '//*[@class="sidebar-elems"]//section//a[@href="#impl-Foo-for-u32"]' 'u32' // @has - '//*[@id="impl-Foo-for-u32"]//h3[@class="code-header in-band"]' 'impl Foo for u32' -// @has - '//*[@class="sidebar-links"]/a[@href="#impl-Foo-for-%26%27a%20str"]' "&'a str" +// @has - '//*[@class="sidebar-elems"]//section//a[@href="#impl-Foo-for-%26%27a%20str"]' "&'a str" // @has - '//*[@id="impl-Foo-for-%26%27a%20str"]//h3[@class="code-header in-band"]' "impl<'a> Foo for &'a str" pub trait Foo {}