Skip to content

Commit 7a16cfc

Browse files
committed
Auto merge of rust-lang#87068 - JohnTitor:rollup-2xuisfx, r=JohnTitor
Rollup of 8 pull requests Successful merges: - rust-lang#73936 (Rustdoc: Change all 'optflag' arguments to 'optflagmulti') - rust-lang#86926 (Update regex crates) - rust-lang#86951 ([docs] Clarify behaviour of f64 and f32::sqrt when argument is negative zero) - rust-lang#87031 (Update reference.md) - rust-lang#87037 (cleanup(rustdoc): remove unused function getObjectNameById) - rust-lang#87045 (Fix tracking issue for `bool_to_option`) - rust-lang#87049 (Account for `submodules = false` in config.toml when updating LLVM submodule) - rust-lang#87061 (Do not suggest adding a semicolon after `?`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 7256855 + 5fcefb1 commit 7a16cfc

File tree

12 files changed

+118
-49
lines changed

12 files changed

+118
-49
lines changed

Cargo.lock

+6-8
Original file line numberDiff line numberDiff line change
@@ -3044,31 +3044,29 @@ dependencies = [
30443044

30453045
[[package]]
30463046
name = "regex"
3047-
version = "1.4.3"
3047+
version = "1.4.6"
30483048
source = "registry+https://github.com/rust-lang/crates.io-index"
3049-
checksum = "d9251239e129e16308e70d853559389de218ac275b515068abc96829d05b948a"
3049+
checksum = "2a26af418b574bd56588335b3a3659a65725d4e636eb1016c2f9e3b38c7cc759"
30503050
dependencies = [
30513051
"aho-corasick",
30523052
"memchr",
30533053
"regex-syntax",
3054-
"thread_local",
30553054
]
30563055

30573056
[[package]]
30583057
name = "regex-automata"
3059-
version = "0.1.9"
3058+
version = "0.1.10"
30603059
source = "registry+https://github.com/rust-lang/crates.io-index"
3061-
checksum = "ae1ded71d66a4a97f5e961fd0cb25a5f366a42a41570d16a763a69c092c26ae4"
3060+
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
30623061
dependencies = [
3063-
"byteorder",
30643062
"regex-syntax",
30653063
]
30663064

30673065
[[package]]
30683066
name = "regex-syntax"
3069-
version = "0.6.22"
3067+
version = "0.6.25"
30703068
source = "registry+https://github.com/rust-lang/crates.io-index"
3071-
checksum = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581"
3069+
checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
30723070

30733071
[[package]]
30743072
name = "remote-test-client"

compiler/rustc_typeck/src/check/coercion.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -1456,11 +1456,15 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
14561456
expected.is_unit(),
14571457
pointing_at_return_type,
14581458
) {
1459-
// If the block is from an external macro, then do not suggest
1460-
// adding a semicolon, because there's nowhere to put it.
1461-
// See issue #81943.
1459+
// If the block is from an external macro or try (`?`) desugaring, then
1460+
// do not suggest adding a semicolon, because there's nowhere to put it.
1461+
// See issues #81943 and #87051.
14621462
if cond_expr.span.desugaring_kind().is_none()
14631463
&& !in_external_macro(fcx.tcx.sess, cond_expr.span)
1464+
&& !matches!(
1465+
cond_expr.kind,
1466+
hir::ExprKind::Match(.., hir::MatchSource::TryDesugar)
1467+
)
14641468
{
14651469
err.span_label(cond_expr.span, "expected this to be `()`");
14661470
if expr.can_have_side_effects() {

library/core/src/bool.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ impl bool {
1212
/// assert_eq!(false.then_some(0), None);
1313
/// assert_eq!(true.then_some(0), Some(0));
1414
/// ```
15-
#[unstable(feature = "bool_to_option", issue = "64260")]
15+
#[unstable(feature = "bool_to_option", issue = "80967")]
1616
#[inline]
1717
pub fn then_some<T>(self, t: T) -> Option<T> {
1818
if self { Some(t) } else { None }

library/std/src/f32.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -324,18 +324,20 @@ impl f32 {
324324

325325
/// Returns the square root of a number.
326326
///
327-
/// Returns NaN if `self` is a negative number.
327+
/// Returns NaN if `self` is a negative number other than `-0.0`.
328328
///
329329
/// # Examples
330330
///
331331
/// ```
332332
/// let positive = 4.0_f32;
333333
/// let negative = -4.0_f32;
334+
/// let negative_zero = -0.0_f32;
334335
///
335336
/// let abs_difference = (positive.sqrt() - 2.0).abs();
336337
///
337338
/// assert!(abs_difference <= f32::EPSILON);
338339
/// assert!(negative.sqrt().is_nan());
340+
/// assert!(negative_zero.sqrt() == negative_zero);
339341
/// ```
340342
#[must_use = "method returns a new number and does not mutate the original value"]
341343
#[stable(feature = "rust1", since = "1.0.0")]

library/std/src/f64.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -324,18 +324,20 @@ impl f64 {
324324

325325
/// Returns the square root of a number.
326326
///
327-
/// Returns NaN if `self` is a negative number.
327+
/// Returns NaN if `self` is a negative number other than `-0.0`.
328328
///
329329
/// # Examples
330330
///
331331
/// ```
332332
/// let positive = 4.0_f64;
333333
/// let negative = -4.0_f64;
334+
/// let negative_zero = -0.0_f64;
334335
///
335336
/// let abs_difference = (positive.sqrt() - 2.0).abs();
336337
///
337338
/// assert!(abs_difference < 1e-10);
338339
/// assert!(negative.sqrt().is_nan());
340+
/// assert!(negative_zero.sqrt() == negative_zero);
339341
/// ```
340342
#[must_use = "method returns a new number and does not mutate the original value"]
341343
#[stable(feature = "rust1", since = "1.0.0")]

src/bootstrap/native.rs

+4
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ pub(crate) fn update_llvm_submodule(build: &Build) {
9999
t!(std::fs::read_dir(dir)).next().is_none()
100100
}
101101

102+
if !build.config.submodules {
103+
return;
104+
}
105+
102106
// NOTE: The check for the empty directory is here because when running x.py
103107
// the first time, the llvm submodule won't be checked out. Check it out
104108
// now so we can build it.

src/doc/reference.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
% The Rust Reference has moved
22

33
We've split up the reference into chapters. Please find it at its new
4-
home [here](reference/index.html).
4+
home [here](https://doc.rust-lang.org/stable/reference/introduction.html).

src/librustdoc/html/static/js/search.js

+8-15
Original file line numberDiff line numberDiff line change
@@ -289,13 +289,6 @@ window.initSearch = function(rawSearchIndex) {
289289
};
290290
}
291291

292-
function getObjectNameFromId(id) {
293-
if (typeof id === "number") {
294-
return searchIndex[id].name;
295-
}
296-
return id;
297-
}
298-
299292
function checkGenerics(obj, val) {
300293
// The names match, but we need to be sure that all generics kinda
301294
// match as well.
@@ -306,10 +299,10 @@ window.initSearch = function(rawSearchIndex) {
306299
var elems = Object.create(null);
307300
var elength = obj[GENERICS_DATA].length;
308301
for (var x = 0; x < elength; ++x) {
309-
if (!elems[getObjectNameFromId(obj[GENERICS_DATA][x])]) {
310-
elems[getObjectNameFromId(obj[GENERICS_DATA][x])] = 0;
302+
if (!elems[obj[GENERICS_DATA][x]]) {
303+
elems[obj[GENERICS_DATA][x]] = 0;
311304
}
312-
elems[getObjectNameFromId(obj[GENERICS_DATA][x])] += 1;
305+
elems[obj[GENERICS_DATA][x]] += 1;
313306
}
314307
var total = 0;
315308
var done = 0;
@@ -318,7 +311,7 @@ window.initSearch = function(rawSearchIndex) {
318311
var vlength = val.generics.length;
319312
for (x = 0; x < vlength; ++x) {
320313
var lev = MAX_LEV_DISTANCE + 1;
321-
var firstGeneric = getObjectNameFromId(val.generics[x]);
314+
var firstGeneric = val.generics[x];
322315
var match = null;
323316
if (elems[firstGeneric]) {
324317
match = firstGeneric;
@@ -361,16 +354,16 @@ window.initSearch = function(rawSearchIndex) {
361354
var elems = Object.create(null);
362355
len = obj[GENERICS_DATA].length;
363356
for (x = 0; x < len; ++x) {
364-
if (!elems[getObjectNameFromId(obj[GENERICS_DATA][x])]) {
365-
elems[getObjectNameFromId(obj[GENERICS_DATA][x])] = 0;
357+
if (!elems[obj[GENERICS_DATA][x]]) {
358+
elems[obj[GENERICS_DATA][x]] = 0;
366359
}
367-
elems[getObjectNameFromId(obj[GENERICS_DATA][x])] += 1;
360+
elems[obj[GENERICS_DATA][x]] += 1;
368361
}
369362

370363
var allFound = true;
371364
len = val.generics.length;
372365
for (x = 0; x < len; ++x) {
373-
firstGeneric = getObjectNameFromId(val.generics[x]);
366+
firstGeneric = val.generics[x];
374367
if (elems[firstGeneric]) {
375368
elems[firstGeneric] -= 1;
376369
} else {

src/librustdoc/lib.rs

+21-19
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,9 @@ fn opts() -> Vec<RustcOptGroup> {
269269
let stable: fn(_, fn(&mut getopts::Options) -> &mut _) -> _ = RustcOptGroup::stable;
270270
let unstable: fn(_, fn(&mut getopts::Options) -> &mut _) -> _ = RustcOptGroup::unstable;
271271
vec![
272-
stable("h", |o| o.optflag("h", "help", "show this help message")),
273-
stable("V", |o| o.optflag("V", "version", "print rustdoc's version")),
274-
stable("v", |o| o.optflag("v", "verbose", "use verbose output")),
272+
stable("h", |o| o.optflagmulti("h", "help", "show this help message")),
273+
stable("V", |o| o.optflagmulti("V", "version", "print rustdoc's version")),
274+
stable("v", |o| o.optflagmulti("v", "verbose", "use verbose output")),
275275
stable("r", |o| {
276276
o.optopt("r", "input-format", "the input type of the specified file", "[rust]")
277277
}),
@@ -309,14 +309,14 @@ fn opts() -> Vec<RustcOptGroup> {
309309
)
310310
}),
311311
stable("plugins", |o| o.optmulti("", "plugins", "removed", "PLUGINS")),
312-
stable("no-default", |o| o.optflag("", "no-defaults", "don't run the default passes")),
312+
stable("no-default", |o| o.optflagmulti("", "no-defaults", "don't run the default passes")),
313313
stable("document-private-items", |o| {
314-
o.optflag("", "document-private-items", "document private items")
314+
o.optflagmulti("", "document-private-items", "document private items")
315315
}),
316316
unstable("document-hidden-items", |o| {
317-
o.optflag("", "document-hidden-items", "document items that have doc(hidden)")
317+
o.optflagmulti("", "document-hidden-items", "document items that have doc(hidden)")
318318
}),
319-
stable("test", |o| o.optflag("", "test", "run code examples as tests")),
319+
stable("test", |o| o.optflagmulti("", "test", "run code examples as tests")),
320320
stable("test-args", |o| {
321321
o.optmulti("", "test-args", "arguments to pass to the test runner", "ARGS")
322322
}),
@@ -386,7 +386,7 @@ fn opts() -> Vec<RustcOptGroup> {
386386
o.optopt("", "markdown-playground-url", "URL to send code snippets to", "URL")
387387
}),
388388
stable("markdown-no-toc", |o| {
389-
o.optflag("", "markdown-no-toc", "don't include table of contents")
389+
o.optflagmulti("", "markdown-no-toc", "don't include table of contents")
390390
}),
391391
stable("e", |o| {
392392
o.optopt(
@@ -412,13 +412,13 @@ fn opts() -> Vec<RustcOptGroup> {
412412
)
413413
}),
414414
unstable("display-warnings", |o| {
415-
o.optflag("", "display-warnings", "to print code warnings when testing doc")
415+
o.optflagmulti("", "display-warnings", "to print code warnings when testing doc")
416416
}),
417417
stable("crate-version", |o| {
418418
o.optopt("", "crate-version", "crate version to print into documentation", "VERSION")
419419
}),
420420
unstable("sort-modules-by-appearance", |o| {
421-
o.optflag(
421+
o.optflagmulti(
422422
"",
423423
"sort-modules-by-appearance",
424424
"sort modules by where they appear in the program, rather than alphabetically",
@@ -495,7 +495,7 @@ fn opts() -> Vec<RustcOptGroup> {
495495
o.optopt("", "json", "Configure the structure of JSON diagnostics", "CONFIG")
496496
}),
497497
unstable("disable-minification", |o| {
498-
o.optflag("", "disable-minification", "Disable minification applied on JS files")
498+
o.optflagmulti("", "disable-minification", "Disable minification applied on JS files")
499499
}),
500500
stable("warn", |o| o.optmulti("W", "warn", "Set lint warnings", "OPT")),
501501
stable("allow", |o| o.optmulti("A", "allow", "Set lint allowed", "OPT")),
@@ -523,7 +523,7 @@ fn opts() -> Vec<RustcOptGroup> {
523523
o.optopt("", "index-page", "Markdown file to be used as index page", "PATH")
524524
}),
525525
unstable("enable-index-page", |o| {
526-
o.optflag("", "enable-index-page", "To enable generation of the index page")
526+
o.optflagmulti("", "enable-index-page", "To enable generation of the index page")
527527
}),
528528
unstable("static-root-path", |o| {
529529
o.optopt(
@@ -535,7 +535,7 @@ fn opts() -> Vec<RustcOptGroup> {
535535
)
536536
}),
537537
unstable("disable-per-crate-search", |o| {
538-
o.optflag(
538+
o.optflagmulti(
539539
"",
540540
"disable-per-crate-search",
541541
"disables generating the crate selector on the search box",
@@ -550,14 +550,14 @@ fn opts() -> Vec<RustcOptGroup> {
550550
)
551551
}),
552552
unstable("show-coverage", |o| {
553-
o.optflag(
553+
o.optflagmulti(
554554
"",
555555
"show-coverage",
556556
"calculate percentage of public items with documentation",
557557
)
558558
}),
559559
unstable("enable-per-target-ignores", |o| {
560-
o.optflag(
560+
o.optflagmulti(
561561
"",
562562
"enable-per-target-ignores",
563563
"parse ignore-foo for ignoring doctests on a per-target basis",
@@ -582,9 +582,9 @@ fn opts() -> Vec<RustcOptGroup> {
582582
unstable("test-builder", |o| {
583583
o.optopt("", "test-builder", "The rustc-like binary to use as the test builder", "PATH")
584584
}),
585-
unstable("check", |o| o.optflag("", "check", "Run rustdoc checks")),
585+
unstable("check", |o| o.optflagmulti("", "check", "Run rustdoc checks")),
586586
unstable("generate-redirect-map", |o| {
587-
o.optflag(
587+
o.optflagmulti(
588588
"",
589589
"generate-redirect-map",
590590
"Generate JSON file at the top level instead of generating HTML redirection files",
@@ -598,9 +598,11 @@ fn opts() -> Vec<RustcOptGroup> {
598598
"[unversioned-shared-resources,toolchain-shared-resources,invocation-specific]",
599599
)
600600
}),
601-
unstable("no-run", |o| o.optflag("", "no-run", "Compile doctests without running them")),
601+
unstable("no-run", |o| {
602+
o.optflagmulti("", "no-run", "Compile doctests without running them")
603+
}),
602604
unstable("show-type-layout", |o| {
603-
o.optflag("", "show-type-layout", "Include the memory layout of types in the docs")
605+
o.optflagmulti("", "show-type-layout", "Include the memory layout of types in the docs")
604606
}),
605607
]
606608
}

src/test/rustdoc/duplicate-flags.rs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// compile-flags: --document-private-items --document-private-items
2+
3+
// @has duplicate_flags/struct.Private.html
4+
struct Private;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Regression test for #87051, where a double semicolon was erroneously
2+
// suggested after a `?` operator.
3+
4+
fn main() -> Result<(), ()> {
5+
a(|| {
6+
b()
7+
//~^ ERROR: mismatched types [E0308]
8+
//~| NOTE: expected `()`, found `i32`
9+
//~| HELP: consider using a semicolon here
10+
})?;
11+
12+
// Here, we do want to suggest a semicolon:
13+
let x = Ok(42);
14+
if true {
15+
//~^ NOTE: expected this to be `()`
16+
x?
17+
//~^ ERROR: mismatched types [E0308]
18+
//~| NOTE: expected `()`, found integer
19+
//~| HELP: consider using a semicolon here
20+
}
21+
//~^ HELP: consider using a semicolon here
22+
23+
Ok(())
24+
}
25+
26+
fn a<F>(f: F) -> Result<(), ()> where F: FnMut() { Ok(()) }
27+
fn b() -> i32 { 42 }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/try-operator-dont-suggest-semicolon.rs:6:9
3+
|
4+
LL | b()
5+
| ^^^- help: consider using a semicolon here: `;`
6+
| |
7+
| expected `()`, found `i32`
8+
9+
error[E0308]: mismatched types
10+
--> $DIR/try-operator-dont-suggest-semicolon.rs:16:9
11+
|
12+
LL | / if true {
13+
LL | |
14+
LL | | x?
15+
| | ^^ expected `()`, found integer
16+
LL | |
17+
LL | |
18+
LL | |
19+
LL | | }
20+
| |_____- expected this to be `()`
21+
|
22+
help: consider using a semicolon here
23+
|
24+
LL | x?;
25+
| ^
26+
help: consider using a semicolon here
27+
|
28+
LL | };
29+
| ^
30+
31+
error: aborting due to 2 previous errors
32+
33+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)