From 6ed16e23b1bd6a294508e2597914977b767c568c Mon Sep 17 00:00:00 2001 From: Fabian Wolff Date: Sat, 12 Jun 2021 18:32:25 +0200 Subject: [PATCH 1/9] Report an error if resolution of closure call functions failed --- compiler/rustc_typeck/src/check/callee.rs | 11 +++++++++-- src/test/ui/lang-items/issue-86238.rs | 16 ++++++++++++++++ src/test/ui/lang-items/issue-86238.stderr | 10 ++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 src/test/ui/lang-items/issue-86238.rs create mode 100644 src/test/ui/lang-items/issue-86238.stderr diff --git a/compiler/rustc_typeck/src/check/callee.rs b/compiler/rustc_typeck/src/check/callee.rs index cb8f336721ad6..9362daa3c889e 100644 --- a/compiler/rustc_typeck/src/check/callee.rs +++ b/compiler/rustc_typeck/src/check/callee.rs @@ -588,10 +588,17 @@ impl<'a, 'tcx> DeferredCallResolution<'tcx> { fcx.write_method_call(self.call_expr.hir_id, method_callee); } None => { - span_bug!( + // This can happen if `#![no_core]` is used and the `fn/fn_mut/fn_once` + // lang items are not defined (issue #86238). + let mut err = fcx.inh.tcx.sess.struct_span_err( self.call_expr.span, - "failed to find an overloaded call trait for closure call" + "failed to find an overloaded call trait for closure call", ); + err.help( + "make sure the `fn`/`fn_mut`/`fn_once` lang items are defined \ + and have an associated `call`/`call_mut`/`call_once` function", + ); + err.emit(); } } } diff --git a/src/test/ui/lang-items/issue-86238.rs b/src/test/ui/lang-items/issue-86238.rs new file mode 100644 index 0000000000000..509f94f3834a5 --- /dev/null +++ b/src/test/ui/lang-items/issue-86238.rs @@ -0,0 +1,16 @@ +// Regression test for the ICE described in issue #86238. + +#![feature(lang_items)] +#![feature(no_core)] + +#![no_core] +fn main() { + let one = || {}; + one() + //~^ ERROR: failed to find an overloaded call trait for closure call + //~| HELP: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined +} +#[lang = "sized"] +trait Sized {} +#[lang = "copy"] +trait Copy {} diff --git a/src/test/ui/lang-items/issue-86238.stderr b/src/test/ui/lang-items/issue-86238.stderr new file mode 100644 index 0000000000000..070f2762634bb --- /dev/null +++ b/src/test/ui/lang-items/issue-86238.stderr @@ -0,0 +1,10 @@ +error: failed to find an overloaded call trait for closure call + --> $DIR/issue-86238.rs:9:5 + | +LL | one() + | ^^^^^ + | + = help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have an associated `call`/`call_mut`/`call_once` function + +error: aborting due to previous error + From dab25ab56cd7a8132281621ecdf7aee8dfdabd15 Mon Sep 17 00:00:00 2001 From: Fabian Wolff Date: Thu, 1 Jul 2021 13:26:17 +0200 Subject: [PATCH 2/9] Reword error message slightly --- compiler/rustc_typeck/src/check/callee.rs | 2 +- src/test/ui/lang-items/issue-86238.stderr | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_typeck/src/check/callee.rs b/compiler/rustc_typeck/src/check/callee.rs index 9362daa3c889e..f55093d82f883 100644 --- a/compiler/rustc_typeck/src/check/callee.rs +++ b/compiler/rustc_typeck/src/check/callee.rs @@ -596,7 +596,7 @@ impl<'a, 'tcx> DeferredCallResolution<'tcx> { ); err.help( "make sure the `fn`/`fn_mut`/`fn_once` lang items are defined \ - and have an associated `call`/`call_mut`/`call_once` function", + and have associated `call`/`call_mut`/`call_once` functions", ); err.emit(); } diff --git a/src/test/ui/lang-items/issue-86238.stderr b/src/test/ui/lang-items/issue-86238.stderr index 070f2762634bb..767e6de2263b9 100644 --- a/src/test/ui/lang-items/issue-86238.stderr +++ b/src/test/ui/lang-items/issue-86238.stderr @@ -4,7 +4,7 @@ error: failed to find an overloaded call trait for closure call LL | one() | ^^^^^ | - = help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have an associated `call`/`call_mut`/`call_once` function + = help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have associated `call`/`call_mut`/`call_once` functions error: aborting due to previous error From 5eb83f4ec3761b69e839f364e127b8c307f6e196 Mon Sep 17 00:00:00 2001 From: Fabian Wolff Date: Fri, 2 Jul 2021 18:29:49 +0200 Subject: [PATCH 3/9] Improve error reporting for modifications behind `&` references --- .../diagnostics/mutability_errors.rs | 24 +++++++++++++++---- ...k-assign-to-andmut-in-aliasable-loc.stderr | 4 ++-- ...orrow-mut-base-ptr-in-aliasable-loc.stderr | 2 +- .../ui/borrowck/borrowck-issue-14498.stderr | 2 +- ...issue-69789-iterator-mut-suggestion.stderr | 2 +- .../issue-83309-ice-immut-in-for-loop.rs | 2 +- .../issue-83309-ice-immut-in-for-loop.stderr | 2 +- src/test/ui/borrowck/issue-85765.rs | 7 ++++++ src/test/ui/borrowck/issue-85765.stderr | 14 +++++++++-- src/test/ui/borrowck/mutability-errors.stderr | 8 +++---- src/test/ui/did_you_mean/issue-39544.rs | 2 +- src/test/ui/did_you_mean/issue-39544.stderr | 2 +- src/test/ui/error-codes/E0389.rs | 2 +- src/test/ui/error-codes/E0389.stderr | 2 +- src/test/ui/issues/issue-51244.rs | 2 +- src/test/ui/issues/issue-51244.stderr | 2 +- src/test/ui/issues/issue-51515.rs | 4 ++-- src/test/ui/issues/issue-51515.stderr | 4 ++-- src/test/ui/mut/mutable-class-fields-2.stderr | 2 +- src/test/ui/nll/issue-47388.stderr | 2 +- src/test/ui/nll/issue-51244.rs | 2 +- src/test/ui/nll/issue-51244.stderr | 2 +- src/test/ui/nll/issue-57989.rs | 2 +- src/test/ui/nll/issue-57989.stderr | 2 +- .../borrowck-move-ref-pattern.rs | 4 ++-- .../borrowck-move-ref-pattern.stderr | 4 ++-- .../ui/rfc-2005-default-binding-mode/enum.rs | 6 ++--- .../rfc-2005-default-binding-mode/enum.stderr | 6 ++--- .../explicit-mut.rs | 6 ++--- .../explicit-mut.stderr | 6 ++--- src/test/ui/suggestions/issue-68049-1.stderr | 2 +- src/test/ui/suggestions/issue-68049-2.stderr | 4 ++-- .../suggest-mut-method-for-loop.stderr | 2 +- .../ui/suggestions/suggest-ref-mut.stderr | 8 +++---- 34 files changed, 90 insertions(+), 57 deletions(-) diff --git a/compiler/rustc_mir/src/borrow_check/diagnostics/mutability_errors.rs b/compiler/rustc_mir/src/borrow_check/diagnostics/mutability_errors.rs index bf5f2c0eec23e..671d947d1b132 100644 --- a/compiler/rustc_mir/src/borrow_check/diagnostics/mutability_errors.rs +++ b/compiler/rustc_mir/src/borrow_check/diagnostics/mutability_errors.rs @@ -147,7 +147,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { if let Some(desc) = access_place_desc { item_msg = format!("`{}`", desc); reason = match error_access { - AccessKind::Mutate => format!(" which is behind {}", pointer_type), + AccessKind::Mutate => format!(", which is behind {}", pointer_type), AccessKind::MutableBorrow => { format!(", as it is behind {}", pointer_type) } @@ -897,16 +897,32 @@ fn suggest_ampmut<'tcx>( ) -> (Span, String) { if let Some(assignment_rhs_span) = opt_assignment_rhs_span { if let Ok(src) = tcx.sess.source_map().span_to_snippet(assignment_rhs_span) { + let is_mutbl = |ty: &str| -> bool { + if ty.starts_with("mut") { + let rest = &ty[3..]; + match rest.chars().next() { + // e.g. `&mut x` + Some(c) if c.is_whitespace() => true, + // e.g. `&mut(x)` + Some('(') => true, + // e.g. `&mutablevar` + _ => false, + } + } else { + false + } + }; if let (true, Some(ws_pos)) = (src.starts_with("&'"), src.find(|c: char| -> bool { c.is_whitespace() })) { let lt_name = &src[1..ws_pos]; - let ty = &src[ws_pos..]; - if !ty.trim_start().starts_with("mut") { + let ty = src[ws_pos..].trim_start(); + if !is_mutbl(ty) { return (assignment_rhs_span, format!("&{} mut {}", lt_name, ty)); } } else if let Some(stripped) = src.strip_prefix('&') { - if !stripped.trim_start().starts_with("mut") { + let stripped = stripped.trim_start(); + if !is_mutbl(stripped) { return (assignment_rhs_span, format!("&mut {}", stripped)); } } diff --git a/src/test/ui/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.stderr b/src/test/ui/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.stderr index d8ccf36852a51..0475df447445d 100644 --- a/src/test/ui/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.stderr +++ b/src/test/ui/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.stderr @@ -1,4 +1,4 @@ -error[E0594]: cannot assign to `*s.pointer` which is behind a `&` reference +error[E0594]: cannot assign to `*s.pointer`, which is behind a `&` reference --> $DIR/borrowck-assign-to-andmut-in-aliasable-loc.rs:9:5 | LL | fn a(s: &S) { @@ -6,7 +6,7 @@ LL | fn a(s: &S) { LL | *s.pointer += 1; | ^^^^^^^^^^^^^^^ `s` is a `&` reference, so the data it refers to cannot be written -error[E0594]: cannot assign to `*s.pointer` which is behind a `&` reference +error[E0594]: cannot assign to `*s.pointer`, which is behind a `&` reference --> $DIR/borrowck-assign-to-andmut-in-aliasable-loc.rs:17:5 | LL | fn c(s: & &mut S) { diff --git a/src/test/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.stderr b/src/test/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.stderr index 1fdeb812bf8bb..0866f54b9fab6 100644 --- a/src/test/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.stderr +++ b/src/test/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.stderr @@ -1,4 +1,4 @@ -error[E0594]: cannot assign to `**t1` which is behind a `&` reference +error[E0594]: cannot assign to `**t1`, which is behind a `&` reference --> $DIR/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs:9:5 | LL | let t1 = t0; diff --git a/src/test/ui/borrowck/borrowck-issue-14498.stderr b/src/test/ui/borrowck/borrowck-issue-14498.stderr index ae9167757a0ae..4c0e46d453142 100644 --- a/src/test/ui/borrowck/borrowck-issue-14498.stderr +++ b/src/test/ui/borrowck/borrowck-issue-14498.stderr @@ -1,4 +1,4 @@ -error[E0594]: cannot assign to `***p` which is behind a `&` reference +error[E0594]: cannot assign to `***p`, which is behind a `&` reference --> $DIR/borrowck-issue-14498.rs:16:5 | LL | let p = &y; diff --git a/src/test/ui/borrowck/issue-69789-iterator-mut-suggestion.stderr b/src/test/ui/borrowck/issue-69789-iterator-mut-suggestion.stderr index d2865ffd196a5..369a8c61d2c99 100644 --- a/src/test/ui/borrowck/issue-69789-iterator-mut-suggestion.stderr +++ b/src/test/ui/borrowck/issue-69789-iterator-mut-suggestion.stderr @@ -1,4 +1,4 @@ -error[E0594]: cannot assign to `*item` which is behind a `&` reference +error[E0594]: cannot assign to `*item`, which is behind a `&` reference --> $DIR/issue-69789-iterator-mut-suggestion.rs:7:9 | LL | for item in &mut std::iter::empty::<&'static ()>() { diff --git a/src/test/ui/borrowck/issue-83309-ice-immut-in-for-loop.rs b/src/test/ui/borrowck/issue-83309-ice-immut-in-for-loop.rs index 6da88bed2c6ba..d301e7b3524b8 100644 --- a/src/test/ui/borrowck/issue-83309-ice-immut-in-for-loop.rs +++ b/src/test/ui/borrowck/issue-83309-ice-immut-in-for-loop.rs @@ -9,7 +9,7 @@ fn main() { for v in Query.iter_mut() { //~^ NOTE this iterator yields `&` references *v -= 1; - //~^ ERROR cannot assign to `*v` which is behind a `&` reference + //~^ ERROR cannot assign to `*v`, which is behind a `&` reference //~| NOTE `v` is a `&` reference, so the data it refers to cannot be written } } diff --git a/src/test/ui/borrowck/issue-83309-ice-immut-in-for-loop.stderr b/src/test/ui/borrowck/issue-83309-ice-immut-in-for-loop.stderr index 143b74c39ba86..26ce007dd346a 100644 --- a/src/test/ui/borrowck/issue-83309-ice-immut-in-for-loop.stderr +++ b/src/test/ui/borrowck/issue-83309-ice-immut-in-for-loop.stderr @@ -1,4 +1,4 @@ -error[E0594]: cannot assign to `*v` which is behind a `&` reference +error[E0594]: cannot assign to `*v`, which is behind a `&` reference --> $DIR/issue-83309-ice-immut-in-for-loop.rs:11:9 | LL | for v in Query.iter_mut() { diff --git a/src/test/ui/borrowck/issue-85765.rs b/src/test/ui/borrowck/issue-85765.rs index b82e0298158aa..1a5f7434fe2bb 100644 --- a/src/test/ui/borrowck/issue-85765.rs +++ b/src/test/ui/borrowck/issue-85765.rs @@ -5,4 +5,11 @@ fn main() { rofl.push(Vec::new()); //~^ ERROR cannot borrow `*rofl` as mutable, as it is behind a `&` reference //~| NOTE `rofl` is a `&` reference, so the data it refers to cannot be borrowed as mutable + + let mut mutvar = 42; + let r = &mutvar; + //~^ HELP consider changing this to be a mutable reference + *r = 0; + //~^ ERROR cannot assign to `*r`, which is behind a `&` reference + //~| NOTE `r` is a `&` reference, so the data it refers to cannot be written } diff --git a/src/test/ui/borrowck/issue-85765.stderr b/src/test/ui/borrowck/issue-85765.stderr index 863c2e8eccc8c..4da4c8f594666 100644 --- a/src/test/ui/borrowck/issue-85765.stderr +++ b/src/test/ui/borrowck/issue-85765.stderr @@ -7,6 +7,16 @@ LL | LL | rofl.push(Vec::new()); | ^^^^ `rofl` is a `&` reference, so the data it refers to cannot be borrowed as mutable -error: aborting due to previous error +error[E0594]: cannot assign to `*r`, which is behind a `&` reference + --> $DIR/issue-85765.rs:12:5 + | +LL | let r = &mutvar; + | ------- help: consider changing this to be a mutable reference: `&mut mutvar` +LL | +LL | *r = 0; + | ^^^^^^ `r` is a `&` reference, so the data it refers to cannot be written + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0596`. +Some errors have detailed explanations: E0594, E0596. +For more information about an error, try `rustc --explain E0594`. diff --git a/src/test/ui/borrowck/mutability-errors.stderr b/src/test/ui/borrowck/mutability-errors.stderr index 5361ebe3916d7..edab22569b34f 100644 --- a/src/test/ui/borrowck/mutability-errors.stderr +++ b/src/test/ui/borrowck/mutability-errors.stderr @@ -1,4 +1,4 @@ -error[E0594]: cannot assign to `*x` which is behind a `&` reference +error[E0594]: cannot assign to `*x`, which is behind a `&` reference --> $DIR/mutability-errors.rs:9:5 | LL | fn named_ref(x: &(i32,)) { @@ -6,7 +6,7 @@ LL | fn named_ref(x: &(i32,)) { LL | *x = (1,); | ^^^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written -error[E0594]: cannot assign to `x.0` which is behind a `&` reference +error[E0594]: cannot assign to `x.0`, which is behind a `&` reference --> $DIR/mutability-errors.rs:10:5 | LL | fn named_ref(x: &(i32,)) { @@ -57,7 +57,7 @@ error[E0596]: cannot borrow data in a `&` reference as mutable LL | &mut f().0; | ^^^^^^^^^^ cannot borrow as mutable -error[E0594]: cannot assign to `*x` which is behind a `*const` pointer +error[E0594]: cannot assign to `*x`, which is behind a `*const` pointer --> $DIR/mutability-errors.rs:23:5 | LL | unsafe fn named_ptr(x: *const (i32,)) { @@ -65,7 +65,7 @@ LL | unsafe fn named_ptr(x: *const (i32,)) { LL | *x = (1,); | ^^^^^^^^^ `x` is a `*const` pointer, so the data it refers to cannot be written -error[E0594]: cannot assign to `x.0` which is behind a `*const` pointer +error[E0594]: cannot assign to `x.0`, which is behind a `*const` pointer --> $DIR/mutability-errors.rs:24:5 | LL | unsafe fn named_ptr(x: *const (i32,)) { diff --git a/src/test/ui/did_you_mean/issue-39544.rs b/src/test/ui/did_you_mean/issue-39544.rs index 3c86f29a89c30..a19d3f7047cea 100644 --- a/src/test/ui/did_you_mean/issue-39544.rs +++ b/src/test/ui/did_you_mean/issue-39544.rs @@ -46,5 +46,5 @@ pub fn with_tuple() { let mut y = 0; let x = (&y,); *x.0 = 1; - //~^ ERROR cannot assign to `*x.0` which is behind a `&` reference + //~^ ERROR cannot assign to `*x.0`, which is behind a `&` reference } diff --git a/src/test/ui/did_you_mean/issue-39544.stderr b/src/test/ui/did_you_mean/issue-39544.stderr index ce0d697238c6b..68180eaee036c 100644 --- a/src/test/ui/did_you_mean/issue-39544.stderr +++ b/src/test/ui/did_you_mean/issue-39544.stderr @@ -90,7 +90,7 @@ LL | let _ = &mut z.x; LL | let _ = &mut w.x; | ^^^^^^^^ `w` is a `&` reference, so the data it refers to cannot be borrowed as mutable -error[E0594]: cannot assign to `*x.0` which is behind a `&` reference +error[E0594]: cannot assign to `*x.0`, which is behind a `&` reference --> $DIR/issue-39544.rs:48:5 | LL | *x.0 = 1; diff --git a/src/test/ui/error-codes/E0389.rs b/src/test/ui/error-codes/E0389.rs index 9dab2c3092434..41172b362f495 100644 --- a/src/test/ui/error-codes/E0389.rs +++ b/src/test/ui/error-codes/E0389.rs @@ -5,6 +5,6 @@ struct FancyNum { fn main() { let mut fancy = FancyNum{ num: 5 }; let fancy_ref = &(&mut fancy); - fancy_ref.num = 6; //~ ERROR cannot assign to `fancy_ref.num` which is behind a `&` reference + fancy_ref.num = 6; //~ ERROR cannot assign to `fancy_ref.num`, which is behind a `&` reference println!("{}", fancy_ref.num); } diff --git a/src/test/ui/error-codes/E0389.stderr b/src/test/ui/error-codes/E0389.stderr index c47750b6f4e69..3d615bd932f43 100644 --- a/src/test/ui/error-codes/E0389.stderr +++ b/src/test/ui/error-codes/E0389.stderr @@ -1,4 +1,4 @@ -error[E0594]: cannot assign to `fancy_ref.num` which is behind a `&` reference +error[E0594]: cannot assign to `fancy_ref.num`, which is behind a `&` reference --> $DIR/E0389.rs:8:5 | LL | let fancy_ref = &(&mut fancy); diff --git a/src/test/ui/issues/issue-51244.rs b/src/test/ui/issues/issue-51244.rs index 509060e1ad81b..d634b8bf80079 100644 --- a/src/test/ui/issues/issue-51244.rs +++ b/src/test/ui/issues/issue-51244.rs @@ -1,4 +1,4 @@ fn main() { let ref my_ref @ _ = 0; - *my_ref = 0; //~ ERROR cannot assign to `*my_ref` which is behind a `&` reference [E0594] + *my_ref = 0; //~ ERROR cannot assign to `*my_ref`, which is behind a `&` reference [E0594] } diff --git a/src/test/ui/issues/issue-51244.stderr b/src/test/ui/issues/issue-51244.stderr index c91083955b820..19f0223a357a5 100644 --- a/src/test/ui/issues/issue-51244.stderr +++ b/src/test/ui/issues/issue-51244.stderr @@ -1,4 +1,4 @@ -error[E0594]: cannot assign to `*my_ref` which is behind a `&` reference +error[E0594]: cannot assign to `*my_ref`, which is behind a `&` reference --> $DIR/issue-51244.rs:3:5 | LL | let ref my_ref @ _ = 0; diff --git a/src/test/ui/issues/issue-51515.rs b/src/test/ui/issues/issue-51515.rs index 8eab7b2fa3ae9..54fd176de75f0 100644 --- a/src/test/ui/issues/issue-51515.rs +++ b/src/test/ui/issues/issue-51515.rs @@ -3,10 +3,10 @@ fn main() { //~^ HELP consider changing this to be a mutable reference //~| SUGGESTION &mut 16 *foo = 32; - //~^ ERROR cannot assign to `*foo` which is behind a `&` reference + //~^ ERROR cannot assign to `*foo`, which is behind a `&` reference let bar = foo; //~^ HELP consider changing this to be a mutable reference //~| SUGGESTION &mut i32 *bar = 64; - //~^ ERROR cannot assign to `*bar` which is behind a `&` reference + //~^ ERROR cannot assign to `*bar`, which is behind a `&` reference } diff --git a/src/test/ui/issues/issue-51515.stderr b/src/test/ui/issues/issue-51515.stderr index 3c208935f31f6..62bb462faa208 100644 --- a/src/test/ui/issues/issue-51515.stderr +++ b/src/test/ui/issues/issue-51515.stderr @@ -1,4 +1,4 @@ -error[E0594]: cannot assign to `*foo` which is behind a `&` reference +error[E0594]: cannot assign to `*foo`, which is behind a `&` reference --> $DIR/issue-51515.rs:5:5 | LL | let foo = &16; @@ -7,7 +7,7 @@ LL | let foo = &16; LL | *foo = 32; | ^^^^^^^^^ `foo` is a `&` reference, so the data it refers to cannot be written -error[E0594]: cannot assign to `*bar` which is behind a `&` reference +error[E0594]: cannot assign to `*bar`, which is behind a `&` reference --> $DIR/issue-51515.rs:10:5 | LL | let bar = foo; diff --git a/src/test/ui/mut/mutable-class-fields-2.stderr b/src/test/ui/mut/mutable-class-fields-2.stderr index 15323ce9a9755..5a4e31947f2b2 100644 --- a/src/test/ui/mut/mutable-class-fields-2.stderr +++ b/src/test/ui/mut/mutable-class-fields-2.stderr @@ -1,4 +1,4 @@ -error[E0594]: cannot assign to `self.how_hungry` which is behind a `&` reference +error[E0594]: cannot assign to `self.how_hungry`, which is behind a `&` reference --> $DIR/mutable-class-fields-2.rs:9:5 | LL | pub fn eat(&self) { diff --git a/src/test/ui/nll/issue-47388.stderr b/src/test/ui/nll/issue-47388.stderr index 8d48b00f8d1f1..a4ee778175306 100644 --- a/src/test/ui/nll/issue-47388.stderr +++ b/src/test/ui/nll/issue-47388.stderr @@ -1,4 +1,4 @@ -error[E0594]: cannot assign to `fancy_ref.num` which is behind a `&` reference +error[E0594]: cannot assign to `fancy_ref.num`, which is behind a `&` reference --> $DIR/issue-47388.rs:8:5 | LL | let fancy_ref = &(&mut fancy); diff --git a/src/test/ui/nll/issue-51244.rs b/src/test/ui/nll/issue-51244.rs index 743415d58afad..c4cbee6754c04 100644 --- a/src/test/ui/nll/issue-51244.rs +++ b/src/test/ui/nll/issue-51244.rs @@ -1,5 +1,5 @@ fn main() { let ref my_ref @ _ = 0; *my_ref = 0; - //~^ ERROR cannot assign to `*my_ref` which is behind a `&` reference [E0594] + //~^ ERROR cannot assign to `*my_ref`, which is behind a `&` reference [E0594] } diff --git a/src/test/ui/nll/issue-51244.stderr b/src/test/ui/nll/issue-51244.stderr index c91083955b820..19f0223a357a5 100644 --- a/src/test/ui/nll/issue-51244.stderr +++ b/src/test/ui/nll/issue-51244.stderr @@ -1,4 +1,4 @@ -error[E0594]: cannot assign to `*my_ref` which is behind a `&` reference +error[E0594]: cannot assign to `*my_ref`, which is behind a `&` reference --> $DIR/issue-51244.rs:3:5 | LL | let ref my_ref @ _ = 0; diff --git a/src/test/ui/nll/issue-57989.rs b/src/test/ui/nll/issue-57989.rs index c410f0b0bfb4d..8f3dec454d5ff 100644 --- a/src/test/ui/nll/issue-57989.rs +++ b/src/test/ui/nll/issue-57989.rs @@ -2,7 +2,7 @@ fn f(x: &i32) { let g = &x; - *x = 0; //~ ERROR cannot assign to `*x` which is behind a `&` reference + *x = 0; //~ ERROR cannot assign to `*x`, which is behind a `&` reference //~| ERROR cannot assign to `*x` because it is borrowed g; } diff --git a/src/test/ui/nll/issue-57989.stderr b/src/test/ui/nll/issue-57989.stderr index 4c416105035d7..e85e63e52ecc3 100644 --- a/src/test/ui/nll/issue-57989.stderr +++ b/src/test/ui/nll/issue-57989.stderr @@ -1,4 +1,4 @@ -error[E0594]: cannot assign to `*x` which is behind a `&` reference +error[E0594]: cannot assign to `*x`, which is behind a `&` reference --> $DIR/issue-57989.rs:5:5 | LL | fn f(x: &i32) { diff --git a/src/test/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.rs b/src/test/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.rs index 9c320edc4dc0e..a6144c9497d04 100644 --- a/src/test/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.rs +++ b/src/test/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.rs @@ -23,8 +23,8 @@ fn tuple() { _x1 = U; //~ ERROR cannot assign twice to immutable variable let _x0_hold = &mut tup.0; //~ ERROR cannot borrow `tup.0` as mutable because it is also let (ref mut _x0_hold, ..) = tup; //~ ERROR cannot borrow `tup.0` as mutable because it is also - *_x0 = U; //~ ERROR cannot assign to `*_x0` which is behind a `&` reference - *_x2 = U; //~ ERROR cannot assign to `*_x2` which is behind a `&` reference + *_x0 = U; //~ ERROR cannot assign to `*_x0`, which is behind a `&` reference + *_x2 = U; //~ ERROR cannot assign to `*_x2`, which is behind a `&` reference drop(tup.1); //~ ERROR use of moved value: `tup.1` let _x1_hold = &tup.1; //~ ERROR borrow of moved value: `tup.1` let (.., ref mut _x3) = tup; diff --git a/src/test/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.stderr b/src/test/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.stderr index d0726f05cc3be..5beca04d28590 100644 --- a/src/test/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.stderr +++ b/src/test/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.stderr @@ -101,7 +101,7 @@ LL | let (ref mut _x0_hold, ..) = tup; LL | *_x0 = U; | -------- immutable borrow later used here -error[E0594]: cannot assign to `*_x0` which is behind a `&` reference +error[E0594]: cannot assign to `*_x0`, which is behind a `&` reference --> $DIR/borrowck-move-ref-pattern.rs:26:5 | LL | let (ref _x0, _x1, ref _x2, ..) = tup; @@ -110,7 +110,7 @@ LL | let (ref _x0, _x1, ref _x2, ..) = tup; LL | *_x0 = U; | ^^^^^^^^ `_x0` is a `&` reference, so the data it refers to cannot be written -error[E0594]: cannot assign to `*_x2` which is behind a `&` reference +error[E0594]: cannot assign to `*_x2`, which is behind a `&` reference --> $DIR/borrowck-move-ref-pattern.rs:27:5 | LL | let (ref _x0, _x1, ref _x2, ..) = tup; diff --git a/src/test/ui/rfc-2005-default-binding-mode/enum.rs b/src/test/ui/rfc-2005-default-binding-mode/enum.rs index af82d36f87eb0..4e57769d6e24c 100644 --- a/src/test/ui/rfc-2005-default-binding-mode/enum.rs +++ b/src/test/ui/rfc-2005-default-binding-mode/enum.rs @@ -6,17 +6,17 @@ use Wrapper::Wrap; pub fn main() { let Wrap(x) = &Wrap(3); - *x += 1; //~ ERROR cannot assign to `*x` which is behind a `&` reference + *x += 1; //~ ERROR cannot assign to `*x`, which is behind a `&` reference if let Some(x) = &Some(3) { - *x += 1; //~ ERROR cannot assign to `*x` which is behind a `&` reference + *x += 1; //~ ERROR cannot assign to `*x`, which is behind a `&` reference } else { panic!(); } while let Some(x) = &Some(3) { - *x += 1; //~ ERROR cannot assign to `*x` which is behind a `&` reference + *x += 1; //~ ERROR cannot assign to `*x`, which is behind a `&` reference break; } } diff --git a/src/test/ui/rfc-2005-default-binding-mode/enum.stderr b/src/test/ui/rfc-2005-default-binding-mode/enum.stderr index d6a89006bc0fb..21e3d3d273d7f 100644 --- a/src/test/ui/rfc-2005-default-binding-mode/enum.stderr +++ b/src/test/ui/rfc-2005-default-binding-mode/enum.stderr @@ -1,16 +1,16 @@ -error[E0594]: cannot assign to `*x` which is behind a `&` reference +error[E0594]: cannot assign to `*x`, which is behind a `&` reference --> $DIR/enum.rs:9:5 | LL | *x += 1; | ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written -error[E0594]: cannot assign to `*x` which is behind a `&` reference +error[E0594]: cannot assign to `*x`, which is behind a `&` reference --> $DIR/enum.rs:13:9 | LL | *x += 1; | ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written -error[E0594]: cannot assign to `*x` which is behind a `&` reference +error[E0594]: cannot assign to `*x`, which is behind a `&` reference --> $DIR/enum.rs:19:9 | LL | *x += 1; diff --git a/src/test/ui/rfc-2005-default-binding-mode/explicit-mut.rs b/src/test/ui/rfc-2005-default-binding-mode/explicit-mut.rs index 212fd94ded3e7..b8fde2208acd5 100644 --- a/src/test/ui/rfc-2005-default-binding-mode/explicit-mut.rs +++ b/src/test/ui/rfc-2005-default-binding-mode/explicit-mut.rs @@ -4,7 +4,7 @@ fn main() { match &&Some(5i32) { Some(n) => { - *n += 1; //~ ERROR cannot assign to `*n` which is behind a `&` reference + *n += 1; //~ ERROR cannot assign to `*n`, which is behind a `&` reference let _ = n; } None => {}, @@ -12,7 +12,7 @@ fn main() { match &mut &Some(5i32) { Some(n) => { - *n += 1; //~ ERROR cannot assign to `*n` which is behind a `&` reference + *n += 1; //~ ERROR cannot assign to `*n`, which is behind a `&` reference let _ = n; } None => {}, @@ -20,7 +20,7 @@ fn main() { match &&mut Some(5i32) { Some(n) => { - *n += 1; //~ ERROR cannot assign to `*n` which is behind a `&` reference + *n += 1; //~ ERROR cannot assign to `*n`, which is behind a `&` reference let _ = n; } None => {}, diff --git a/src/test/ui/rfc-2005-default-binding-mode/explicit-mut.stderr b/src/test/ui/rfc-2005-default-binding-mode/explicit-mut.stderr index a6f2f3ec30968..c3f64f65a412e 100644 --- a/src/test/ui/rfc-2005-default-binding-mode/explicit-mut.stderr +++ b/src/test/ui/rfc-2005-default-binding-mode/explicit-mut.stderr @@ -1,16 +1,16 @@ -error[E0594]: cannot assign to `*n` which is behind a `&` reference +error[E0594]: cannot assign to `*n`, which is behind a `&` reference --> $DIR/explicit-mut.rs:7:13 | LL | *n += 1; | ^^^^^^^ `n` is a `&` reference, so the data it refers to cannot be written -error[E0594]: cannot assign to `*n` which is behind a `&` reference +error[E0594]: cannot assign to `*n`, which is behind a `&` reference --> $DIR/explicit-mut.rs:15:13 | LL | *n += 1; | ^^^^^^^ `n` is a `&` reference, so the data it refers to cannot be written -error[E0594]: cannot assign to `*n` which is behind a `&` reference +error[E0594]: cannot assign to `*n`, which is behind a `&` reference --> $DIR/explicit-mut.rs:23:13 | LL | *n += 1; diff --git a/src/test/ui/suggestions/issue-68049-1.stderr b/src/test/ui/suggestions/issue-68049-1.stderr index 32367d2d0cf21..7f931f0cdc9e8 100644 --- a/src/test/ui/suggestions/issue-68049-1.stderr +++ b/src/test/ui/suggestions/issue-68049-1.stderr @@ -1,4 +1,4 @@ -error[E0594]: cannot assign to `self.0` which is behind a `&` reference +error[E0594]: cannot assign to `self.0`, which is behind a `&` reference --> $DIR/issue-68049-1.rs:7:9 | LL | self.0 += 1; diff --git a/src/test/ui/suggestions/issue-68049-2.stderr b/src/test/ui/suggestions/issue-68049-2.stderr index f10a83c68a81b..2f31193e4a4a2 100644 --- a/src/test/ui/suggestions/issue-68049-2.stderr +++ b/src/test/ui/suggestions/issue-68049-2.stderr @@ -1,4 +1,4 @@ -error[E0594]: cannot assign to `*input` which is behind a `&` reference +error[E0594]: cannot assign to `*input`, which is behind a `&` reference --> $DIR/issue-68049-2.rs:9:7 | LL | fn example(&self, input: &i32); // should suggest here @@ -7,7 +7,7 @@ LL | fn example(&self, input: &i32); // should suggest here LL | *input = self.0; | ^^^^^^^^^^^^^^^ `input` is a `&` reference, so the data it refers to cannot be written -error[E0594]: cannot assign to `self.0` which is behind a `&` reference +error[E0594]: cannot assign to `self.0`, which is behind a `&` reference --> $DIR/issue-68049-2.rs:17:5 | LL | fn example(&self, input: &i32); // should suggest here diff --git a/src/test/ui/suggestions/suggest-mut-method-for-loop.stderr b/src/test/ui/suggestions/suggest-mut-method-for-loop.stderr index 6ab08197441c3..3eb9e1031d706 100644 --- a/src/test/ui/suggestions/suggest-mut-method-for-loop.stderr +++ b/src/test/ui/suggestions/suggest-mut-method-for-loop.stderr @@ -1,4 +1,4 @@ -error[E0594]: cannot assign to `t.v` which is behind a `&` reference +error[E0594]: cannot assign to `t.v`, which is behind a `&` reference --> $DIR/suggest-mut-method-for-loop.rs:14:9 | LL | for mut t in buzz.values() { diff --git a/src/test/ui/suggestions/suggest-ref-mut.stderr b/src/test/ui/suggestions/suggest-ref-mut.stderr index b4981279a238b..9fd2658ec702d 100644 --- a/src/test/ui/suggestions/suggest-ref-mut.stderr +++ b/src/test/ui/suggestions/suggest-ref-mut.stderr @@ -1,4 +1,4 @@ -error[E0594]: cannot assign to `self.0` which is behind a `&` reference +error[E0594]: cannot assign to `self.0`, which is behind a `&` reference --> $DIR/suggest-ref-mut.rs:7:9 | LL | fn zap(&self) { @@ -7,7 +7,7 @@ LL | fn zap(&self) { LL | self.0 = 32; | ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be written -error[E0594]: cannot assign to `*foo` which is behind a `&` reference +error[E0594]: cannot assign to `*foo`, which is behind a `&` reference --> $DIR/suggest-ref-mut.rs:16:5 | LL | let ref foo = 16; @@ -16,7 +16,7 @@ LL | let ref foo = 16; LL | *foo = 32; | ^^^^^^^^^ `foo` is a `&` reference, so the data it refers to cannot be written -error[E0594]: cannot assign to `*bar` which is behind a `&` reference +error[E0594]: cannot assign to `*bar`, which is behind a `&` reference --> $DIR/suggest-ref-mut.rs:21:9 | LL | if let Some(ref bar) = Some(16) { @@ -25,7 +25,7 @@ LL | if let Some(ref bar) = Some(16) { LL | *bar = 32; | ^^^^^^^^^ `bar` is a `&` reference, so the data it refers to cannot be written -error[E0594]: cannot assign to `*quo` which is behind a `&` reference +error[E0594]: cannot assign to `*quo`, which is behind a `&` reference --> $DIR/suggest-ref-mut.rs:25:22 | LL | ref quo => { *quo = 32; }, From f84f377018b911b765f36cad27672dd5f2e955e8 Mon Sep 17 00:00:00 2001 From: Manuel Drehwald Date: Sat, 10 Jul 2021 19:51:36 +0200 Subject: [PATCH 4/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 5/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 6/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 7/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 8/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 9/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.