Skip to content

Commit b7fe885

Browse files
authored
Unrolled build for rust-lang#118677
Rollup merge of rust-lang#118677 - GuillaumeGomez:doc_cfg-display, r=notriddle [rustdoc] Fix display of features Fixes rust-lang#118615. It now looks like this: ![image](https://github.com/rust-lang/rust/assets/3050060/6e77204e-0706-44a3-89ae-2dbd1934ebbc) We can't use flex without breaking the flow, meaning we can't vertically align items as we want. Because of that, the `min-height` was problematic as it rendered weirdly and therefore needed to be removed. r? `@notriddle`
2 parents 6c470a5 + 9e1797b commit b7fe885

File tree

4 files changed

+43
-9
lines changed

4 files changed

+43
-9
lines changed

Diff for: src/librustdoc/html/static/css/rustdoc.css

+12-9
Original file line numberDiff line numberDiff line change
@@ -1081,15 +1081,9 @@ so that we can apply CSS-filters to change the arrow color in themes */
10811081
}
10821082

10831083
.item-info .stab {
1084-
/* This min-height is needed to unify the height of the stab elements because some of them
1085-
have emojis.
1086-
*/
1087-
min-height: 36px;
1088-
display: flex;
1084+
display: block;
10891085
padding: 3px;
10901086
margin-bottom: 5px;
1091-
align-items: center;
1092-
vertical-align: text-bottom;
10931087
}
10941088
.item-name .stab {
10951089
margin-left: 0.3125em;
@@ -1112,17 +1106,26 @@ so that we can apply CSS-filters to change the arrow color in themes */
11121106
color: var(--stab-code-color);
11131107
}
11141108

1115-
.stab .emoji {
1109+
.stab .emoji, .item-info .stab::before {
11161110
font-size: 1.25rem;
1111+
}
1112+
.stab .emoji {
11171113
margin-right: 0.3rem;
11181114
}
1115+
.item-info .stab::before {
1116+
/* ensure badges with emoji and without it have same height */
1117+
content: "\0";
1118+
width: 0;
1119+
display: inline-block;
1120+
color: transparent;
1121+
}
11191122

11201123
/* Black one-pixel outline around emoji shapes */
11211124
.emoji {
11221125
text-shadow:
11231126
1px 0 0 black,
11241127
-1px 0 0 black,
1125-
0 1px 0 black,
1128+
0 1px 0 black,
11261129
0 -1px 0 black;
11271130
}
11281131

Diff for: tests/rustdoc-gui/item-info.goml

+15
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,22 @@ assert-size: (".item-info", {"width": 840})
88
assert-size: (".item-info .stab", {"width": 289})
99
assert-position: (".item-info .stab", {"x": 245})
1010

11+
// We check that the display of the feature elements is not broken. It serves as regression
12+
// test for <https://github.com/rust-lang/rust/issues/118615>.
13+
set-window-size: (850, 800)
14+
store-position: (
15+
"//*[@class='stab portability']//code[text()='Win32_System']",
16+
{"x": first_line_x, "y": first_line_y},
17+
)
18+
store-position: (
19+
"//*[@class='stab portability']//code[text()='Win32_System_Diagnostics']",
20+
{"x": second_line_x, "y": second_line_y},
21+
)
22+
assert: |first_line_x| != |second_line_x| && |first_line_x| == 516 && |second_line_x| == 272
23+
assert: |first_line_y| != |second_line_y| && |first_line_y| == 688 && |second_line_y| == 711
24+
1125
// Now we ensure that they're not rendered on the same line.
26+
set-window-size: (1100, 800)
1227
go-to: "file://" + |DOC_PATH| + "/lib2/trait.Trait.html"
1328
// We first ensure that there are two item info on the trait.
1429
assert-count: ("#main-content > .item-info .stab", 2)

Diff for: tests/rustdoc-gui/src/lib2/Cargo.toml

+7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ edition = "2018"
66
[lib]
77
path = "lib.rs"
88

9+
[features]
10+
Win32 = ["Win32_System"]
11+
Win32_System = ["Win32_System_Diagnostics"]
12+
Win32_System_Diagnostics = ["Win32_System_Diagnostics_Debug"]
13+
Win32_System_Diagnostics_Debug = []
14+
default = ["Win32"]
15+
916
[dependencies]
1017
implementors = { path = "./implementors" }
1118
http = { path = "./http" }

Diff for: tests/rustdoc-gui/src/lib2/lib.rs

+9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// ignore-tidy-linelength
22

33
#![feature(doc_cfg)]
4+
#![feature(doc_auto_cfg)]
45

56
pub mod another_folder;
67
pub mod another_mod;
@@ -28,6 +29,14 @@ impl Foo {
2829
/// Some documentation
2930
/// # A Heading
3031
pub fn a_method(&self) {}
32+
33+
#[cfg(all(
34+
feature = "Win32",
35+
feature = "Win32_System",
36+
feature = "Win32_System_Diagnostics",
37+
feature = "Win32_System_Diagnostics_Debug"
38+
))]
39+
pub fn lot_of_features() {}
3140
}
3241

3342
#[doc(cfg(feature = "foo-method"))]

0 commit comments

Comments
 (0)