Skip to content

Commit 1f7762b

Browse files
committed
Auto merge of #80024 - GuillaumeGomez:rollup-rqd46ko, r=GuillaumeGomez
Rollup of 3 pull requests Successful merges: - #79918 (doc(array,vec): add notes about side effects when empty-initializing) - #79936 (Fix item name display on mobile) - #80013 (Refactor test_lang_string_parse to make it clearer) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 3c45bff + 2169094 commit 1f7762b

File tree

4 files changed

+82
-75
lines changed

4 files changed

+82
-75
lines changed

library/alloc/src/macros.rs

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
/// to the same boxed integer value, not five references pointing to independently
3030
/// boxed integers.
3131
///
32+
/// Also, note that `vec![expr; 0]` is allowed, and produces an empty vector.
33+
/// This will still evaluate `expr`, however, and immediately drop the resulting value, so
34+
/// be mindful of side effects.
35+
///
3236
/// [`Vec`]: crate::vec::Vec
3337
#[cfg(not(test))]
3438
#[macro_export]

library/std/src/primitive_docs.rs

+4
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,10 @@ mod prim_pointer {}
489489
/// * A repeat expression `[x; N]`, which produces an array with `N` copies of `x`.
490490
/// The type of `x` must be [`Copy`].
491491
///
492+
/// Note that `[expr; 0]` is allowed, and produces an empty array.
493+
/// This will still evaluate `expr`, however, and immediately drop the resulting value, so
494+
/// be mindful of side effects.
495+
///
492496
/// Arrays of *any* size implement the following traits if the element type allows it:
493497
///
494498
/// - [`Copy`]

src/librustdoc/html/markdown/tests.rs

