diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index c5847d3614602..f543568ec1f0e 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -3051,7 +3051,7 @@ fn item_trait( let item_type = m.type_(); let id = cx.derive_id(format!("{}.{}", item_type, name)); let ns_id = cx.derive_id(format!("{}.{}", name, item_type.name_space())); - write!(w, "{extra}

", + write!(w, "

{extra}", extra = render_spotlight_traits(m)?, id = id, ns_id = ns_id)?; @@ -3436,7 +3436,7 @@ fn item_union(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item, let id = format!("{}.{}", ItemType::StructField, name); write!(w, "\ \ - \ + {name}: {ty}\ ", id = id, name = name, @@ -3991,8 +3991,7 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi None => "impl".to_string(), }); if let Some(use_absolute) = use_absolute { - write!(w, "

\ -
", id)?; + write!(w, "

", id)?; fmt_impl_for_trait_page(&i.inner_impl(), w, use_absolute)?; if show_def_docs { for it in &i.inner_impl().items { @@ -4006,22 +4005,18 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi } write!(w, "")?; } else { - write!(w, "

\ -
{}", - id, i.inner_impl())?; + write!(w, "

{}", + id, i.inner_impl() + )?; } write!(w, "", id)?; - write!(w, "

")?; let since = i.impl_item.stability.as_ref().map(|s| &s.since[..]); + render_stability_since_raw(w, since, outer_version)?; if let Some(l) = (Item { item: &i.impl_item, cx: cx }).src_href() { - write!(w, "
")?; - render_stability_since_raw(w, since, outer_version)?; write!(w, "[src]", l, "goto source code")?; - } else { - render_stability_since_raw(w, since, outer_version)?; } - write!(w, "

")?; + write!(w, "")?; if let Some(ref dox) = cx.shared.maybe_collapsed_doc_value(&i.impl_item) { let mut ids = cx.id_map.borrow_mut(); write!(w, "
{}
", @@ -4057,20 +4052,15 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi let ns_id = cx.derive_id(format!("{}.{}", name, item_type.name_space())); write!(w, "

", id, item_type, extra_class)?; write!(w, "{}", spotlight_decl(decl)?)?; - write!(w, "
", ns_id)?; + write!(w, "", ns_id)?; render_assoc_item(w, item, link.anchor(&id), ItemType::Impl)?; write!(w, "")?; + render_stability_since_raw(w, item.stable_since(), outer_version)?; if let Some(l) = (Item { cx, item }).src_href() { - write!(w, "")?; - write!(w, "
")?; - render_stability_since_raw(w, item.stable_since(), outer_version)?; - write!(w, "[src]
", + write!(w, "[src]", l, "goto source code")?; - } else { - write!(w, "
")?; - render_stability_since_raw(w, item.stable_since(), outer_version)?; } - write!(w, "

")?; + write!(w, "")?; } } clean::TypedefItem(ref tydef, _) => { @@ -4082,40 +4072,18 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi write!(w, "
")?; } clean::AssociatedConstItem(ref ty, ref default) => { - let mut version = String::new(); - - render_stability_since_raw(&mut version, item.stable_since(), outer_version)?; - let id = cx.derive_id(format!("{}.{}", item_type, name)); let ns_id = cx.derive_id(format!("{}.{}", name, item_type.name_space())); write!(w, "

", id, item_type, extra_class)?; - if !version.is_empty() { - write!(w, "
", ns_id)?; - } else { - write!(w, "", ns_id)?; - } + write!(w, "", ns_id)?; assoc_const(w, item, ty, default.as_ref(), link.anchor(&id))?; - if !version.is_empty() { - write!(w, "")?; - } - let src = if let Some(l) = (Item { cx, item }).src_href() { - if !version.is_empty() { - write!(w, "")?; - write!(w, "
{}", version)?; - } - format!("[src]", - l, "goto source code") - } else { - if !version.is_empty() { - write!(w, "
{}", version)?; - } - String::new() - }; - if version.is_empty() { - write!(w, "{}", src)?; - } else { - write!(w, "{}

", src)?; + write!(w, "")?; + render_stability_since_raw(w, item.stable_since(), outer_version)?; + if let Some(l) = (Item { cx, item }).src_href() { + write!(w, "[src]", + l, "goto source code")?; } + write!(w, "")?; } clean::AssociatedTypeItem(ref bounds, ref default) => { let id = cx.derive_id(format!("{}.{}", item_type, name)); diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 02ffcf478f9ad..b376ab804126a 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -2409,8 +2409,17 @@ if (!DOMTokenList.prototype.remove) { e.remove(); }); onEachLazy(main.childNodes, function(e) { + // Unhide the actual content once loading is complete. Headers get + // flex treatment for their horizontal layout, divs get block treatment + // for vertical layout (column-oriented flex layout for divs caused + // errors in mobile browsers). if (e.tagName === "H2" || e.tagName === "H3") { - e.nextElementSibling.style.display = "block"; + let nextTagName = e.nextElementSibling.tagName; + if (nextTagName == "H2" || nextTagName == "H3") { + e.nextElementSibling.style.display = "flex"; + } else { + e.nextElementSibling.style.display = "block"; + } } }); } diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index 0b0acafb755c9..9cb7963ad0071 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -90,8 +90,9 @@ h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), h4:not(.method):not(.t border-bottom: 1px solid; } h3.impl, h3.method, h4.method, h3.type, h4.type, h4.associatedconstant { + flex-basis: 100%; font-weight: 600; - margin-top: 10px; + margin-top: 16px; margin-bottom: 10px; position: relative; } @@ -357,7 +358,8 @@ nav.sub { #main > .docblock h3, #main > .docblock h4, #main > .docblock h5 { font-size: 1em; } #main > h2 + div, #main > h2 + h3, #main > h3 + div { - display: none; + display: none; /* Changed to flex or block via js once the page is loaded */ + flex-wrap: wrap; } .docblock h1 { font-size: 1em; } @@ -391,7 +393,7 @@ h4 > code, h3 > code, .invisible > code { } .in-band, code { - z-index: 5; + z-index: -5; } .invisible { @@ -535,6 +537,10 @@ h4 > code, h3 > code, .invisible > code { margin-top: -8px; } +.impl-items { + flex-basis: 100%; +} + #main > .stability { margin-top: 0; } @@ -781,6 +787,33 @@ body.blur > :not(#help) { top: 0; } +.impl-items .since, .impl .since { + flex-grow: 0; + padding-left: 12px; + padding-right: 2px; + position: initial; +} + +.impl-items .srclink, .impl .srclink { + flex-grow: 0; + /* Override header settings otherwise it's too bold */ + font-size: 17px; + font-weight: normal; +} + +.impl-items code, .impl code { + flex-grow: 1; +} + +.impl-items h4, h4.impl, h3.impl { + display: flex; + flex-basis: 100%; + font-size: 16px; + margin-bottom: 12px; + /* Push the src link out to the right edge consistently */ + justify-content: space-between; +} + .variants_table { width: 100%; } @@ -868,15 +901,6 @@ h3 > .collapse-toggle, h4 > .collapse-toggle { margin-left: 20px; } -.ghost { - display: none; -} - -.ghost + .since { - position: initial; - display: table-cell; -} - .since + .srclink { display: table-cell; padding-left: 10px; @@ -1116,7 +1140,7 @@ span.since { margin-left: 5px; top: -5px; left: 105%; - z-index: 1; + z-index: 10; } .tooltip:hover .tooltiptext { @@ -1358,8 +1382,9 @@ h3.important { margin-top: 16px; } -.content > .methods > div.important-traits { +.content > .methods > .method > div.important-traits { position: absolute; + font-weight: 400; left: -42px; margin-top: 2px; } diff --git a/src/test/rustdoc/assoc-consts-version.rs b/src/test/rustdoc/assoc-consts-version.rs index 3f3c25162994e..c561269cf9a85 100644 --- a/src/test/rustdoc/assoc-consts-version.rs +++ b/src/test/rustdoc/assoc-consts-version.rs @@ -10,7 +10,7 @@ pub struct SomeStruct; impl SomeStruct { - // @has 'foo/struct.SomeStruct.html' '//*[@id="SOME_CONST.v"]//div[@class="since"]' '1.1.2' + // @has 'foo/struct.SomeStruct.html' '//*[@id="associatedconstant.SOME_CONST"]//div[@class="since"]' '1.1.2' #[stable(since="1.1.2", feature="rust2")] pub const SOME_CONST: usize = 0; } diff --git a/src/test/rustdoc/const.rs b/src/test/rustdoc/const.rs index f3118bb606630..c33db5809cc7c 100644 --- a/src/test/rustdoc/const.rs +++ b/src/test/rustdoc/const.rs @@ -3,7 +3,7 @@ pub struct Foo; impl Foo { - // @has const/struct.Foo.html '//*[@id="new.v"]//code' 'const unsafe fn new' + // @has const/struct.Foo.html '//code[@id="new.v"]' 'const unsafe fn new' pub const unsafe fn new() -> Foo { Foo } diff --git a/src/test/rustdoc/issue-25001.rs b/src/test/rustdoc/issue-25001.rs index 3c1580f3786bb..55d8ee394385b 100644 --- a/src/test/rustdoc/issue-25001.rs +++ b/src/test/rustdoc/issue-25001.rs @@ -9,17 +9,17 @@ pub trait Bar { impl Foo { // @has - '//*[@id="method.pass"]//code' 'fn pass()' - // @has - '//*[@id="pass.v"]//code' 'fn pass()' + // @has - '//code[@id="pass.v"]' 'fn pass()' pub fn pass() {} } impl Foo { // @has - '//*[@id="method.pass-1"]//code' 'fn pass() -> usize' - // @has - '//*[@id="pass.v-1"]//code' 'fn pass() -> usize' + // @has - '//code[@id="pass.v-1"]' 'fn pass() -> usize' pub fn pass() -> usize { 42 } } impl Foo { // @has - '//*[@id="method.pass-2"]//code' 'fn pass() -> isize' - // @has - '//*[@id="pass.v-2"]//code' 'fn pass() -> isize' + // @has - '//code[@id="pass.v-2"]' 'fn pass() -> isize' pub fn pass() -> isize { 42 } } diff --git a/src/test/rustdoc/issue-51236.rs b/src/test/rustdoc/issue-51236.rs index b57a067f3d9b8..d9accf9c5998b 100644 --- a/src/test/rustdoc/issue-51236.rs +++ b/src/test/rustdoc/issue-51236.rs @@ -7,7 +7,7 @@ pub mod traits { } // @has issue_51236/struct.Owned.html -// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' "impl Send for \ +// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//code' "impl Send for \ // Owned where >::Reader: Send" pub struct Owned where T: for<'a> ::traits::Owned<'a> { marker: PhantomData<>::Reader>, diff --git a/src/test/rustdoc/issue-54705.rs b/src/test/rustdoc/issue-54705.rs index 34f71fab0cc63..263b1eb0bd65a 100644 --- a/src/test/rustdoc/issue-54705.rs +++ b/src/test/rustdoc/issue-54705.rs @@ -3,10 +3,10 @@ pub trait ScopeHandle<'scope> {} // @has issue_54705/struct.ScopeFutureContents.html -// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' "impl<'scope, S> \ +// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//code' "impl<'scope, S> \ // Send for ScopeFutureContents<'scope, S> where S: Sync" // -// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' "impl<'scope, S> \ +// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//code' "impl<'scope, S> \ // Sync for ScopeFutureContents<'scope, S> where S: Sync" pub struct ScopeFutureContents<'scope, S> where S: ScopeHandle<'scope>, diff --git a/src/test/rustdoc/issue-55321.rs b/src/test/rustdoc/issue-55321.rs index 5c34a4d34ab87..257cb32c65c25 100644 --- a/src/test/rustdoc/issue-55321.rs +++ b/src/test/rustdoc/issue-55321.rs @@ -1,16 +1,16 @@ #![feature(optin_builtin_traits)] // @has issue_55321/struct.A.html -// @has - '//*[@id="implementations-list"]/*[@class="impl"]//*/code' "impl !Send for A" -// @has - '//*[@id="implementations-list"]/*[@class="impl"]//*/code' "impl !Sync for A" +// @has - '//*[@id="implementations-list"]/*[@class="impl"]//code' "impl !Send for A" +// @has - '//*[@id="implementations-list"]/*[@class="impl"]//code' "impl !Sync for A" pub struct A(); impl !Send for A {} impl !Sync for A {} // @has issue_55321/struct.B.html -// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' "impl !Send for \ +// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//code' "impl !Send for \ // B" -// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' "impl !Sync for \ +// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//code' "impl !Sync for \ // B" pub struct B(A, Box); diff --git a/src/test/rustdoc/issue-56822.rs b/src/test/rustdoc/issue-56822.rs index 41aba1a007ad8..38aa797993b36 100644 --- a/src/test/rustdoc/issue-56822.rs +++ b/src/test/rustdoc/issue-56822.rs @@ -27,7 +27,7 @@ impl<'a, T> MyTrait for Inner<'a, T> { } // @has issue_56822/struct.Parser.html -// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' "impl<'a> Send for \ +// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//code' "impl<'a> Send for \ // Parser<'a>" pub struct Parser<'a> { field: > as MyTrait>::Output diff --git a/src/test/rustdoc/synthetic_auto/complex.rs b/src/test/rustdoc/synthetic_auto/complex.rs index d2533a2dd390e..609cefc7115e2 100644 --- a/src/test/rustdoc/synthetic_auto/complex.rs +++ b/src/test/rustdoc/synthetic_auto/complex.rs @@ -20,7 +20,7 @@ mod foo { } // @has complex/struct.NotOuter.html -// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' "impl<'a, T, K: \ +// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//code' "impl<'a, T, K: \ // ?Sized> Send for NotOuter<'a, T, K> where K: for<'b> Fn((&'b bool, &'a u8)) \ // -> &'b i8, T: MyTrait<'a>, >::MyItem: Copy, 'a: 'static" diff --git a/src/test/rustdoc/synthetic_auto/lifetimes.rs b/src/test/rustdoc/synthetic_auto/lifetimes.rs index 03b84c7838edc..6d0a68f9b0734 100644 --- a/src/test/rustdoc/synthetic_auto/lifetimes.rs +++ b/src/test/rustdoc/synthetic_auto/lifetimes.rs @@ -9,10 +9,10 @@ where {} // @has lifetimes/struct.Foo.html -// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' "impl<'c, K> Send \ +// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//code' "impl<'c, K> Send \ // for Foo<'c, K> where K: for<'b> Fn(&'b bool) -> &'c u8, 'c: 'static" // -// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' "impl<'c, K> Sync \ +// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//code' "impl<'c, K> Sync \ // for Foo<'c, K> where K: Sync" pub struct Foo<'c, K: 'c> { inner_field: Inner<'c, K>, diff --git a/src/test/rustdoc/synthetic_auto/manual.rs b/src/test/rustdoc/synthetic_auto/manual.rs index c7cfa0c0fa1b8..413ba187f4556 100644 --- a/src/test/rustdoc/synthetic_auto/manual.rs +++ b/src/test/rustdoc/synthetic_auto/manual.rs @@ -1,8 +1,8 @@ // @has manual/struct.Foo.html -// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' 'impl Sync for \ +// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//code' 'impl Sync for \ // Foo where T: Sync' // -// @has - '//*[@id="implementations-list"]/*[@class="impl"]//*/code' \ +// @has - '//*[@id="implementations-list"]/*[@class="impl"]//code' \ // 'impl Send for Foo' // // @count - '//*[@id="implementations-list"]/*[@class="impl"]' 1 diff --git a/src/test/rustdoc/synthetic_auto/negative.rs b/src/test/rustdoc/synthetic_auto/negative.rs index 5b6304ed4e471..30713849da221 100644 --- a/src/test/rustdoc/synthetic_auto/negative.rs +++ b/src/test/rustdoc/synthetic_auto/negative.rs @@ -3,10 +3,10 @@ pub struct Inner { } // @has negative/struct.Outer.html -// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' "impl !Send for \ +// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//code' "impl !Send for \ // Outer" // -// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' "impl \ +// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//code' "impl \ // !Sync for Outer" pub struct Outer { inner_field: Inner, diff --git a/src/test/rustdoc/synthetic_auto/nested.rs b/src/test/rustdoc/synthetic_auto/nested.rs index 75d2ff2af13e1..e710ce1c2ed95 100644 --- a/src/test/rustdoc/synthetic_auto/nested.rs +++ b/src/test/rustdoc/synthetic_auto/nested.rs @@ -9,10 +9,10 @@ where } // @has nested/struct.Foo.html -// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' 'impl Send for \ +// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//code' 'impl Send for \ // Foo where T: Copy' // -// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' \ +// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//code' \ // 'impl Sync for Foo where T: Sync' pub struct Foo { inner_field: Inner, diff --git a/src/test/rustdoc/synthetic_auto/no-redundancy.rs b/src/test/rustdoc/synthetic_auto/no-redundancy.rs index 92402714b9d51..cf173111ec1e2 100644 --- a/src/test/rustdoc/synthetic_auto/no-redundancy.rs +++ b/src/test/rustdoc/synthetic_auto/no-redundancy.rs @@ -9,7 +9,7 @@ where } // @has no_redundancy/struct.Outer.html -// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' "impl Send for \ +// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//code' "impl Send for \ // Outer where T: Copy + Send" pub struct Outer { inner_field: Inner, diff --git a/src/test/rustdoc/synthetic_auto/project.rs b/src/test/rustdoc/synthetic_auto/project.rs index 6be6b44a4400a..5346521f8d2e3 100644 --- a/src/test/rustdoc/synthetic_auto/project.rs +++ b/src/test/rustdoc/synthetic_auto/project.rs @@ -23,10 +23,10 @@ where } // @has project/struct.Foo.html -// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' "impl<'c, K> Send \ +// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//code' "impl<'c, K> Send \ // for Foo<'c, K> where K: MyTrait, 'c: 'static" // -// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' "impl<'c, K> Sync \ +// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//code' "impl<'c, K> Sync \ // for Foo<'c, K> where K: MyTrait, ::MyItem: OtherTrait, 'c: 'static," pub struct Foo<'c, K: 'c> { inner_field: Inner<'c, K>, diff --git a/src/test/rustdoc/synthetic_auto/self-referential.rs b/src/test/rustdoc/synthetic_auto/self-referential.rs index 0dca8fe297820..7d15434afe6db 100644 --- a/src/test/rustdoc/synthetic_auto/self-referential.rs +++ b/src/test/rustdoc/synthetic_auto/self-referential.rs @@ -23,7 +23,7 @@ impl Pattern for Wrapper { // @has self_referential/struct.WriteAndThen.html -// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' "impl Send for \ +// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//code' "impl Send for \ // WriteAndThen where ::Value: Send" pub struct WriteAndThen(pub P1::Value,pub > as Pattern>::Value) where P1: Pattern; diff --git a/src/test/rustdoc/synthetic_auto/static-region.rs b/src/test/rustdoc/synthetic_auto/static-region.rs index d1d50fbc6ba15..59493744b623d 100644 --- a/src/test/rustdoc/synthetic_auto/static-region.rs +++ b/src/test/rustdoc/synthetic_auto/static-region.rs @@ -3,7 +3,7 @@ pub trait OwnedTrait<'a> { } // @has static_region/struct.Owned.html -// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' "impl Send for \ +// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//code' "impl Send for \ // Owned where >::Reader: Send" pub struct Owned where T: OwnedTrait<'static> { marker: >::Reader,