Skip to content

Commit 0b22d41

Browse files
committed
rustdoc: fix spacing of non-toggled impl blocks
We recently removed the "up here" arrows on item-infos, and adjusted vertical spacing so that even without the arrow, it would be visually clear which item the item-info belonged to. The new CSS styles for vertical spacing only applied to toggles, though. This missed non-toggled impl blocks - for instance, those without any methods, like https://doc.rust-lang.org/nightly/std/marker/trait.Send.html#implementors. The result was lists of implementors that were spaced too closely. This PR fixes the spacing by making it apply to non-toggled impl blocks as well. This also fixes an issue where item-infos were displayed too far below their items. That was a result of display: table on .item-info .stab. Changed that to display: inline-block.
1 parent 5d6ee0d commit 0b22d41

File tree

5 files changed

+23
-3
lines changed

5 files changed

+23
-3
lines changed

src/librustdoc/html/static/css/rustdoc.css

+3-2
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,7 @@ body.blur > :not(#help) {
10411041
}
10421042

10431043
.item-info .stab {
1044-
display: table;
1044+
display: inline-block;
10451045
}
10461046
.stab {
10471047
padding: 3px;
@@ -2039,7 +2039,8 @@ details.rustdoc-toggle[open] > summary.hideme::after {
20392039
}
20402040

20412041
.method-toggle summary,
2042-
.implementors-toggle summary {
2042+
.implementors-toggle summary,
2043+
.impl {
20432044
margin-bottom: 0.75em;
20442045
}
20452046

src/test/rustdoc-gui/implementors.goml

+4
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@ assert: ("#implementors-list .impl:nth-child(2) > a.anchor")
1414
assert-attribute: ("#implementors-list .impl:nth-child(2)", {"id": "impl-Whatever-1"})
1515
assert-attribute: ("#implementors-list .impl:nth-child(2) > a.anchor", {"href": "#impl-Whatever-1"})
1616
assert: "#implementors-list .impl:nth-child(2) > .code-header.in-band"
17+
18+
goto: file://|DOC_PATH|/test_docs/struct.HasEmptyTraits.html
19+
compare-elements-position-near-false: ("#impl-EmptyTrait1", "#impl-EmptyTrait2", {"y": 30})
20+
compare-elements-position-near: ("#impl-EmptyTrait3 h3", "#impl-EmptyTrait3 .item-info", {"y": 30})

src/test/rustdoc-gui/item-info-width.goml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ goto: file://|DOC_PATH|/lib2/struct.Foo.html
44
size: (1100, 800)
55
// We check that ".item-info" is bigger than its content.
66
assert-css: (".item-info", {"width": "790px"})
7-
assert-css: (".item-info .stab", {"width": "340px"})
7+
assert-css: (".item-info .stab", {"width": "339.562px"})
88
assert-position: (".item-info .stab", {"x": 295})

src/test/rustdoc-gui/src/test_docs/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ build = "build.rs"
77

88
[lib]
99
path = "lib.rs"
10+
11+
[features]
12+
default = ["some-feature"]
13+
some-feature = []

src/test/rustdoc-gui/src/test_docs/lib.rs

+11
Original file line numberDiff line numberDiff line change
@@ -260,3 +260,14 @@ impl HeavilyDocumentedUnion {
260260
macro_rules! heavily_documented_macro {
261261
() => {};
262262
}
263+
264+
pub trait EmptyTrait1 {}
265+
pub trait EmptyTrait2 {}
266+
pub trait EmptyTrait3 {}
267+
268+
pub struct HasEmptyTraits{}
269+
270+
impl EmptyTrait1 for HasEmptyTraits {}
271+
impl EmptyTrait2 for HasEmptyTraits {}
272+
#[doc(cfg(feature = "some-feature"))]
273+
impl EmptyTrait3 for HasEmptyTraits {}

0 commit comments

Comments
 (0)