Auto merge of #87068 - JohnTitor:rollup-2xuisfx, r=JohnTitor

Rollup of 8 pull requests

Successful merges:

 - #73936 (Rustdoc: Change all 'optflag' arguments to 'optflagmulti')
 - #86926 (Update regex crates)
 - #86951 ([docs] Clarify behaviour of f64 and f32::sqrt when argument is negative zero)
 - #87031 (Update reference.md)
 - #87037 (cleanup(rustdoc): remove unused function getObjectNameById)
 - #87045 (Fix tracking issue for `bool_to_option`)
 - #87049 (Account for `submodules = false` in config.toml when updating LLVM submodule)
 - #87061 (Do not suggest adding a semicolon after `?`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2021-07-11 19:34:04 +00:00
commit 7a16cfcffc
12 changed files with 118 additions and 49 deletions

View file

@ -3044,31 +3044,29 @@ dependencies = [
[[package]]
name = "regex"
version = "1.4.3"
version = "1.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9251239e129e16308e70d853559389de218ac275b515068abc96829d05b948a"
checksum = "2a26af418b574bd56588335b3a3659a65725d4e636eb1016c2f9e3b38c7cc759"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
"thread_local",
]
[[package]]
name = "regex-automata"
version = "0.1.9"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae1ded71d66a4a97f5e961fd0cb25a5f366a42a41570d16a763a69c092c26ae4"
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
dependencies = [
"byteorder",
"regex-syntax",
]
[[package]]
name = "regex-syntax"
version = "0.6.22"
version = "0.6.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581"
checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
[[package]]
name = "remote-test-client"

View file

