about summary refs log tree commit diff
path: root/src/librustdoc/html
diff options
context:
space:
mode:
Diffstat (limited to 'src/librustdoc/html')
-rw-r--r--src/librustdoc/html/render/mod.rs145
-rw-r--r--src/librustdoc/html/render/print_item.rs24
-rw-r--r--src/librustdoc/html/static/main.js5
-rw-r--r--src/librustdoc/html/static/rustdoc.css24
-rw-r--r--src/librustdoc/html/static/themes/ayu.css5
-rw-r--r--src/librustdoc/html/static/themes/dark.css5
-rw-r--r--src/librustdoc/html/static/themes/light.css5
7 files changed, 95 insertions, 118 deletions
diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs
index 0efa014b127..499f33f14f5 100644
--- a/src/librustdoc/html/render/mod.rs
+++ b/src/librustdoc/html/render/mod.rs
@@ -490,7 +490,6 @@ fn settings(root_path: &str, suffix: &str, themes: &[StylePath]) -> Result<Strin
         ("auto-hide-method-docs", "Auto-hide item methods' documentation", false).into(),
         ("auto-hide-trait-implementations", "Auto-hide trait implementation documentation", false)
             .into(),
-        ("auto-collapse-implementors", "Auto-hide implementors of a trait", true).into(),
         ("go-to-only-result", "Directly go to item in search if there is only one result", false)
             .into(),
         ("line-numbers", "Show line numbers on code examples", false).into(),
@@ -724,6 +723,8 @@ fn short_item_info(
     extra_info
 }
 
