From 97c2fa1f9d8c809c7d492dc8574bbe9f16684042 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 7 Jul 2021 11:07:09 +0200 Subject: [PATCH 1/9] Update regex crates This removes two dependencies of rustbuild --- Cargo.lock | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f8f1331579406..b432f9ae2272a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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" From a853a49425c042ffd2d0d46883537a6fc85dddba Mon Sep 17 00:00:00 2001 From: cyberia Date: Wed, 7 Jul 2021 18:22:17 +0100 Subject: [PATCH 2/9] Clarify behaviour of f64 and f32::sqrt when argument is negative zero --- library/std/src/f32.rs | 4 +++- library/std/src/f64.rs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/library/std/src/f32.rs b/library/std/src/f32.rs index 21bd79611a5e5..e0cc6ad1d4231 100644 --- a/library/std/src/f32.rs +++ b/library/std/src/f32.rs @@ -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")] diff --git a/library/std/src/f64.rs b/library/std/src/f64.rs index 8c8cf73741b51..7ed65b7dafec5 100644 --- a/library/std/src/f64.rs +++ b/library/std/src/f64.rs @@ -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")] From f84f377018b911b765f36cad27672dd5f2e955e8 Mon Sep 17 00:00:00 2001 From: Manuel Drehwald Date: Sat, 10 Jul 2021 19:51:36 +0200 Subject: [PATCH 3/9] Update reference.md Apparently the Rust reference has moved again, so the link gave a 404 error. --- src/doc/reference.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/reference.md b/src/doc/reference.md index fdeea17ed1124..5e09cdc5cf5cd 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -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). From f6e3644c11dc795cc1b9b5ed1aefb64f99dc4ce4 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Sat, 10 Jul 2021 13:16:16 -0700 Subject: [PATCH 4/9] cleanup(rustdoc): remove unused function getObjectNameById This function was used in an earlier version, when idx's were used to serialize function inputs and outputs. That's not done any more, so removed the JS-side support for it. --- src/librustdoc/html/static/js/search.js | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js index a7fc0b831f410..76e7295bce329 100644 --- a/src/librustdoc/html/static/js/search.js +++ b/src/librustdoc/html/static/js/search.js @@ -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 { From 5302539c98dafbe49f798ddd274c27686a2b7f6c Mon Sep 17 00:00:00 2001 From: Zach Lute Date: Wed, 1 Jul 2020 11:25:54 -0700 Subject: [PATCH 5/9] Change all 'optflag' arguments to 'optflagmulti' Because specifying these flags multiple times will never be discernibly different in functionality from specifying them a single time, there is no reason to fail and report an error to the user. --- src/librustdoc/lib.rs | 30 ++++++++++++++--------------- src/test/rustdoc/duplicate-flags.rs | 4 ++++ 2 files changed, 19 insertions(+), 15 deletions(-) create mode 100644 src/test/rustdoc/duplicate-flags.rs diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 64a9905b33f15..ec233a689ef83 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -269,9 +269,9 @@ fn opts() -> Vec { 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 { ) }), 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 { 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 { ) }), 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 { 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 { 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 { ) }), 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 { ) }), 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", diff --git a/src/test/rustdoc/duplicate-flags.rs b/src/test/rustdoc/duplicate-flags.rs new file mode 100644 index 0000000000000..dde36df2cf50e --- /dev/null +++ b/src/test/rustdoc/duplicate-flags.rs @@ -0,0 +1,4 @@ +// compile-flags: --document-private-items --document-private-items + +// @has duplicate_flags/struct.Private.html +struct Private; From 0cc66c8ea73354e96abcd7fe4dc63e71a96451a5 Mon Sep 17 00:00:00 2001 From: Zach Lute Date: Sat, 10 Jul 2021 14:32:14 -0700 Subject: [PATCH 6/9] Change all instance of optflag added since the original change to optflagmulti. --- src/librustdoc/lib.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index ec233a689ef83..bc635190f4281 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -582,9 +582,9 @@ fn opts() -> Vec { 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 { "[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") }), ] } From 14633a0a27c9f82595c1af8123876f5d4a91871d Mon Sep 17 00:00:00 2001 From: Jacob Pratt Date: Sat, 10 Jul 2021 18:25:01 -0400 Subject: [PATCH 7/9] Fix tracking issue for `bool_to_option` --- library/core/src/bool.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/bool.rs b/library/core/src/bool.rs index 00164c631b305..dcafaae2f5b49 100644 --- a/library/core/src/bool.rs +++ b/library/core/src/bool.rs @@ -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(self, t: T) -> Option { if self { Some(t) } else { None } From 89d260f86eacde2a44e3af02a99b0bdf3ffea35a Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Sat, 10 Jul 2021 21:33:03 -0400 Subject: [PATCH 8/9] Account for `submodules = false` in config.toml when updating LLVM submodule --- src/bootstrap/native.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index b967b6dbd2dae..0be42d9b23486 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -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. From 9946ff227d3b1ec7ee5de9ef9b2f81ee4547df34 Mon Sep 17 00:00:00 2001 From: Fabian Wolff Date: Sun, 11 Jul 2021 17:04:11 +0200 Subject: [PATCH 9/9] Do not suggest adding a semicolon after `?` --- compiler/rustc_typeck/src/check/coercion.rs | 10 ++++-- .../try-operator-dont-suggest-semicolon.rs | 27 +++++++++++++++ ...try-operator-dont-suggest-semicolon.stderr | 33 +++++++++++++++++++ 3 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 src/test/ui/suggestions/try-operator-dont-suggest-semicolon.rs create mode 100644 src/test/ui/suggestions/try-operator-dont-suggest-semicolon.stderr diff --git a/compiler/rustc_typeck/src/check/coercion.rs b/compiler/rustc_typeck/src/check/coercion.rs index afa4d0f1c4de9..9e89804b74713 100644 --- a/compiler/rustc_typeck/src/check/coercion.rs +++ b/compiler/rustc_typeck/src/check/coercion.rs @@ -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() { diff --git a/src/test/ui/suggestions/try-operator-dont-suggest-semicolon.rs b/src/test/ui/suggestions/try-operator-dont-suggest-semicolon.rs new file mode 100644 index 0000000000000..f882a159f9834 --- /dev/null +++ b/src/test/ui/suggestions/try-operator-dont-suggest-semicolon.rs @@ -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) -> Result<(), ()> where F: FnMut() { Ok(()) } +fn b() -> i32 { 42 } diff --git a/src/test/ui/suggestions/try-operator-dont-suggest-semicolon.stderr b/src/test/ui/suggestions/try-operator-dont-suggest-semicolon.stderr new file mode 100644 index 0000000000000..4f7e18742e22e --- /dev/null +++ b/src/test/ui/suggestions/try-operator-dont-suggest-semicolon.stderr @@ -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`.