@ -1456,11 +1456,15 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
expected.is_unit(),
pointing_at_return_type,
) {
// If the block is from an external macro, then do not suggest
// adding a semicolon, because there's nowhere to put it.
// See issue #81943.
// If the block is from an external macro or try (`?`) desugaring, then
// do not suggest adding a semicolon, because there's nowhere to put it.
// See issues #81943 and #87051.
if cond_expr.span.desugaring_kind().is_none()
&& !in_external_macro(fcx.tcx.sess, cond_expr.span)
&& !matches!(
cond_expr.kind,
hir::ExprKind::Match(.., hir::MatchSource::TryDesugar)
)
{
err.span_label(cond_expr.span, "expected this to be `()`");
if expr.can_have_side_effects() {

View file

@ -12,7 +12,7 @@ impl bool {
/// assert_eq!(false.then_some(0), None);
/// assert_eq!(true.then_some(0), Some(0));
/// ```
#[unstable(feature = "bool_to_option", issue = "64260")]
#[unstable(feature = "bool_to_option", issue = "80967")]
#[inline]
pub fn then_some<T>(self, t: T) -> Option<T> {
if self { Some(t) } else { None }

View file

@ -324,18 +324,20 @@ impl f32 {
/// Returns the square root of a number.
///
/// Returns NaN if `self` is a negative number.
/// Returns NaN if `self` is a negative number other than `-0.0`.
///
/// # Examples
///
/// ```
/// let positive = 4.0_f32;
/// let negative = -4.0_f32;
/// let negative_zero = -0.0_f32;
///
/// let abs_difference = (positive.sqrt() - 2.0).abs();
///
/// assert!(abs_difference <= f32::EPSILON);
/// assert!(negative.sqrt().is_nan());
/// assert!(negative_zero.sqrt() == negative_zero);
/// ```
#[must_use = "method returns a new number and does not mutate the original value"]
#[stable(feature = "rust1", since = "1.0.0")]

View file

@ -324,18 +324,20 @@ impl f64 {
/// Returns the square root of a number.
///
/// Returns NaN if `self` is a negative number.
/// Returns NaN if `self` is a negative number other than `-0.0`.
///
/// # Examples
///
/// ```
/// let positive = 4.0_f64;
/// let negative = -4.0_f64;
/// let negative_zero = -0.0_f64;
///
/// let abs_difference = (positive.sqrt() - 2.0).abs();
///
/// assert!(abs_difference < 1e-10);
/// assert!(negative.sqrt().is_nan());
/// assert!(negative_zero.sqrt() == negative_zero);
/// ```
#[must_use = "method returns a new number and does not mutate the original value"]
#[stable(feature = "rust1", since = "1.0.0")]

View file

@ -99,6 +99,10 @@ pub(crate) fn update_llvm_submodule(build: &Build) {
t!(std::fs::read_dir(dir)).next().is_none()
}
if !build.config.submodules {
return;
}
// NOTE: The check for the empty directory is here because when running x.py
// the first time, the llvm submodule won't be checked out. Check it out
// now so we can build it.

View file

@ -1,4 +1,4 @@
% The Rust Reference has moved
We've split up the reference into chapters. Please find it at its new
home [here](reference/index.html).
home [here](https://doc.rust-lang.org/stable/reference/introduction.html).

View file

@ -289,13 +289,6 @@ window.initSearch = function(rawSearchIndex) {
};
}
function getObjectNameFromId(id) {
if (typeof id === "number") {
return searchIndex[id].name;
}
return id;
}
function checkGenerics(obj, val) {
// The names match, but we need to be sure that all generics kinda
// match as well.
@ -306,10 +299,10 @@ window.initSearch = function(rawSearchIndex) {
var elems = Object.create(null);
var elength = obj[GENERICS_DATA].length;
for (var x = 0; x < elength; ++x) {
if (!elems[getObjectNameFromId(obj[GENERICS_DATA][x])]) {
elems[getObjectNameFromId(obj[GENERICS_DATA][x])] = 0;
if (!elems[obj[GENERICS_DATA][x]]) {
elems[obj[GENERICS_DATA][x]] = 0;
}
elems[getObjectNameFromId(obj[GENERICS_DATA][x])] += 1;
elems[obj[GENERICS_DATA][x]] += 1;
}
var total = 0;
var done = 0;
@ -318,7 +311,7 @@ window.initSearch = function(rawSearchIndex) {
var vlength = val.generics.length;
for (x = 0; x < vlength; ++x) {
var lev = MAX_LEV_DISTANCE + 1;
var firstGeneric = getObjectNameFromId(val.generics[x]);
var firstGeneric = val.generics[x];
var match = null;
if (elems[firstGeneric]) {
match = firstGeneric;
@ -361,16 +354,16 @@ window.initSearch = function(rawSearchIndex) {
var elems = Object.create(null);
len = obj[GENERICS_DATA].length;
for (x = 0; x < len; ++x) {
if (!elems[getObjectNameFromId(obj[GENERICS_DATA][x])]) {
elems[getObjectNameFromId(obj[GENERICS_DATA][x])] = 0;
if (!elems[obj[GENERICS_DATA][x]]) {
elems[obj[GENERICS_DATA][x]] = 0;
}
elems[getObjectNameFromId(obj[GENERICS_DATA][x])] += 1;
elems[obj[GENERICS_DATA][x]] += 1;
}
var allFound = true;
len = val.generics.length;
for (x = 0; x < len; ++x) {
firstGeneric = getObjectNameFromId(val.generics[x]);
firstGeneric = val.generics[x];
if (elems[firstGeneric]) {
elems[firstGeneric] -= 1;
} else {

View file

@ -269,9 +269,9 @@ fn opts() -> Vec<RustcOptGroup> {
let stable: fn(_, fn(&mut getopts::Options) -> &mut _) -> _ = RustcOptGroup::stable;
let unstable: fn(_, fn(&mut getopts::Options) -> &mut _) -> _ = RustcOptGroup::unstable;
vec![
stable("h", |o| o.optflag("h", "help", "show this help message")),
stable("V", |o| o.optflag("V", "version", "print rustdoc's version")),
stable("v", |o| o.optflag("v", "verbose", "use verbose output")),
stable("h", |o| o.optflagmulti("h", "help", "show this help message")),
stable("V", |o| o.optflagmulti("V", "version", "print rustdoc's version")),
stable("v", |o| o.optflagmulti("v", "verbose", "use verbose output")),
stable("r", |o| {
o.optopt("r", "input-format", "the input type of the specified file", "[rust]")
}),
@ -309,14 +309,14 @@ fn opts() -> Vec<RustcOptGroup> {
)
}),
stable("plugins", |o| o.optmulti("", "plugins", "removed", "PLUGINS")),
stable("no-default", |o| o.optflag("", "no-defaults", "don't run the default passes")),
stable("no-default", |o| o.optflagmulti("", "no-defaults", "don't run the default passes")),
stable("document-private-items", |o| {
o.optflag("", "document-private-items", "document private items")
o.optflagmulti("", "document-private-items", "document private items")
}),
unstable("document-hidden-items", |o| {
o.optflag("", "document-hidden-items", "document items that have doc(hidden)")
o.optflagmulti("", "document-hidden-items", "document items that have doc(hidden)")
}),
stable("test", |o| o.optflag("", "test", "run code examples as tests")),
stable("test", |o| o.optflagmulti("", "test", "run code examples as tests")),
stable("test-args", |o| {
o.optmulti("", "test-args", "arguments to pass to the test runner", "ARGS")
}),
@ -386,7 +386,7 @@ fn opts() -> Vec<RustcOptGroup> {
o.optopt("", "markdown-playground-url", "URL to send code snippets to", "URL")
}),
stable("markdown-no-toc", |o| {
o.optflag("", "markdown-no-toc", "don't include table of contents")
o.optflagmulti("", "markdown-no-toc", "don't include table of contents")
}),
stable("e", |o| {
o.optopt(
@ -412,13 +412,13 @@ fn opts() -> Vec<RustcOptGroup> {
)
}),
unstable("display-warnings", |o| {
o.optflag("", "display-warnings", "to print code warnings when testing doc")
o.optflagmulti("", "display-warnings", "to print code warnings when testing doc")
}),
stable("crate-version", |o| {
o.optopt("", "crate-version", "crate version to print into documentation", "VERSION")
}),
unstable("sort-modules-by-appearance", |o| {
o.optflag(
o.optflagmulti(
"",
"sort-modules-by-appearance",
"sort modules by where they appear in the program, rather than alphabetically",
@ -495,7 +495,7 @@ fn opts() -> Vec<RustcOptGroup> {
o.optopt("", "json", "Configure the structure of JSON diagnostics", "CONFIG")
}),
unstable("disable-minification", |o| {
o.optflag("", "disable-minification", "Disable minification applied on JS files")
o.optflagmulti("", "disable-minification", "Disable minification applied on JS files")
}),
stable("warn", |o| o.optmulti("W", "warn", "Set lint warnings", "OPT")),
stable("allow", |o| o.optmulti("A", "allow", "Set lint allowed", "OPT")),
@ -523,7 +523,7 @@ fn opts() -> Vec<RustcOptGroup> {
o.optopt("", "index-page", "Markdown file to be used as index page", "PATH")
}),
unstable("enable-index-page", |o| {
o.optflag("", "enable-index-page", "To enable generation of the index page")
o.optflagmulti("", "enable-index-page", "To enable generation of the index page")
}),
unstable("static-root-path", |o| {
o.optopt(
@ -535,7 +535,7 @@ fn opts() -> Vec<RustcOptGroup> {
)
}),
unstable("disable-per-crate-search", |o| {
o.optflag(
o.optflagmulti(
"",
"disable-per-crate-search",
"disables generating the crate selector on the search box",
@ -550,14 +550,14 @@ fn opts() -> Vec<RustcOptGroup> {
)
}),
unstable("show-coverage", |o| {
o.optflag(
o.optflagmulti(
"",
"show-coverage",
"calculate percentage of public items with documentation",
)
}),
unstable("enable-per-target-ignores", |o| {
o.optflag(
o.optflagmulti(
"",
"enable-per-target-ignores",
"parse ignore-foo for ignoring doctests on a per-target basis",
@ -582,9 +582,9 @@ fn opts() -> Vec<RustcOptGroup> {
unstable("test-builder", |o| {
o.optopt("", "test-builder", "The rustc-like binary to use as the test builder", "PATH")
}),
unstable("check", |o| o.optflag("", "check", "Run rustdoc checks")),
unstable("check", |o| o.optflagmulti("", "check", "Run rustdoc checks")),
unstable("generate-redirect-map", |o| {
o.optflag(
o.optflagmulti(
"",
"generate-redirect-map",
"Generate JSON file at the top level instead of generating HTML redirection files",
@ -598,9 +598,11 @@ fn opts() -> Vec<RustcOptGroup> {
"[unversioned-shared-resources,toolchain-shared-resources,invocation-specific]",
)
}),
unstable("no-run", |o| o.optflag("", "no-run", "Compile doctests without running them")),
unstable("no-run", |o| {
o.optflagmulti("", "no-run", "Compile doctests without running them")
}),
unstable("show-type-layout", |o| {
o.optflag("", "show-type-layout", "Include the memory layout of types in the docs")
o.optflagmulti("", "show-type-layout", "Include the memory layout of types in the docs")
}),
]
}

View file

@ -0,0 +1,4 @@
// compile-flags: --document-private-items --document-private-items
// @has duplicate_flags/struct.Private.html
struct Private;

View file

@ -0,0 +1,27 @@
// Regression test for #87051, where a double semicolon was erroneously
// suggested after a `?` operator.
fn main() -> Result<(), ()> {
a(|| {
b()
//~^ ERROR: mismatched types [E0308]
//~| NOTE: expected `()`, found `i32`
//~| HELP: consider using a semicolon here
})?;
// Here, we do want to suggest a semicolon:
let x = Ok(42);
if true {
//~^ NOTE: expected this to be `()`
x?
//~^ ERROR: mismatched types [E0308]
//~| NOTE: expected `()`, found integer
//~| HELP: consider using a semicolon here
}
//~^ HELP: consider using a semicolon here
Ok(())
}
fn a<F>(f: F) -> Result<(), ()> where F: FnMut() { Ok(()) }
fn b() -> i32 { 42 }

View file

@ -0,0 +1,33 @@
error[E0308]: mismatched types
--> $DIR/try-operator-dont-suggest-semicolon.rs:6:9
|
LL | b()
| ^^^- help: consider using a semicolon here: `;`
| |
| expected `()`, found `i32`
error[E0308]: mismatched types
--> $DIR/try-operator-dont-suggest-semicolon.rs:16:9
|
LL | / if true {
LL | |
LL | | x?
| | ^^ expected `()`, found integer
LL | |
LL | |
LL | |
LL | | }
| |_____- expected this to be `()`
|
help: consider using a semicolon here
|
LL | x?;
| ^
help: consider using a semicolon here
|
LL | };
| ^
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0308`.