+// Render the list of items inside one of the sections "Trait Implementations",
+// "Auto Trait Implementations," "Blanket Trait Implementations" (on struct/enum pages).
 fn render_impls(
     cx: &Context<'_>,
     w: &mut Buffer,
@@ -746,8 +747,6 @@ fn render_impls(
                 containing_item,
                 assoc_link,
                 RenderMode::Normal,
-                containing_item.stable_since(tcx).as_deref(),
-                containing_item.const_stable_since(tcx).as_deref(),
                 true,
                 None,
                 false,
@@ -1025,7 +1024,6 @@ fn render_assoc_items(
         Some(v) => v,
         None => return,
     };
-    let tcx = cx.tcx();
     let cache = cx.cache();
     let (non_trait, traits): (Vec<_>, _) = v.iter().partition(|i| i.inner_impl().trait_.is_none());
     if !non_trait.is_empty() {
@@ -1059,8 +1057,6 @@ fn render_assoc_items(
                 containing_item,
                 AssocItemLink::Anchor(None),
                 render_mode,
-                containing_item.stable_since(tcx).as_deref(),
-                containing_item.const_stable_since(tcx).as_deref(),
                 true,
                 None,
                 false,
@@ -1261,8 +1257,6 @@ fn render_impl(
     parent: &clean::Item,
     link: AssocItemLink<'_>,
     render_mode: RenderMode,
-    outer_version: Option<&str>,
-    outer_const_version: Option<&str>,
     show_def_docs: bool,
     use_absolute: Option<bool>,
     is_on_foreign_type: bool,
@@ -1279,23 +1273,23 @@ fn render_impl(
     // For trait implementations, the `interesting` output contains all methods that have doc
     // comments, and the `boring` output contains all methods that do not. The distinction is
     // used to allow hiding the boring methods.
+    // `containing_item` is used for rendering stability info. If the parent is a trait impl,
+    // `containing_item` will the grandparent, since trait impls can't have stability attached.
     fn doc_impl_item(
         boring: &mut Buffer,
         interesting: &mut Buffer,
         cx: &Context<'_>,
         item: &clean::Item,
         parent: &clean::Item,
+        containing_item: &clean::Item,
         link: AssocItemLink<'_>,
         render_mode: RenderMode,
         is_default_item: bool,
-        outer_version: Option<&str>,
-        outer_const_version: Option<&str>,
         trait_: Option<&clean::Trait>,
         show_def_docs: bool,
     ) {
         let item_type = item.type_();
         let name = item.name.as_ref().unwrap();
-        let tcx = cx.tcx();
 
         let render_method_item = match render_mode {
             RenderMode::Normal => true,
@@ -1364,6 +1358,8 @@ fn render_impl(
                         "<div id=\"{}\" class=\"{}{} has-srclink\">",
                         id, item_type, in_trait_class,
                     );
+                    render_rightside(w, cx, item, containing_item);
+                    write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
                     w.write_str("<code>");
                     render_assoc_item(
                         w,
@@ -1373,15 +1369,6 @@ fn render_impl(
                         cx,
                     );
                     w.write_str("</code>");
-                    render_stability_since_raw(
-                        w,
-                        item.stable_since(tcx).as_deref(),
-                        item.const_stable_since(tcx).as_deref(),
-                        outer_version,
-                        outer_const_version,
-                    );
-                    write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
-                    write_srclink(cx, item, w);
                     w.write_str("</div>");
                 }
             }
@@ -1390,9 +1377,11 @@ fn render_impl(
                 let id = cx.derive_id(source_id.clone());
                 write!(
                     w,
-                    "<div id=\"{}\" class=\"{}{} has-srclink\"><code>",
+                    "<div id=\"{}\" class=\"{}{} has-srclink\">",
                     id, item_type, in_trait_class
                 );
+                write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
+                w.write_str("<code>");
                 assoc_type(
                     w,
                     item,
@@ -1403,7 +1392,6 @@ fn render_impl(
                     cx,
                 );
                 w.write_str("</code>");
-                write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
                 w.write_str("</div>");
             }
             clean::AssocConstItem(ref ty, ref default) => {
@@ -1411,9 +1399,12 @@ fn render_impl(
                 let id = cx.derive_id(source_id.clone());
                 write!(
                     w,
-                    "<div id=\"{}\" class=\"{}{} has-srclink\"><code>",
+                    "<div id=\"{}\" class=\"{}{} has-srclink\">",
                     id, item_type, in_trait_class
                 );
+                render_rightside(w, cx, item, containing_item);
+                write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
+                w.write_str("<code>");
                 assoc_const(
                     w,
                     item,
@@ -1424,21 +1415,14 @@ fn render_impl(
                     cx,
                 );
                 w.write_str("</code>");
-                render_stability_since_raw(
-                    w,
-                    item.stable_since(tcx).as_deref(),
-                    item.const_stable_since(tcx).as_deref(),
-                    outer_version,
-                    outer_const_version,
-                );
-                write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
-                write_srclink(cx, item, w);
                 w.write_str("</div>");
             }
             clean::AssocTypeItem(ref bounds, ref default) => {
                 let source_id = format!("{}.{}", item_type, name);
                 let id = cx.derive_id(source_id.clone());
-                write!(w, "<div id=\"{}\" class=\"{}{}\"><code>", id, item_type, in_trait_class,);
+                write!(w, "<div id=\"{}\" class=\"{}{}\">", id, item_type, in_trait_class,);
+                write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
+                w.write_str("<code>");
                 assoc_type(
                     w,
                     item,
@@ -1449,7 +1433,6 @@ fn render_impl(
                     cx,
                 );
                 w.write_str("</code>");
-                write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
                 w.write_str("</div>");
             }
             clean::StrippedItem(..) => return,
@@ -1474,11 +1457,10 @@ fn render_impl(
             cx,
             trait_item,
             if trait_.is_some() { &i.impl_item } else { parent },
+            parent,
             link,
             render_mode,
             false,
-            outer_version,
-            outer_const_version,
             trait_.map(|t| &t.trait_),
             show_def_docs,
         );
@@ -1491,9 +1473,8 @@ fn render_impl(
         t: &clean::Trait,
         i: &clean::Impl,
         parent: &clean::Item,
+        containing_item: &clean::Item,
         render_mode: RenderMode,
-        outer_version: Option<&str>,
-        outer_const_version: Option<&str>,
         show_def_docs: bool,
     ) {
         for trait_item in &t.items {
@@ -1511,11 +1492,10 @@ fn render_impl(
                 cx,
                 trait_item,
                 parent,
+                containing_item,
                 assoc_link,
                 render_mode,
                 true,
-                outer_version,
-                outer_const_version,
                 Some(t),
                 show_def_docs,
             );
@@ -1535,28 +1515,25 @@ fn render_impl(
                 &t.trait_,
                 &i.inner_impl(),
                 &i.impl_item,
+                parent,
                 render_mode,
-                outer_version,
-                outer_const_version,
                 show_def_docs,
             );
         }
     }
     if render_mode == RenderMode::Normal {
-        let toggled = !impl_items.is_empty() || !default_impl_items.is_empty();
+        let toggled = !(impl_items.is_empty() && default_impl_items.is_empty());
         if toggled {
             close_tags.insert_str(0, "</details>");
             write!(w, "<details class=\"rustdoc-toggle implementors-toggle\" open>");
-        }
-        if toggled {
             write!(w, "<summary>")
         }
         render_impl_summary(
             w,
             cx,
             i,
-            outer_version,
-            outer_const_version,
+            parent,
+            parent,
             show_def_docs,
             use_absolute,
             is_on_foreign_type,
@@ -1565,11 +1542,6 @@ fn render_impl(
         if toggled {
             write!(w, "</summary>")
         }
-        if trait_.is_some() {
-            if let Some(portability) = portability(&i.impl_item, Some(parent)) {
-                write!(w, "<div class=\"item-info\">{}</div>", portability);
-            }
-        }
 
         if let Some(ref dox) = cx.shared.maybe_collapsed_doc_value(&i.impl_item) {
             let mut ids = cx.id_map.borrow_mut();
@@ -1597,12 +1569,35 @@ fn render_impl(
     w.write_str(&close_tags);
 }
 
-fn render_impl_summary(
+// Render the items that appear on the right side of methods, impls, and
+// associated types. For example "1.0.0 (const: 1.39.0) [src]".
+fn render_rightside(
+    w: &mut Buffer,
+    cx: &Context<'_>,
+    item: &clean::Item,
+    containing_item: &clean::Item,
+) {
+    let tcx = cx.tcx();
+
+    write!(w, "<div class=\"rightside\">");
+    render_stability_since_raw(
+        w,
+        item.stable_since(tcx).as_deref(),
+        item.const_stable_since(tcx).as_deref(),
+        containing_item.stable_since(tcx).as_deref(),
+        containing_item.const_stable_since(tcx).as_deref(),
+    );
+
+    write_srclink(cx, item, w);
+    w.write_str("</div>");
+}
+
+pub(crate) fn render_impl_summary(
     w: &mut Buffer,
     cx: &Context<'_>,
     i: &Impl,
-    outer_version: Option<&str>,
-    outer_const_version: Option<&str>,
+    parent: &clean::Item,
+    containing_item: &clean::Item,
     show_def_docs: bool,
     use_absolute: Option<bool>,
     is_on_foreign_type: bool,
@@ -1610,7 +1605,6 @@ fn render_impl_summary(
     // in documentation pages for trait with automatic implementations like "Send" and "Sync".
     aliases: &[String],
 ) {
-    let tcx = cx.tcx();
     let id = cx.derive_id(match i.inner_impl().trait_ {
         Some(ref t) => {
             if is_on_foreign_type {
@@ -1626,13 +1620,12 @@ fn render_impl_summary(
     } else {
         format!(" data-aliases=\"{}\"", aliases.join(","))
     };
+    write!(w, "<div id=\"{}\" class=\"impl has-srclink\"{}>", id, aliases);
+    render_rightside(w, cx, &i.impl_item, containing_item);
+    write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
+    write!(w, "<code class=\"in-band\">");
+
     if let Some(use_absolute) = use_absolute {
-        write!(
-            w,
-            "<div id=\"{}\" class=\"impl has-srclink\"{}>\
-                     <code class=\"in-band\">",
-            id, aliases
-        );
         write!(w, "{}", i.inner_impl().print(use_absolute, cx));
         if show_def_docs {
             for it in &i.inner_impl().items {
@@ -1643,26 +1636,18 @@ fn render_impl_summary(
                 }
             }
         }
-        w.write_str("</code>");
     } else {
-        write!(
-            w,
-            "<div id=\"{}\" class=\"impl has-srclink\"{}>\
-                     <code class=\"in-band\">{}</code>",
-            id,
-            aliases,
-            i.inner_impl().print(false, cx)
-        );
+        write!(w, "{}", i.inner_impl().print(false, cx));
     }
-    write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
-    render_stability_since_raw(
-        w,
-        i.impl_item.stable_since(tcx).as_deref(),
-        i.impl_item.const_stable_since(tcx).as_deref(),
-        outer_version,
-        outer_const_version,
-    );
-    write_srclink(cx, &i.impl_item, w);
+    write!(w, "</code>");
+
+    let is_trait = i.inner_impl().trait_.is_some();
+    if is_trait {
+        if let Some(portability) = portability(&i.impl_item, Some(parent)) {
+            write!(w, "<div class=\"item-info\">{}</div>", portability);
+        }
+    }
+
     w.write_str("</div>");
 }
 
diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs
index 88ec172a18b..8fd53538912 100644
--- a/src/librustdoc/html/render/print_item.rs
+++ b/src/librustdoc/html/render/print_item.rs
@@ -15,7 +15,8 @@ use rustc_span::symbol::{kw, sym, Symbol};
 use super::{
     collect_paths_for_type, document, ensure_trailing_slash, item_ty_to_strs, notable_traits_decl,
     render_assoc_item, render_assoc_items, render_attributes_in_code, render_attributes_in_pre,
-    render_impl, render_stability_since_raw, write_srclink, AssocItemLink, Context,
+    render_impl, render_impl_summary, render_stability_since_raw, write_srclink, AssocItemLink,
+    Context,
 };
 use crate::clean::{self, GetDefId};
 use crate::formats::item_type::ItemType;
@@ -585,11 +586,14 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
         if toggled {
             write!(w, "<details class=\"rustdoc-toggle\" open><summary>");
         }
-        write!(w, "<div id=\"{}\" class=\"method has-srclink\"><code>", id);
-        render_assoc_item(w, m, AssocItemLink::Anchor(Some(&id)), ItemType::Impl, cx);
-        w.write_str("</code>");
+        write!(w, "<div id=\"{}\" class=\"method has-srclink\">", id);
+        write!(w, "<div class=\"rightside\">");
         render_stability_since(w, m, t, cx.tcx());
         write_srclink(cx, m, w);
+        write!(w, "</div>");
+        write!(w, "<code>");
+        render_assoc_item(w, m, AssocItemLink::Anchor(Some(&id)), ItemType::Impl, cx);
+        w.write_str("</code>");
         w.write_str("</div>");
         if toggled {
             write!(w, "</summary>");
@@ -701,8 +705,6 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
                     it,
                     assoc_link,
                     RenderMode::Normal,
-                    implementor.impl_item.stable_since(cx.tcx()).as_deref(),
-                    implementor.impl_item.const_stable_since(cx.tcx()).as_deref(),
                     false,
                     None,
                     true,
@@ -1310,7 +1312,7 @@ fn render_implementor(
     implementor_dups: &FxHashMap<Symbol, (DefId, bool)>,
     aliases: &[String],
 ) {
-    // If there's already another implementor that has the same abbridged name, use the
+    // If there's already another implementor that has the same abridged name, use the
     // full path, for example in `std::iter::ExactSizeIterator`
     let use_absolute = match implementor.inner_impl().for_ {
         clean::ResolvedPath { ref path, is_generic: false, .. }
@@ -1320,19 +1322,15 @@ fn render_implementor(
         } => implementor_dups[&path.last()].1,
         _ => false,
     };
-    render_impl(
+    render_impl_summary(
         w,
         cx,
         implementor,
         trait_,
-        AssocItemLink::Anchor(None),
-        RenderMode::Normal,
-        trait_.stable_since(cx.tcx()).as_deref(),
-        trait_.const_stable_since(cx.tcx()).as_deref(),
+        trait_,
         false,
         Some(use_absolute),
         false,
-        false,
         aliases,
     );
 }
diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js
index e43a231d757..98128878999 100644
--- a/src/librustdoc/html/static/main.js
+++ b/src/librustdoc/html/static/main.js
@@ -778,7 +778,6 @@ function hideThemeButtonState() {
         }
 
         var hideMethodDocs = getSettingValue("auto-hide-method-docs") === "true";
-        var hideImplementors = getSettingValue("auto-collapse-implementors") !== "false";
         var hideImplementations = getSettingValue("auto-hide-trait-implementations") === "true";
         var hideLargeItemContents = getSettingValue("auto-hide-large-items") !== "false";
 
@@ -796,10 +795,6 @@ function hideThemeButtonState() {
             setImplementorsTogglesOpen("blanket-implementations-list", false);
         }
 
-        if (!hideImplementors) {
-            setImplementorsTogglesOpen("implementors-list", true);
-        }
-
         onEachLazy(document.getElementsByClassName("rustdoc-toggle"), function (e) {
             if (!hideLargeItemContents && hasClass(e, "type-contents-toggle")) {
                 e.open = true;
diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css
index 7535145caa5..9a59ee528a0 100644
--- a/src/librustdoc/html/static/rustdoc.css
+++ b/src/librustdoc/html/static/rustdoc.css
@@ -581,7 +581,6 @@ nav.sub {
 .content .item-info {
 	position: relative;
 	margin-left: 33px;
-	margin-top: -13px;
 }
 
 .sub-variant > div > .item-info {
@@ -852,12 +851,12 @@ body.blur > :not(#help) {
 }
 
 .stab {
-	display: table;
 	border-width: 1px;
 	border-style: solid;
 	padding: 3px;
 	margin-bottom: 5px;
 	font-size: 90%;
+	font-weight: normal;
 }
 .stab p {
 	display: inline;
@@ -900,32 +899,25 @@ body.blur > :not(#help) {
 .since {
 	font-weight: normal;
 	font-size: initial;
-	position: absolute;
-	right: 0;
-	top: 0;
 }
 
 .impl-items .since, .impl .since, .methods .since {
-	flex-grow: 0;
 	padding-left: 12px;
 	padding-right: 2px;
 	position: initial;
 }
 
 .impl-items .srclink, .impl .srclink, .methods .srclink {
-	flex-grow: 0;
 	/* Override header settings otherwise it's too bold */
 	font-size: 17px;
 	font-weight: normal;
 }
 
-.impl-items code, .impl code, .methods code {
-	flex-grow: 1;
+.rightside {
+	float: right;
 }
 
 .has-srclink {
-	display: flex;
-	flex-basis: 100%;
 	font-size: 16px;
 	margin-bottom: 12px;
 	/* Push the src link out to the right edge consistently */
@@ -986,7 +978,6 @@ a.test-arrow:hover{
 }
 
 .since + .srclink {
-	display: table-cell;
 	padding-left: 10px;
 }
 
@@ -1046,6 +1037,10 @@ a.test-arrow:hover{
 	opacity: 1;
 }
 
+:target {
+	padding-right: 3px;
+}
+
 .information {
 	position: absolute;
 	left: -25px;
@@ -1612,11 +1607,6 @@ details.undocumented[open] > summary::before {
 		margin-left: 0;
 	}
 
-	.content .impl-items .method, .content .impl-items > .type, .impl-items > .associatedconstant,
-	.impl-items > .associatedtype {
-		display: flex;
-	}
-
 	.anchor {
 		display: none !important;
 	}
diff --git a/src/librustdoc/html/static/themes/ayu.css b/src/librustdoc/html/static/themes/ayu.css
index d220d8708a1..171d06c0a36 100644
--- a/src/librustdoc/html/static/themes/ayu.css
+++ b/src/librustdoc/html/static/themes/ayu.css
@@ -334,8 +334,11 @@ a.test-arrow:hover {
 	color: #999;
 }
 
-:target > code, :target > .in-band {
+:target, :target * {
 	background: rgba(255, 236, 164, 0.06);
+}
+
+:target {
 	border-right: 3px solid rgba(255, 180, 76, 0.85);
 }
 
diff --git a/src/librustdoc/html/static/themes/dark.css b/src/librustdoc/html/static/themes/dark.css
index 6385a763f2e..d9ea28058ad 100644
--- a/src/librustdoc/html/static/themes/dark.css
+++ b/src/librustdoc/html/static/themes/dark.css
@@ -282,8 +282,11 @@ a.test-arrow:hover{
 	color: #999;
 }
 
-:target > code, :target > .in-band {
+:target, :target * {
 	background-color: #494a3d;
+}
+
+:target {
 	border-right: 3px solid #bb7410;
 }
 
diff --git a/src/librustdoc/html/static/themes/light.css b/src/librustdoc/html/static/themes/light.css
index c19d5bfc317..a2dfb89820b 100644
--- a/src/librustdoc/html/static/themes/light.css
+++ b/src/librustdoc/html/static/themes/light.css
@@ -275,8 +275,11 @@ a.test-arrow:hover{
 	color: #999;
 }
 
-:target > code, :target > .in-band {
+:target, :target * {
 	background: #FDFFD3;
+}
+
+:target {
 	border-right: 3px solid #ffb44c;
 }