+69-74
Original file line numberDiff line numberDiff line change
@@ -51,82 +51,77 @@ fn test_unique_id() {
5151

5252
#[test]
5353
fn test_lang_string_parse() {
54-
fn t(
55-
s: &str,
56-
should_panic: bool,
57-
no_run: bool,
58-
ignore: Ignore,
59-
rust: bool,
60-
test_harness: bool,
61-
compile_fail: bool,
62-
allow_fail: bool,
63-
error_codes: Vec<String>,
64-
edition: Option<Edition>,
65-
) {
66-
assert_eq!(
67-
LangString::parse(s, ErrorCodes::Yes, true, None),
68-
LangString {
69-
should_panic,
70-
no_run,
71-
ignore,
72-
rust,
73-
test_harness,
74-
compile_fail,
75-
error_codes,
76-
original: s.to_owned(),
77-
allow_fail,
78-
edition,
79-
}
80-
)
54+
fn t(lg: LangString) {
55+
let s = &lg.original;
56+
assert_eq!(LangString::parse(s, ErrorCodes::Yes, true, None), lg)
8157
}
82-
let ignore_foo = Ignore::Some(vec!["foo".to_string()]);
8358

84-
fn v() -> Vec<String> {
85-
Vec::new()
86-
}
87-
88-
// marker | should_panic | no_run | ignore | rust | test_harness
89-
// | compile_fail | allow_fail | error_codes | edition
90-
t("", false, false, Ignore::None, true, false, false, false, v(), None);
91-
t("rust", false, false, Ignore::None, true, false, false, false, v(), None);
92-
t("sh", false, false, Ignore::None, false, false, false, false, v(), None);
93-
t("ignore", false, false, Ignore::All, true, false, false, false, v(), None);
94-
t("ignore-foo", false, false, ignore_foo, true, false, false, false, v(), None);
95-
t("should_panic", true, false, Ignore::None, true, false, false, false, v(), None);
96-
t("no_run", false, true, Ignore::None, true, false, false, false, v(), None);
97-
t("test_harness", false, false, Ignore::None, true, true, false, false, v(), None);
98-
t("compile_fail", false, true, Ignore::None, true, false, true, false, v(), None);
99-
t("allow_fail", false, false, Ignore::None, true, false, false, true, v(), None);
100-
t("{.no_run .example}", false, true, Ignore::None, true, false, false, false, v(), None);
101-
t("{.sh .should_panic}", true, false, Ignore::None, false, false, false, false, v(), None);
102-
t("{.example .rust}", false, false, Ignore::None, true, false, false, false, v(), None);
103-
t("{.test_harness .rust}", false, false, Ignore::None, true, true, false, false, v(), None);
104-
t("text, no_run", false, true, Ignore::None, false, false, false, false, v(), None);
105-
t("text,no_run", false, true, Ignore::None, false, false, false, false, v(), None);
106-
t(
107-
"edition2015",
108-
false,
109-
false,
110-
Ignore::None,
111-
true,
112-
false,
113-
false,
114-
false,
115-
v(),
116-
Some(Edition::Edition2015),
117-
);
118-
t(
119-
"edition2018",
120-
false,
121-
false,
122-
Ignore::None,
123-
true,
124-
false,
125-
false,
126-
false,
127-
v(),
128-
Some(Edition::Edition2018),
129-
);
59+
t(LangString::all_false());
60+
t(LangString { original: "rust".into(), ..LangString::all_false() });
61+
t(LangString { original: "sh".into(), rust: false, ..LangString::all_false() });
62+
t(LangString { original: "ignore".into(), ignore: Ignore::All, ..LangString::all_false() });
63+
t(LangString {
64+
original: "ignore-foo".into(),
65+
ignore: Ignore::Some(vec!["foo".to_string()]),
66+
..LangString::all_false()
67+
});
68+
t(LangString {
69+
original: "should_panic".into(),
70+
should_panic: true,
71+
..LangString::all_false()
72+
});
73+
t(LangString { original: "no_run".into(), no_run: true, ..LangString::all_false() });
74+
t(LangString {
75+
original: "test_harness".into(),
76+
test_harness: true,
77+
..LangString::all_false()
78+
});
79+
t(LangString {
80+
original: "compile_fail".into(),
81+
no_run: true,
82+
compile_fail: true,
83+
..LangString::all_false()
84+
});
85+
t(LangString { original: "allow_fail".into(), allow_fail: true, ..LangString::all_false() });
86+
t(LangString {
87+
original: "{.no_run .example}".into(),
88+
no_run: true,
89+
..LangString::all_false()
90+
});
91+
t(LangString {
92+
original: "{.sh .should_panic}".into(),
93+
should_panic: true,
94+
rust: false,
95+
..LangString::all_false()
96+
});
97+
t(LangString { original: "{.example .rust}".into(), ..LangString::all_false() });
98+
t(LangString {
99+
original: "{.test_harness .rust}".into(),
100+
test_harness: true,
101+
..LangString::all_false()
102+
});
103+
t(LangString {
104+
original: "text, no_run".into(),
105+
no_run: true,
106+
rust: false,
107+
..LangString::all_false()
108+
});
109+
t(LangString {
110+
original: "text,no_run".into(),
111+
no_run: true,
112+
rust: false,
113+
..LangString::all_false()
114+
});
115+
t(LangString {
116+
original: "edition2015".into(),
117+
edition: Some(Edition::Edition2015),
118+
..LangString::all_false()
119+
});
120+
t(LangString {
121+
original: "edition2018".into(),
122+
edition: Some(Edition::Edition2018),
123+
..LangString::all_false()
124+
});
130125
}
131126

132127
#[test]

src/librustdoc/html/static/rustdoc.css

+5-1
Original file line numberDiff line numberDiff line change
@@ -1570,9 +1570,13 @@ h4 > .notable-traits {
15701570
height: 73px;
15711571
}
15721572

1573+
#main {
1574+
margin-top: 100px;
1575+
}
1576+
15731577
#main > table:not(.table-display) td {
15741578
word-break: break-word;
1575-
min-width: 10%;
1579+
width: 50%;
15761580
}
15771581

15781582
.search-container > div {

0 commit comments

Comments
 (0)