Skip to content

Commit

Permalink
Auto merge of #80024 - GuillaumeGomez:rollup-rqd46ko, r=GuillaumeGomez
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Dec 14, 2020
2 parents 3c45bff + 2169094 commit 1f7762b
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 75 deletions.
4 changes: 4 additions & 0 deletions library/alloc/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
/// to the same boxed integer value, not five references pointing to independently
/// boxed integers.
///
/// Also, note that `vec![expr; 0]` is allowed, and produces an empty vector.
/// This will still evaluate `expr`, however, and immediately drop the resulting value, so
/// be mindful of side effects.
///
/// [`Vec`]: crate::vec::Vec
#[cfg(not(test))]
#[macro_export]
Expand Down
4 changes: 4 additions & 0 deletions library/std/src/primitive_docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,10 @@ mod prim_pointer {}
/// * A repeat expression `[x; N]`, which produces an array with `N` copies of `x`.
/// The type of `x` must be [`Copy`].
///
/// Note that `[expr; 0]` is allowed, and produces an empty array.
/// This will still evaluate `expr`, however, and immediately drop the resulting value, so
/// be mindful of side effects.
///
/// Arrays of *any* size implement the following traits if the element type allows it:
///
/// - [`Copy`]
Expand Down
143 changes: 69 additions & 74 deletions src/librustdoc/html/markdown/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,82 +51,77 @@ fn test_unique_id() {

#[test]
fn test_lang_string_parse() {
fn t(
s: &str,
should_panic: bool,
no_run: bool,
ignore: Ignore,
rust: bool,
test_harness: bool,
compile_fail: bool,
allow_fail: bool,
error_codes: Vec<String>,
edition: Option<Edition>,
) {
assert_eq!(
LangString::parse(s, ErrorCodes::Yes, true, None),
LangString {
should_panic,
no_run,
ignore,
rust,
test_harness,
compile_fail,
error_codes,
original: s.to_owned(),
allow_fail,
edition,
}
)
fn t(lg: LangString) {
let s = &lg.original;
assert_eq!(LangString::parse(s, ErrorCodes::Yes, true, None), lg)
}
let ignore_foo = Ignore::Some(vec!["foo".to_string()]);

fn v() -> Vec<String> {
Vec::new()
}

// marker | should_panic | no_run | ignore | rust | test_harness
// | compile_fail | allow_fail | error_codes | edition
t("", false, false, Ignore::None, true, false, false, false, v(), None);
t("rust", false, false, Ignore::None, true, false, false, false, v(), None);
t("sh", false, false, Ignore::None, false, false, false, false, v(), None);
t("ignore", false, false, Ignore::All, true, false, false, false, v(), None);
t("ignore-foo", false, false, ignore_foo, true, false, false, false, v(), None);
t("should_panic", true, false, Ignore::None, true, false, false, false, v(), None);
t("no_run", false, true, Ignore::None, true, false, false, false, v(), None);
t("test_harness", false, false, Ignore::None, true, true, false, false, v(), None);
t("compile_fail", false, true, Ignore::None, true, false, true, false, v(), None);
t("allow_fail", false, false, Ignore::None, true, false, false, true, v(), None);
t("{.no_run .example}", false, true, Ignore::None, true, false, false, false, v(), None);
t("{.sh .should_panic}", true, false, Ignore::None, false, false, false, false, v(), None);
t("{.example .rust}", false, false, Ignore::None, true, false, false, false, v(), None);
t("{.test_harness .rust}", false, false, Ignore::None, true, true, false, false, v(), None);
t("text, no_run", false, true, Ignore::None, false, false, false, false, v(), None);
t("text,no_run", false, true, Ignore::None, false, false, false, false, v(), None);
t(
"edition2015",
false,
false,
Ignore::None,
true,
false,
false,
false,
v(),
Some(Edition::Edition2015),
);
t(
"edition2018",
false,
false,
Ignore::None,
true,
false,
false,
false,
v(),
Some(Edition::Edition2018),
);
t(LangString::all_false());
t(LangString { original: "rust".into(), ..LangString::all_false() });
t(LangString { original: "sh".into(), rust: false, ..LangString::all_false() });
t(LangString { original: "ignore".into(), ignore: Ignore::All, ..LangString::all_false() });
t(LangString {
original: "ignore-foo".into(),
ignore: Ignore::Some(vec!["foo".to_string()]),
..LangString::all_false()
});
t(LangString {
original: "should_panic".into(),
should_panic: true,
..LangString::all_false()
});
t(LangString { original: "no_run".into(), no_run: true, ..LangString::all_false() });
t(LangString {
original: "test_harness".into(),
test_harness: true,
..LangString::all_false()
});
t(LangString {
original: "compile_fail".into(),
no_run: true,
compile_fail: true,
..LangString::all_false()
});
t(LangString { original: "allow_fail".into(), allow_fail: true, ..LangString::all_false() });
t(LangString {
original: "{.no_run .example}".into(),
no_run: true,
..LangString::all_false()
});
t(LangString {
original: "{.sh .should_panic}".into(),
should_panic: true,
rust: false,
..LangString::all_false()
});
t(LangString { original: "{.example .rust}".into(), ..LangString::all_false() });
t(LangString {
original: "{.test_harness .rust}".into(),
test_harness: true,
..LangString::all_false()
});
t(LangString {
original: "text, no_run".into(),
no_run: true,
rust: false,
..LangString::all_false()
});
t(LangString {
original: "text,no_run".into(),
no_run: true,
rust: false,
..LangString::all_false()
});
t(LangString {
original: "edition2015".into(),
edition: Some(Edition::Edition2015),
..LangString::all_false()
});
t(LangString {
original: "edition2018".into(),
edition: Some(Edition::Edition2018),
..LangString::all_false()
});
}

#[test]
Expand Down
6 changes: 5 additions & 1 deletion src/librustdoc/html/static/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -1570,9 +1570,13 @@ h4 > .notable-traits {
height: 73px;
}

#main {
margin-top: 100px;
}

#main > table:not(.table-display) td {
word-break: break-word;
min-width: 10%;
width: 50%;
}

.search-container > div {
Expand Down

0 comments on commit 1f7762b

Please sign in to comment.