\
@@ -1916,14 +1923,16 @@ fn render_impl(
}
if !default_impl_items.is_empty() || !impl_items.is_empty() {
w.write_str("");
- close_tags.insert_str(0, "
");
+ close_tags.push("");
}
}
if !default_impl_items.is_empty() || !impl_items.is_empty() {
w.push_buffer(default_impl_items);
w.push_buffer(impl_items);
}
- w.write_str(&close_tags);
+ for tag in close_tags.into_iter().rev() {
+ w.write_str(tag);
+ }
}
// Render the items that appear on the right side of methods, impls, and
diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css
index 28df8d3f011fe..1e48306228967 100644
--- a/src/librustdoc/html/static/css/rustdoc.css
+++ b/src/librustdoc/html/static/css/rustdoc.css
@@ -1852,6 +1852,11 @@ details.toggle {
position: relative;
}
+details.big-toggle {
+ /* This makes [-] on the same line as . */
+ contain: inline-size;
+}
+
/* The hideme class is used on summary tags that contain a span with
placeholder text shown only when the toggle is closed. For instance,
"Expand description" or "Show methods". */
@@ -1942,6 +1947,11 @@ details.toggle > summary:not(.hideme)::before {
left: -24px;
}
+details.big-toggle > summary:not(.hideme)::before {
+ left: -34px;
+ top: 9px;
+}
+
/* When a "hideme" summary is open and the "Expand description" or "Show
methods" text is hidden, we want the [-] toggle that remains to not
affect the layout of the items to its right. To do that, we use
diff --git a/tests/rustdoc-gui/deref-block.goml b/tests/rustdoc-gui/deref-block.goml
new file mode 100644
index 0000000000000..24f612f8a6fd1
--- /dev/null
+++ b/tests/rustdoc-gui/deref-block.goml
@@ -0,0 +1,30 @@
+// This test ensures that several clickable items actually have the pointer cursor.
+go-to: "file://" + |DOC_PATH| + "/lib2/struct.Derefer.html"
+
+assert-text: (".big-toggle summary", "Methods from Deref§")
+// We ensure it doesn't go over `§`.
+assert-css: (".big-toggle summary::before", {
+ "left": "-34px",
+ "top": "9px",
+})
+// It should NOT have the same X or Y position as the other toggles.
+compare-elements-position-false: (
+ ".big-toggle summary::before",
+ ".method-toggle summary::before",
+ ["x", "y"],
+)
+
+// We now check that if we're in mobile mode, it gets back to its original X position.
+set-window-size: (600, 600)
+assert-css: (".big-toggle summary::before", {
+ "left": "-11px",
+ "top": "9px",
+})
+// It should have the same X position as the other toggles.
+compare-elements-position: (".big-toggle summary::before", ".method-toggle summary::before", ["x"])
+// But still shouldn't have the same Y position.
+compare-elements-position-false: (
+ ".big-toggle summary::before",
+ ".method-toggle summary::before",
+ ["y"],
+)
diff --git a/tests/rustdoc-gui/src/lib2/lib.rs b/tests/rustdoc-gui/src/lib2/lib.rs
index 2467c7adae1a3..8db754f91ce61 100644
--- a/tests/rustdoc-gui/src/lib2/lib.rs
+++ b/tests/rustdoc-gui/src/lib2/lib.rs
@@ -356,3 +356,13 @@ pub mod scroll_traits {
fn this_is_a_method_with_a_long_name_returning_something() -> String;
}
}
+
+pub struct Derefer(String);
+
+impl std::ops::Deref for Derefer {
+ type Target = str;
+
+ fn deref(&self) -> &Self::Target {
+ &self.0
+ }
+}