From 7da9eeeaa7e3095420c24377d9ad612b8ad321ed Mon Sep 17 00:00:00 2001 From: Christopher Vittal Date: Mon, 25 Mar 2019 04:09:52 -0400 Subject: [PATCH 1/4] Remove BorrowckMode::Compare --- src/librustc/infer/mod.rs | 5 ++--- src/librustc/session/config.rs | 4 ---- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/librustc/infer/mod.rs b/src/librustc/infer/mod.rs index 65bc2b3e945ce..fc209df8516ca 100644 --- a/src/librustc/infer/mod.rs +++ b/src/librustc/infer/mod.rs @@ -97,9 +97,8 @@ impl SuppressRegionErrors { // If we're on Migrate mode, report AST region errors BorrowckMode::Migrate => SuppressRegionErrors { suppressed: false }, - // If we're on MIR or Compare mode, don't report AST region errors as they should - // be reported by NLL - BorrowckMode::Compare | BorrowckMode::Mir => SuppressRegionErrors { suppressed: true }, + // If we're on MIR don't report AST region errors as they should be reported by NLL + BorrowckMode::Mir => SuppressRegionErrors { suppressed: true }, } } } diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 4682eb547836b..4577c06fc68d6 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -462,7 +462,6 @@ pub enum PrintRequest { #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum BorrowckMode { Mir, - Compare, Migrate, } @@ -471,7 +470,6 @@ impl BorrowckMode { /// on the AST borrow check if the MIR-based one errors. pub fn migrate(self) -> bool { match self { - BorrowckMode::Compare => false, BorrowckMode::Mir => false, BorrowckMode::Migrate => true, } @@ -480,7 +478,6 @@ impl BorrowckMode { /// Should we emit the AST-based borrow checker errors? pub fn use_ast(self) -> bool { match self { - BorrowckMode::Compare => true, BorrowckMode::Mir => false, BorrowckMode::Migrate => false, } @@ -2315,7 +2312,6 @@ pub fn build_session_options_and_crate_config( let borrowck_mode = match debugging_opts.borrowck.as_ref().map(|s| &s[..]) { None | Some("migrate") => BorrowckMode::Migrate, Some("mir") => BorrowckMode::Mir, - Some("compare") => BorrowckMode::Compare, Some(m) => early_error(error_format, &format!("unknown borrowck mode `{}`", m)), }; From 2a0426c2695e1a22c37b5ce039fb0febeb8b8f6b Mon Sep 17 00:00:00 2001 From: Christopher Vittal Date: Mon, 25 Mar 2019 09:16:12 -0400 Subject: [PATCH 2/4] Stub display impl for Origin --- src/librustc_mir/util/borrowck_errors.rs | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/src/librustc_mir/util/borrowck_errors.rs b/src/librustc_mir/util/borrowck_errors.rs index bf3cdf4abf797..4563c9f18a3e4 100644 --- a/src/librustc_mir/util/borrowck_errors.rs +++ b/src/librustc_mir/util/borrowck_errors.rs @@ -12,26 +12,10 @@ pub enum Origin { } impl fmt::Display for Origin { - fn fmt(&self, w: &mut fmt::Formatter<'_>) -> fmt::Result { - // If the user passed `-Z borrowck=compare`, then include - // origin info as part of the error report, - // otherwise - let display_origin = ty::tls::with_opt(|opt_tcx| { - if let Some(tcx) = opt_tcx { - tcx.sess.opts.borrowck_mode == BorrowckMode::Compare - } else { - false - } - }); - if display_origin { - match *self { - Origin::Mir => write!(w, " (Mir)"), - Origin::Ast => write!(w, " (Ast)"), - } - } else { - // Print no origin info - Ok(()) - } + fn fmt(&self, _w: &mut fmt::Formatter<'_>) -> fmt::Result { + // FIXME(chrisvittal) remove Origin entirely + // Print no origin info + Ok(()) } } From cfdd6ba77e077d051dba7da064761050d5754b4a Mon Sep 17 00:00:00 2001 From: Christopher Vittal Date: Thu, 2 May 2019 18:34:15 -0400 Subject: [PATCH 3/4] Update tests --- .../run-pass/binding/match-pipe-binding.rs | 1 - src/test/run-pass/issues/issue-16671.rs | 1 - src/test/run-pass/issues/issue-49955.rs | 1 - src/test/run-pass/issues/issue-8860.rs | 1 - src/test/run-pass/numbers-arithmetic/i128.rs | 1 - src/test/run-pass/numbers-arithmetic/u128.rs | 1 - src/test/run-pass/weird-exprs.rs | 1 - .../ui/borrowck/borrowck-closures-two-mut.rs | 7 -- .../borrowck/borrowck-closures-two-mut.stderr | 104 +++--------------- src/test/ui/borrowck/borrowck-reinit.rs | 5 +- src/test/ui/borrowck/borrowck-reinit.stderr | 16 +-- src/test/ui/borrowck/borrowck-storage-dead.rs | 5 +- .../ui/borrowck/borrowck-storage-dead.stderr | 12 +- src/test/ui/borrowck/immutable-arg.rs | 5 +- src/test/ui/borrowck/immutable-arg.stderr | 14 +-- src/test/ui/borrowck/issue-41962.rs | 6 +- src/test/ui/borrowck/issue-41962.stderr | 24 +--- .../generator/yield-while-local-borrowed.rs | 8 +- .../yield-while-local-borrowed.stderr | 32 ++---- src/test/ui/issues/issue-44373-2.rs | 1 - src/test/ui/issues/issue-45697-1.rs | 7 +- src/test/ui/issues/issue-45697-1.stderr | 14 +-- src/test/ui/issues/issue-45697.rs | 7 +- src/test/ui/issues/issue-45697.stderr | 14 +-- src/test/ui/issues/issue-46471-1.rs | 5 +- src/test/ui/issues/issue-46471-1.stderr | 17 +-- src/test/ui/issues/issue-46471.rs | 5 +- src/test/ui/issues/issue-46471.stderr | 20 +--- src/test/ui/issues/issue-46472.rs | 5 +- src/test/ui/issues/issue-46472.stderr | 24 +--- .../liveness-assign-imm-local-notes.rs | 15 +-- .../liveness-assign-imm-local-notes.stderr | 51 ++------- .../ui/moves/moves-based-on-type-tuple.rs | 5 +- .../ui/moves/moves-based-on-type-tuple.stderr | 16 +-- src/test/ui/nll/get_default.rs | 11 +- src/test/ui/nll/get_default.stderr | 58 ++-------- src/test/ui/nll/loan_ends_mid_block_pair.rs | 10 +- .../ui/nll/loan_ends_mid_block_pair.stderr | 60 +--------- src/test/ui/nll/loan_ends_mid_block_vec.rs | 14 +-- .../ui/nll/loan_ends_mid_block_vec.stderr | 88 ++------------- .../ui/nll/region-ends-after-if-condition.rs | 6 +- .../nll/region-ends-after-if-condition.stderr | 32 +----- src/test/ui/nll/return_from_loop.rs | 6 +- src/test/ui/nll/return_from_loop.stderr | 32 +----- 44 files changed, 121 insertions(+), 647 deletions(-) diff --git a/src/test/run-pass/binding/match-pipe-binding.rs b/src/test/run-pass/binding/match-pipe-binding.rs index 40dbd2468950e..7d4a7c708ddd7 100644 --- a/src/test/run-pass/binding/match-pipe-binding.rs +++ b/src/test/run-pass/binding/match-pipe-binding.rs @@ -1,5 +1,4 @@ // run-pass -// compile-flags: -Z borrowck=compare fn test1() { // from issue 6338 diff --git a/src/test/run-pass/issues/issue-16671.rs b/src/test/run-pass/issues/issue-16671.rs index 81a6b669b70ef..eff8e275bb58b 100644 --- a/src/test/run-pass/issues/issue-16671.rs +++ b/src/test/run-pass/issues/issue-16671.rs @@ -1,5 +1,4 @@ // run-pass -//compile-flags: -Z borrowck=compare #![deny(warnings)] diff --git a/src/test/run-pass/issues/issue-49955.rs b/src/test/run-pass/issues/issue-49955.rs index aa114ec0c1383..f2f3ebff2db18 100644 --- a/src/test/run-pass/issues/issue-49955.rs +++ b/src/test/run-pass/issues/issue-49955.rs @@ -1,5 +1,4 @@ // run-pass -// compile-flags: -Z borrowck=compare const ALL_THE_NUMS: [u32; 1] = [ 1 diff --git a/src/test/run-pass/issues/issue-8860.rs b/src/test/run-pass/issues/issue-8860.rs index 7925ef3b5dfab..b89a80c1307cf 100644 --- a/src/test/run-pass/issues/issue-8860.rs +++ b/src/test/run-pass/issues/issue-8860.rs @@ -1,6 +1,5 @@ // run-pass #![allow(dead_code)] -// compile-flags: -Z borrowck=compare static mut DROP: isize = 0; static mut DROP_S: isize = 0; diff --git a/src/test/run-pass/numbers-arithmetic/i128.rs b/src/test/run-pass/numbers-arithmetic/i128.rs index f3b5506ae32a6..ea0ef95e4f1af 100644 --- a/src/test/run-pass/numbers-arithmetic/i128.rs +++ b/src/test/run-pass/numbers-arithmetic/i128.rs @@ -3,7 +3,6 @@ // ignore-emscripten i128 doesn't work -// compile-flags: -Z borrowck=compare #![feature(test)] diff --git a/src/test/run-pass/numbers-arithmetic/u128.rs b/src/test/run-pass/numbers-arithmetic/u128.rs index 56d1f221d844c..9394071632377 100644 --- a/src/test/run-pass/numbers-arithmetic/u128.rs +++ b/src/test/run-pass/numbers-arithmetic/u128.rs @@ -1,7 +1,6 @@ // run-pass // ignore-emscripten u128 not supported -// compile-flags: -Z borrowck=compare #![feature(test)] diff --git a/src/test/run-pass/weird-exprs.rs b/src/test/run-pass/weird-exprs.rs index ae4de92ff7488..6b00293b6e52a 100644 --- a/src/test/run-pass/weird-exprs.rs +++ b/src/test/run-pass/weird-exprs.rs @@ -2,7 +2,6 @@ #![allow(dead_code)] #![allow(unreachable_code)] #![allow(unused_parens)] -// compile-flags: -Z borrowck=compare #![recursion_limit = "256"] diff --git a/src/test/ui/borrowck/borrowck-closures-two-mut.rs b/src/test/ui/borrowck/borrowck-closures-two-mut.rs index 1fced982f8d68..5fe51654f3b79 100644 --- a/src/test/ui/borrowck/borrowck-closures-two-mut.rs +++ b/src/test/ui/borrowck/borrowck-closures-two-mut.rs @@ -2,8 +2,6 @@ // access to the variable, whether that mutable access be used // for direct assignment or for taking mutable ref. Issue #6801. -// compile-flags: -Z borrowck=compare - #![feature(box_syntax)] fn to_fn_mut(f: F) -> F { f } @@ -12,7 +10,6 @@ fn a() { let mut x = 3; let c1 = to_fn_mut(|| x = 4); let c2 = to_fn_mut(|| x = 5); //~ ERROR cannot borrow `x` as mutable more than once - //~| ERROR cannot borrow `x` as mutable more than once drop((c1, c2)); } @@ -24,7 +21,6 @@ fn b() { let mut x = 3; let c1 = to_fn_mut(|| set(&mut x)); let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once - //~| ERROR cannot borrow `x` as mutable more than once drop((c1, c2)); } @@ -32,7 +28,6 @@ fn c() { let mut x = 3; let c1 = to_fn_mut(|| x = 5); let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once - //~| ERROR cannot borrow `x` as mutable more than once drop((c1, c2)); } @@ -41,7 +36,6 @@ fn d() { let c1 = to_fn_mut(|| x = 5); let c2 = to_fn_mut(|| { let _y = to_fn_mut(|| set(&mut x)); }); // (nested closure) //~^ ERROR cannot borrow `x` as mutable more than once - //~| ERROR cannot borrow `x` as mutable more than once drop((c1, c2)); } @@ -54,7 +48,6 @@ fn g() { let c1 = to_fn_mut(|| set(&mut *x.f)); let c2 = to_fn_mut(|| set(&mut *x.f)); //~^ ERROR cannot borrow `x` as mutable more than once - //~| ERROR cannot borrow `x` as mutable more than once drop((c1, c2)); } diff --git a/src/test/ui/borrowck/borrowck-closures-two-mut.stderr b/src/test/ui/borrowck/borrowck-closures-two-mut.stderr index e881201ddfcc0..bffb11640744c 100644 --- a/src/test/ui/borrowck/borrowck-closures-two-mut.stderr +++ b/src/test/ui/borrowck/borrowck-closures-two-mut.stderr @@ -1,80 +1,5 @@ -error[E0499]: cannot borrow `x` as mutable more than once at a time (Ast) - --> $DIR/borrowck-closures-two-mut.rs:14:24 - | -LL | let c1 = to_fn_mut(|| x = 4); - | -- - previous borrow occurs due to use of `x` in closure - | | - | first mutable borrow occurs here -LL | let c2 = to_fn_mut(|| x = 5); - | ^^ - borrow occurs due to use of `x` in closure - | | - | second mutable borrow occurs here -... -LL | } - | - first borrow ends here - -error[E0499]: cannot borrow `x` as mutable more than once at a time (Ast) - --> $DIR/borrowck-closures-two-mut.rs:26:24 - | -LL | let c1 = to_fn_mut(|| set(&mut x)); - | -- - previous borrow occurs due to use of `x` in closure - | | - | first mutable borrow occurs here -LL | let c2 = to_fn_mut(|| set(&mut x)); - | ^^ - borrow occurs due to use of `x` in closure - | | - | second mutable borrow occurs here -... -LL | } - | - first borrow ends here - -error[E0499]: cannot borrow `x` as mutable more than once at a time (Ast) - --> $DIR/borrowck-closures-two-mut.rs:34:24 - | -LL | let c1 = to_fn_mut(|| x = 5); - | -- - previous borrow occurs due to use of `x` in closure - | | - | first mutable borrow occurs here -LL | let c2 = to_fn_mut(|| set(&mut x)); - | ^^ - borrow occurs due to use of `x` in closure - | | - | second mutable borrow occurs here -... -LL | } - | - first borrow ends here - -error[E0499]: cannot borrow `x` as mutable more than once at a time (Ast) - --> $DIR/borrowck-closures-two-mut.rs:42:24 - | -LL | let c1 = to_fn_mut(|| x = 5); - | -- - previous borrow occurs due to use of `x` in closure - | | - | first mutable borrow occurs here -LL | let c2 = to_fn_mut(|| { let _y = to_fn_mut(|| set(&mut x)); }); // (nested closure) - | ^^ - borrow occurs due to use of `x` in closure - | | - | second mutable borrow occurs here -... -LL | } - | - first borrow ends here - -error[E0499]: cannot borrow `x` as mutable more than once at a time (Ast) - --> $DIR/borrowck-closures-two-mut.rs:55:24 - | -LL | let c1 = to_fn_mut(|| set(&mut *x.f)); - | -- - previous borrow occurs due to use of `x` in closure - | | - | first mutable borrow occurs here -LL | let c2 = to_fn_mut(|| set(&mut *x.f)); - | ^^ - borrow occurs due to use of `x` in closure - | | - | second mutable borrow occurs here -... -LL | } - | - first borrow ends here - -error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir) - --> $DIR/borrowck-closures-two-mut.rs:14:24 +error[E0499]: cannot borrow `x` as mutable more than once at a time + --> $DIR/borrowck-closures-two-mut.rs:12:24 | LL | let c1 = to_fn_mut(|| x = 4); | -- - first borrow occurs due to use of `x` in closure @@ -84,12 +9,11 @@ LL | let c2 = to_fn_mut(|| x = 5); | ^^ - second borrow occurs due to use of `x` in closure | | | second mutable borrow occurs here -LL | LL | drop((c1, c2)); | -- first borrow later used here -error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir) - --> $DIR/borrowck-closures-two-mut.rs:26:24 +error[E0499]: cannot borrow `x` as mutable more than once at a time + --> $DIR/borrowck-closures-two-mut.rs:23:24 | LL | let c1 = to_fn_mut(|| set(&mut x)); | -- - first borrow occurs due to use of `x` in closure @@ -99,12 +23,11 @@ LL | let c2 = to_fn_mut(|| set(&mut x)); | ^^ - second borrow occurs due to use of `x` in closure | | | second mutable borrow occurs here -LL | LL | drop((c1, c2)); | -- first borrow later used here -error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir) - --> $DIR/borrowck-closures-two-mut.rs:34:24 +error[E0499]: cannot borrow `x` as mutable more than once at a time + --> $DIR/borrowck-closures-two-mut.rs:30:24 | LL | let c1 = to_fn_mut(|| x = 5); | -- - first borrow occurs due to use of `x` in closure @@ -114,12 +37,11 @@ LL | let c2 = to_fn_mut(|| set(&mut x)); | ^^ - second borrow occurs due to use of `x` in closure | | | second mutable borrow occurs here -LL | LL | drop((c1, c2)); | -- first borrow later used here -error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir) - --> $DIR/borrowck-closures-two-mut.rs:42:24 +error[E0499]: cannot borrow `x` as mutable more than once at a time + --> $DIR/borrowck-closures-two-mut.rs:37:24 | LL | let c1 = to_fn_mut(|| x = 5); | -- - first borrow occurs due to use of `x` in closure @@ -129,12 +51,12 @@ LL | let c2 = to_fn_mut(|| { let _y = to_fn_mut(|| set(&mut x)); }); // (nes | ^^ - second borrow occurs due to use of `x` in closure | | | second mutable borrow occurs here -... +LL | LL | drop((c1, c2)); | -- first borrow later used here -error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir) - --> $DIR/borrowck-closures-two-mut.rs:55:24 +error[E0499]: cannot borrow `x` as mutable more than once at a time + --> $DIR/borrowck-closures-two-mut.rs:49:24 | LL | let c1 = to_fn_mut(|| set(&mut *x.f)); | -- - first borrow occurs due to use of `x` in closure @@ -144,10 +66,10 @@ LL | let c2 = to_fn_mut(|| set(&mut *x.f)); | ^^ - second borrow occurs due to use of `x` in closure | | | second mutable borrow occurs here -... +LL | LL | drop((c1, c2)); | -- first borrow later used here -error: aborting due to 10 previous errors +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-reinit.rs b/src/test/ui/borrowck/borrowck-reinit.rs index e8e38a92c81e9..866b3a2a8af9b 100644 --- a/src/test/ui/borrowck/borrowck-reinit.rs +++ b/src/test/ui/borrowck/borrowck-reinit.rs @@ -1,10 +1,7 @@ -// compile-flags: -Z borrowck=compare - fn main() { let mut x = Box::new(0); let _u = x; // error shouldn't note this move x = Box::new(1); drop(x); - let _ = (1,x); //~ ERROR use of moved value: `x` (Ast) - //~^ ERROR use of moved value: `x` (Mir) + let _ = (1,x); //~ ERROR use of moved value: `x` } diff --git a/src/test/ui/borrowck/borrowck-reinit.stderr b/src/test/ui/borrowck/borrowck-reinit.stderr index 3618a7cb2cd39..f8f14b6435f08 100644 --- a/src/test/ui/borrowck/borrowck-reinit.stderr +++ b/src/test/ui/borrowck/borrowck-reinit.stderr @@ -1,15 +1,5 @@ -error[E0382]: use of moved value: `x` (Ast) - --> $DIR/borrowck-reinit.rs:8:16 - | -LL | drop(x); - | - value moved here -LL | let _ = (1,x); - | ^ value used here after move - | - = note: move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `x` (Mir) - --> $DIR/borrowck-reinit.rs:8:16 +error[E0382]: use of moved value: `x` + --> $DIR/borrowck-reinit.rs:6:16 | LL | let mut x = Box::new(0); | ----- move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait @@ -19,6 +9,6 @@ LL | drop(x); LL | let _ = (1,x); | ^ value used here after move -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-storage-dead.rs b/src/test/ui/borrowck/borrowck-storage-dead.rs index 72c3bc1371985..fe9844610425e 100644 --- a/src/test/ui/borrowck/borrowck-storage-dead.rs +++ b/src/test/ui/borrowck/borrowck-storage-dead.rs @@ -1,5 +1,3 @@ -// compile-flags: -Z borrowck=compare - fn ok() { loop { let _x = 1; @@ -15,8 +13,7 @@ fn also_ok() { fn fail() { loop { let x: i32; - let _ = x + 1; //~ERROR (Ast) [E0381] - //~^ ERROR (Mir) [E0381] + let _ = x + 1; //~ERROR [E0381] } } diff --git a/src/test/ui/borrowck/borrowck-storage-dead.stderr b/src/test/ui/borrowck/borrowck-storage-dead.stderr index c291ed224eb3c..5b9f49c2e7c92 100644 --- a/src/test/ui/borrowck/borrowck-storage-dead.stderr +++ b/src/test/ui/borrowck/borrowck-storage-dead.stderr @@ -1,15 +1,9 @@ -error[E0381]: use of possibly uninitialized variable: `x` (Ast) - --> $DIR/borrowck-storage-dead.rs:18:17 +error[E0381]: use of possibly uninitialized variable: `x` + --> $DIR/borrowck-storage-dead.rs:16:17 | LL | let _ = x + 1; | ^ use of possibly uninitialized `x` -error[E0381]: use of possibly uninitialized variable: `x` (Mir) - --> $DIR/borrowck-storage-dead.rs:18:17 - | -LL | let _ = x + 1; - | ^ use of possibly uninitialized `x` - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/immutable-arg.rs b/src/test/ui/borrowck/immutable-arg.rs index 8d1cd3c80455c..2352d1bbe6456 100644 --- a/src/test/ui/borrowck/immutable-arg.rs +++ b/src/test/ui/borrowck/immutable-arg.rs @@ -1,9 +1,6 @@ -//compile-flags: -Z borrowck=compare - fn foo(_x: u32) { _x = 4; - //~^ ERROR cannot assign to immutable argument `_x` (Mir) - //~^^ ERROR cannot assign twice to immutable variable `_x` (Ast) + //~^ ERROR cannot assign to immutable argument `_x` } fn main() {} diff --git a/src/test/ui/borrowck/immutable-arg.stderr b/src/test/ui/borrowck/immutable-arg.stderr index 8b21e92666674..7255ca327e753 100644 --- a/src/test/ui/borrowck/immutable-arg.stderr +++ b/src/test/ui/borrowck/immutable-arg.stderr @@ -1,19 +1,11 @@ -error[E0384]: cannot assign twice to immutable variable `_x` (Ast) - --> $DIR/immutable-arg.rs:4:5 - | -LL | fn foo(_x: u32) { - | -- first assignment to `_x` -LL | _x = 4; - | ^^^^^^ cannot assign twice to immutable variable - -error[E0384]: cannot assign to immutable argument `_x` (Mir) - --> $DIR/immutable-arg.rs:4:5 +error[E0384]: cannot assign to immutable argument `_x` + --> $DIR/immutable-arg.rs:2:5 | LL | fn foo(_x: u32) { | -- help: make this binding mutable: `mut _x` LL | _x = 4; | ^^^^^^ cannot assign to immutable argument -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/borrowck/issue-41962.rs b/src/test/ui/borrowck/issue-41962.rs index 2bcc074542d17..38a01b138e47d 100644 --- a/src/test/ui/borrowck/issue-41962.rs +++ b/src/test/ui/borrowck/issue-41962.rs @@ -1,13 +1,9 @@ -// compile-flags: -Z borrowck=compare - pub fn main(){ let maybe = Some(vec![true, true]); loop { if let Some(thing) = maybe { } - //~^^ ERROR use of partially moved value: `maybe` (Ast) [E0382] - //~| ERROR use of moved value: `(maybe as std::prelude::v1::Some).0` (Ast) [E0382] - //~| ERROR use of moved value (Mir) [E0382] + //~^^ ERROR use of moved value [E0382] } } diff --git a/src/test/ui/borrowck/issue-41962.stderr b/src/test/ui/borrowck/issue-41962.stderr index fd4d318b5ddf1..422d1605aa46b 100644 --- a/src/test/ui/borrowck/issue-41962.stderr +++ b/src/test/ui/borrowck/issue-41962.stderr @@ -1,29 +1,11 @@ -error[E0382]: use of partially moved value: `maybe` (Ast) - --> $DIR/issue-41962.rs:7:30 - | -LL | if let Some(thing) = maybe { - | ----- ^^^^^ value used here after move - | | - | value moved here - | - = note: move occurs because the value has type `std::vec::Vec`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `(maybe as std::prelude::v1::Some).0` (Ast) - --> $DIR/issue-41962.rs:7:21 - | -LL | if let Some(thing) = maybe { - | ^^^^^ value moved here in previous iteration of loop - | - = note: move occurs because the value has type `std::vec::Vec`, which does not implement the `Copy` trait - -error[E0382]: use of moved value (Mir) - --> $DIR/issue-41962.rs:7:21 +error[E0382]: use of moved value + --> $DIR/issue-41962.rs:5:21 | LL | if let Some(thing) = maybe { | ^^^^^ value moved here, in previous iteration of loop | = note: move occurs because value has type `std::vec::Vec`, which does not implement the `Copy` trait -error: aborting due to 3 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/generator/yield-while-local-borrowed.rs b/src/test/ui/generator/yield-while-local-borrowed.rs index 38061e71358c4..b643bbf3376fb 100644 --- a/src/test/ui/generator/yield-while-local-borrowed.rs +++ b/src/test/ui/generator/yield-while-local-borrowed.rs @@ -1,5 +1,3 @@ -// compile-flags: -Z borrowck=compare - #![feature(generators, generator_trait)] use std::ops::{GeneratorState, Generator}; @@ -13,8 +11,7 @@ fn borrow_local_inline() { // `b` and gets extended by region inference.) let mut b = move || { let a = &mut 3; - //~^ ERROR borrow may still be in use when generator yields (Ast) - //~| ERROR borrow may still be in use when generator yields (Mir) + //~^ ERROR borrow may still be in use when generator yields yield(); println!("{}", a); }; @@ -41,8 +38,7 @@ fn borrow_local() { let a = 3; { let b = &a; - //~^ ERROR borrow may still be in use when generator yields (Ast) - //~| ERROR borrow may still be in use when generator yields (Mir) + //~^ ERROR borrow may still be in use when generator yields yield(); println!("{}", b); } diff --git a/src/test/ui/generator/yield-while-local-borrowed.stderr b/src/test/ui/generator/yield-while-local-borrowed.stderr index 56f425b7e70a0..c1513ef9b7157 100644 --- a/src/test/ui/generator/yield-while-local-borrowed.stderr +++ b/src/test/ui/generator/yield-while-local-borrowed.stderr @@ -1,39 +1,21 @@ -error[E0626]: borrow may still be in use when generator yields (Ast) - --> $DIR/yield-while-local-borrowed.rs:15:22 - | -LL | let a = &mut 3; - | ^ -... -LL | yield(); - | ------- possible yield occurs here - -error[E0626]: borrow may still be in use when generator yields (Ast) - --> $DIR/yield-while-local-borrowed.rs:43:22 - | -LL | let b = &a; - | ^ -... -LL | yield(); - | ------- possible yield occurs here - -error[E0626]: borrow may still be in use when generator yields (Mir) - --> $DIR/yield-while-local-borrowed.rs:15:17 +error[E0626]: borrow may still be in use when generator yields + --> $DIR/yield-while-local-borrowed.rs:13:17 | LL | let a = &mut 3; | ^^^^^^ -... +LL | LL | yield(); | ------- possible yield occurs here -error[E0626]: borrow may still be in use when generator yields (Mir) - --> $DIR/yield-while-local-borrowed.rs:43:21 +error[E0626]: borrow may still be in use when generator yields + --> $DIR/yield-while-local-borrowed.rs:40:21 | LL | let b = &a; | ^^ -... +LL | LL | yield(); | ------- possible yield occurs here -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0626`. diff --git a/src/test/ui/issues/issue-44373-2.rs b/src/test/ui/issues/issue-44373-2.rs index ab92bf458fb60..18b2ce85125f2 100644 --- a/src/test/ui/issues/issue-44373-2.rs +++ b/src/test/ui/issues/issue-44373-2.rs @@ -1,6 +1,5 @@ // compile-pass #![allow(dead_code)] -// compile-flags: -Z borrowck=compare struct Foo(bool); diff --git a/src/test/ui/issues/issue-45697-1.rs b/src/test/ui/issues/issue-45697-1.rs index c9b267ca5a10a..b45f1170b86c5 100644 --- a/src/test/ui/issues/issue-45697-1.rs +++ b/src/test/ui/issues/issue-45697-1.rs @@ -1,7 +1,7 @@ // Test that assignments to an `&mut` pointer which is found in a // borrowed (but otherwise non-aliasable) location is illegal. -// compile-flags: -Z borrowck=compare -C overflow-checks=on +// compile-flags: -C overflow-checks=on struct S<'a> { pointer: &'a mut isize @@ -18,9 +18,8 @@ fn main() { let mut y = S { pointer: &mut x }; let z = copy_borrowed_ptr(&mut y); *y.pointer += 1; - //~^ ERROR cannot assign to `*y.pointer` because it is borrowed (Ast) [E0506] - //~| ERROR cannot use `*y.pointer` because it was mutably borrowed (Mir) [E0503] - //~| ERROR cannot assign to `*y.pointer` because it is borrowed (Mir) [E0506] + //~^ ERROR cannot use `*y.pointer` because it was mutably borrowed [E0503] + //~| ERROR cannot assign to `*y.pointer` because it is borrowed [E0506] *z.pointer += 1; } } diff --git a/src/test/ui/issues/issue-45697-1.stderr b/src/test/ui/issues/issue-45697-1.stderr index 854e18003f330..30c69f19658c8 100644 --- a/src/test/ui/issues/issue-45697-1.stderr +++ b/src/test/ui/issues/issue-45697-1.stderr @@ -1,12 +1,4 @@ -error[E0506]: cannot assign to `*y.pointer` because it is borrowed (Ast) - --> $DIR/issue-45697-1.rs:20:9 - | -LL | let z = copy_borrowed_ptr(&mut y); - | - borrow of `*y.pointer` occurs here -LL | *y.pointer += 1; - | ^^^^^^^^^^^^^^^ assignment to borrowed `*y.pointer` occurs here - -error[E0503]: cannot use `*y.pointer` because it was mutably borrowed (Mir) +error[E0503]: cannot use `*y.pointer` because it was mutably borrowed --> $DIR/issue-45697-1.rs:20:9 | LL | let z = copy_borrowed_ptr(&mut y); @@ -17,7 +9,7 @@ LL | *y.pointer += 1; LL | *z.pointer += 1; | --------------- borrow later used here -error[E0506]: cannot assign to `*y.pointer` because it is borrowed (Mir) +error[E0506]: cannot assign to `*y.pointer` because it is borrowed --> $DIR/issue-45697-1.rs:20:9 | LL | let z = copy_borrowed_ptr(&mut y); @@ -28,7 +20,7 @@ LL | *y.pointer += 1; LL | *z.pointer += 1; | --------------- borrow later used here -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors Some errors have detailed explanations: E0503, E0506. For more information about an error, try `rustc --explain E0503`. diff --git a/src/test/ui/issues/issue-45697.rs b/src/test/ui/issues/issue-45697.rs index 5bb30432fede4..db6d1d8fa2a92 100644 --- a/src/test/ui/issues/issue-45697.rs +++ b/src/test/ui/issues/issue-45697.rs @@ -1,7 +1,7 @@ // Test that assignments to an `&mut` pointer which is found in a // borrowed (but otherwise non-aliasable) location is illegal. -// compile-flags: -Z borrowck=compare -C overflow-checks=off +// compile-flags: -C overflow-checks=off struct S<'a> { pointer: &'a mut isize @@ -18,9 +18,8 @@ fn main() { let mut y = S { pointer: &mut x }; let z = copy_borrowed_ptr(&mut y); *y.pointer += 1; - //~^ ERROR cannot assign to `*y.pointer` because it is borrowed (Ast) [E0506] - //~| ERROR cannot use `*y.pointer` because it was mutably borrowed (Mir) [E0503] - //~| ERROR cannot assign to `*y.pointer` because it is borrowed (Mir) [E0506] + //~^ ERROR cannot use `*y.pointer` because it was mutably borrowed [E0503] + //~| ERROR cannot assign to `*y.pointer` because it is borrowed [E0506] *z.pointer += 1; } } diff --git a/src/test/ui/issues/issue-45697.stderr b/src/test/ui/issues/issue-45697.stderr index 01ae416b1cf14..26749d36f0b7b 100644 --- a/src/test/ui/issues/issue-45697.stderr +++ b/src/test/ui/issues/issue-45697.stderr @@ -1,12 +1,4 @@ -error[E0506]: cannot assign to `*y.pointer` because it is borrowed (Ast) - --> $DIR/issue-45697.rs:20:9 - | -LL | let z = copy_borrowed_ptr(&mut y); - | - borrow of `*y.pointer` occurs here -LL | *y.pointer += 1; - | ^^^^^^^^^^^^^^^ assignment to borrowed `*y.pointer` occurs here - -error[E0503]: cannot use `*y.pointer` because it was mutably borrowed (Mir) +error[E0503]: cannot use `*y.pointer` because it was mutably borrowed --> $DIR/issue-45697.rs:20:9 | LL | let z = copy_borrowed_ptr(&mut y); @@ -17,7 +9,7 @@ LL | *y.pointer += 1; LL | *z.pointer += 1; | --------------- borrow later used here -error[E0506]: cannot assign to `*y.pointer` because it is borrowed (Mir) +error[E0506]: cannot assign to `*y.pointer` because it is borrowed --> $DIR/issue-45697.rs:20:9 | LL | let z = copy_borrowed_ptr(&mut y); @@ -28,7 +20,7 @@ LL | *y.pointer += 1; LL | *z.pointer += 1; | --------------- borrow later used here -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors Some errors have detailed explanations: E0503, E0506. For more information about an error, try `rustc --explain E0503`. diff --git a/src/test/ui/issues/issue-46471-1.rs b/src/test/ui/issues/issue-46471-1.rs index 3cf3f35284951..aa161d40f702d 100644 --- a/src/test/ui/issues/issue-46471-1.rs +++ b/src/test/ui/issues/issue-46471-1.rs @@ -1,11 +1,8 @@ -// compile-flags: -Z borrowck=compare - fn main() { let y = { let mut z = 0; &mut z }; - //~^^ ERROR `z` does not live long enough (Ast) [E0597] - //~| ERROR `z` does not live long enough (Mir) [E0597] + //~^^ ERROR `z` does not live long enough [E0597] println!("{}", y); } diff --git a/src/test/ui/issues/issue-46471-1.stderr b/src/test/ui/issues/issue-46471-1.stderr index 51026c9f2d834..b09f31729a5fd 100644 --- a/src/test/ui/issues/issue-46471-1.stderr +++ b/src/test/ui/issues/issue-46471-1.stderr @@ -1,16 +1,5 @@ -error[E0597]: `z` does not live long enough (Ast) - --> $DIR/issue-46471-1.rs:6:14 - | -LL | &mut z - | ^ borrowed value does not live long enough -LL | }; - | - `z` dropped here while still borrowed -... -LL | } - | - borrowed value needs to live until here - -error[E0597]: `z` does not live long enough (Mir) - --> $DIR/issue-46471-1.rs:6:9 +error[E0597]: `z` does not live long enough + --> $DIR/issue-46471-1.rs:4:9 | LL | &mut z | ^^^^^^ @@ -20,6 +9,6 @@ LL | &mut z LL | }; | - `z` dropped here while still borrowed -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/issues/issue-46471.rs b/src/test/ui/issues/issue-46471.rs index 0905c8bb1eb12..8922005d2f82c 100644 --- a/src/test/ui/issues/issue-46471.rs +++ b/src/test/ui/issues/issue-46471.rs @@ -1,10 +1,7 @@ -// compile-flags: -Z borrowck=compare - fn foo() -> &'static u32 { let x = 0; &x - //~^ ERROR `x` does not live long enough (Ast) [E0597] - //~| ERROR cannot return reference to local variable `x` (Mir) [E0515] + //~^ ERROR cannot return reference to local variable `x` [E0515] } fn main() { } diff --git a/src/test/ui/issues/issue-46471.stderr b/src/test/ui/issues/issue-46471.stderr index 90202e307eb11..935414c1f3f9d 100644 --- a/src/test/ui/issues/issue-46471.stderr +++ b/src/test/ui/issues/issue-46471.stderr @@ -1,21 +1,9 @@ -error[E0597]: `x` does not live long enough (Ast) - --> $DIR/issue-46471.rs:5:6 - | -LL | &x - | ^ borrowed value does not live long enough -... -LL | } - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... - -error[E0515]: cannot return reference to local variable `x` (Mir) - --> $DIR/issue-46471.rs:5:5 +error[E0515]: cannot return reference to local variable `x` + --> $DIR/issue-46471.rs:3:5 | LL | &x | ^^ returns a reference to data owned by the current function -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0515, E0597. -For more information about an error, try `rustc --explain E0515`. +For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/issues/issue-46472.rs b/src/test/ui/issues/issue-46472.rs index 88f97e99aeaff..b9e20e8dbcb5f 100644 --- a/src/test/ui/issues/issue-46472.rs +++ b/src/test/ui/issues/issue-46472.rs @@ -1,9 +1,6 @@ -// compile-flags: -Z borrowck=compare - fn bar<'a>() -> &'a mut u32 { &mut 4 - //~^ ERROR borrowed value does not live long enough (Ast) [E0597] - //~| ERROR cannot return reference to temporary value (Mir) [E0515] + //~^ ERROR cannot return reference to temporary value [E0515] } fn main() { } diff --git a/src/test/ui/issues/issue-46472.stderr b/src/test/ui/issues/issue-46472.stderr index 0cc93a081b2af..6e561e03a8b7a 100644 --- a/src/test/ui/issues/issue-46472.stderr +++ b/src/test/ui/issues/issue-46472.stderr @@ -1,20 +1,5 @@ -error[E0597]: borrowed value does not live long enough (Ast) - --> $DIR/issue-46472.rs:4:10 - | -LL | &mut 4 - | ^ temporary value does not live long enough -... -LL | } - | - temporary value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 3:8... - --> $DIR/issue-46472.rs:3:8 - | -LL | fn bar<'a>() -> &'a mut u32 { - | ^^ - -error[E0515]: cannot return reference to temporary value (Mir) - --> $DIR/issue-46472.rs:4:5 +error[E0515]: cannot return reference to temporary value + --> $DIR/issue-46472.rs:2:5 | LL | &mut 4 | ^^^^^- @@ -22,7 +7,6 @@ LL | &mut 4 | | temporary value created here | returns a reference to data owned by the current function -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0515, E0597. -For more information about an error, try `rustc --explain E0515`. +For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/lifetimes/lifetime-errors/liveness-assign-imm-local-notes.rs b/src/test/ui/lifetimes/lifetime-errors/liveness-assign-imm-local-notes.rs index 99949e17b6f4a..81a20c58776c8 100644 --- a/src/test/ui/lifetimes/lifetime-errors/liveness-assign-imm-local-notes.rs +++ b/src/test/ui/lifetimes/lifetime-errors/liveness-assign-imm-local-notes.rs @@ -1,17 +1,13 @@ -// FIXME: Change to UI Test // Check notes are placed on an assignment that can actually precede the current assignment // Don't emit a first assignment for assignment in a loop. -// compile-flags: -Zborrowck=compare - fn test() { let x; if true { x = 1; } else { x = 2; - x = 3; //~ ERROR (Ast) [E0384] - //~^ ERROR (Mir) [E0384] + x = 3; //~ ERROR [E0384] } } @@ -22,8 +18,7 @@ fn test_in_loop() { x = 1; } else { x = 2; - x = 3; //~ ERROR (Ast) [E0384] - //~^ ERROR (Mir) [E0384] + x = 3; //~ ERROR [E0384] } } } @@ -32,11 +27,9 @@ fn test_using_loop() { let x; loop { if true { - x = 1; //~ ERROR (Ast) [E0384] - //~^ ERROR (Mir) [E0384] + x = 1; //~ ERROR [E0384] } else { - x = 2; //~ ERROR (Ast) [E0384] - //~^ ERROR (Mir) [E0384] + x = 2; //~ ERROR [E0384] } } } diff --git a/src/test/ui/lifetimes/lifetime-errors/liveness-assign-imm-local-notes.stderr b/src/test/ui/lifetimes/lifetime-errors/liveness-assign-imm-local-notes.stderr index e15290f0b9ee9..c646912d3b679 100644 --- a/src/test/ui/lifetimes/lifetime-errors/liveness-assign-imm-local-notes.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/liveness-assign-imm-local-notes.stderr @@ -1,36 +1,5 @@ -error[E0384]: cannot assign twice to immutable variable `x` (Ast) - --> $DIR/liveness-assign-imm-local-notes.rs:13:9 - | -LL | x = 2; - | ----- first assignment to `x` -LL | x = 3; - | ^^^^^ cannot assign twice to immutable variable - -error[E0384]: cannot assign twice to immutable variable `x` (Ast) - --> $DIR/liveness-assign-imm-local-notes.rs:25:13 - | -LL | x = 2; - | ----- first assignment to `x` -LL | x = 3; - | ^^^^^ cannot assign twice to immutable variable - -error[E0384]: cannot assign twice to immutable variable `x` (Ast) - --> $DIR/liveness-assign-imm-local-notes.rs:35:13 - | -LL | x = 1; - | ^^^^^ cannot assign twice to immutable variable - -error[E0384]: cannot assign twice to immutable variable `x` (Ast) - --> $DIR/liveness-assign-imm-local-notes.rs:38:13 - | -LL | x = 1; - | ----- first assignment to `x` -... -LL | x = 2; - | ^^^^^ cannot assign twice to immutable variable - -error[E0384]: cannot assign twice to immutable variable `x` (Mir) - --> $DIR/liveness-assign-imm-local-notes.rs:13:9 +error[E0384]: cannot assign twice to immutable variable `x` + --> $DIR/liveness-assign-imm-local-notes.rs:10:9 | LL | let x; | - help: make this binding mutable: `mut x` @@ -40,8 +9,8 @@ LL | x = 2; LL | x = 3; | ^^^^^ cannot assign twice to immutable variable -error[E0384]: cannot assign twice to immutable variable `x` (Mir) - --> $DIR/liveness-assign-imm-local-notes.rs:25:13 +error[E0384]: cannot assign twice to immutable variable `x` + --> $DIR/liveness-assign-imm-local-notes.rs:21:13 | LL | let x; | - help: make this binding mutable: `mut x` @@ -51,8 +20,8 @@ LL | x = 2; LL | x = 3; | ^^^^^ cannot assign twice to immutable variable -error[E0384]: cannot assign twice to immutable variable `x` (Mir) - --> $DIR/liveness-assign-imm-local-notes.rs:35:13 +error[E0384]: cannot assign twice to immutable variable `x` + --> $DIR/liveness-assign-imm-local-notes.rs:30:13 | LL | let x; | - help: make this binding mutable: `mut x` @@ -60,18 +29,18 @@ LL | let x; LL | x = 1; | ^^^^^ cannot assign twice to immutable variable -error[E0384]: cannot assign twice to immutable variable `x` (Mir) - --> $DIR/liveness-assign-imm-local-notes.rs:38:13 +error[E0384]: cannot assign twice to immutable variable `x` + --> $DIR/liveness-assign-imm-local-notes.rs:32:13 | LL | let x; | - help: make this binding mutable: `mut x` ... LL | x = 1; | ----- first assignment to `x` -... +LL | } else { LL | x = 2; | ^^^^^ cannot assign twice to immutable variable -error: aborting due to 8 previous errors +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/moves/moves-based-on-type-tuple.rs b/src/test/ui/moves/moves-based-on-type-tuple.rs index d99fe51931a1f..828d90cd7ac7f 100644 --- a/src/test/ui/moves/moves-based-on-type-tuple.rs +++ b/src/test/ui/moves/moves-based-on-type-tuple.rs @@ -1,11 +1,8 @@ #![feature(box_syntax)] -// compile-flags: -Z borrowck=compare - fn dup(x: Box) -> Box<(Box,Box)> { box (x, x) - //~^ use of moved value: `x` (Ast) [E0382] - //~| use of moved value: `x` (Mir) [E0382] + //~^ use of moved value: `x` [E0382] } fn main() { diff --git a/src/test/ui/moves/moves-based-on-type-tuple.stderr b/src/test/ui/moves/moves-based-on-type-tuple.stderr index c49dbdab40210..2e1ddbdf57f98 100644 --- a/src/test/ui/moves/moves-based-on-type-tuple.stderr +++ b/src/test/ui/moves/moves-based-on-type-tuple.stderr @@ -1,15 +1,5 @@ -error[E0382]: use of moved value: `x` (Ast) - --> $DIR/moves-based-on-type-tuple.rs:6:13 - | -LL | box (x, x) - | - ^ value used here after move - | | - | value moved here - | - = note: move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `x` (Mir) - --> $DIR/moves-based-on-type-tuple.rs:6:13 +error[E0382]: use of moved value: `x` + --> $DIR/moves-based-on-type-tuple.rs:4:13 | LL | fn dup(x: Box) -> Box<(Box,Box)> { | - move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait @@ -18,6 +8,6 @@ LL | box (x, x) | | | value moved here -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/nll/get_default.rs b/src/test/ui/nll/get_default.rs index 89f693bfb654e..ffac8a33da104 100644 --- a/src/test/ui/nll/get_default.rs +++ b/src/test/ui/nll/get_default.rs @@ -3,8 +3,6 @@ // a variety of errors from the older, AST-based machinery (notably // borrowck), and then we get the NLL error at the end. -// compile-flags:-Zborrowck=compare - struct Map { } @@ -21,8 +19,7 @@ fn ok(map: &mut Map) -> &String { } None => { map.set(String::new()); // Ideally, this would not error. - //~^ ERROR borrowed as immutable (Ast) - //~| ERROR borrowed as immutable (Mir) + //~^ ERROR borrowed as immutable } } } @@ -33,14 +30,12 @@ fn err(map: &mut Map) -> &String { match map.get() { Some(v) => { map.set(String::new()); // Both AST and MIR error here - //~^ ERROR borrowed as immutable (Mir) - //~| ERROR borrowed as immutable (Ast) + //~^ ERROR borrowed as immutable return v; } None => { map.set(String::new()); // Ideally, just AST would error here - //~^ ERROR borrowed as immutable (Ast) - //~| ERROR borrowed as immutable (Mir) + //~^ ERROR borrowed as immutable } } } diff --git a/src/test/ui/nll/get_default.stderr b/src/test/ui/nll/get_default.stderr index abb5343845b57..af79771e7e1b9 100644 --- a/src/test/ui/nll/get_default.stderr +++ b/src/test/ui/nll/get_default.stderr @@ -1,41 +1,5 @@ -error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Ast) - --> $DIR/get_default.rs:23:17 - | -LL | match map.get() { - | --- immutable borrow occurs here -... -LL | map.set(String::new()); // Ideally, this would not error. - | ^^^ mutable borrow occurs here -... -LL | } - | - immutable borrow ends here - -error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Ast) - --> $DIR/get_default.rs:35:17 - | -LL | match map.get() { - | --- immutable borrow occurs here -LL | Some(v) => { -LL | map.set(String::new()); // Both AST and MIR error here - | ^^^ mutable borrow occurs here -... -LL | } - | - immutable borrow ends here - -error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Ast) - --> $DIR/get_default.rs:41:17 - | -LL | match map.get() { - | --- immutable borrow occurs here -... -LL | map.set(String::new()); // Ideally, just AST would error here - | ^^^ mutable borrow occurs here -... -LL | } - | - immutable borrow ends here - -error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir) - --> $DIR/get_default.rs:23:17 +error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable + --> $DIR/get_default.rs:21:17 | LL | fn ok(map: &mut Map) -> &String { | - let's call the lifetime of this reference `'1` @@ -47,10 +11,10 @@ LL | return v; | - returning this value requires that `*map` is borrowed for `'1` ... LL | map.set(String::new()); // Ideally, this would not error. - | ^^^ mutable borrow occurs here + | ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here -error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir) - --> $DIR/get_default.rs:35:17 +error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable + --> $DIR/get_default.rs:32:17 | LL | fn err(map: &mut Map) -> &String { | - let's call the lifetime of this reference `'1` @@ -59,13 +23,13 @@ LL | match map.get() { | --- immutable borrow occurs here LL | Some(v) => { LL | map.set(String::new()); // Both AST and MIR error here - | ^^^ mutable borrow occurs here -... + | ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here +LL | LL | return v; | - returning this value requires that `*map` is borrowed for `'1` -error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir) - --> $DIR/get_default.rs:41:17 +error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable + --> $DIR/get_default.rs:37:17 | LL | fn err(map: &mut Map) -> &String { | - let's call the lifetime of this reference `'1` @@ -77,8 +41,8 @@ LL | return v; | - returning this value requires that `*map` is borrowed for `'1` ... LL | map.set(String::new()); // Ideally, just AST would error here - | ^^^ mutable borrow occurs here + | ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here -error: aborting due to 6 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/nll/loan_ends_mid_block_pair.rs b/src/test/ui/nll/loan_ends_mid_block_pair.rs index bad214deac129..acd6ec706080d 100644 --- a/src/test/ui/nll/loan_ends_mid_block_pair.rs +++ b/src/test/ui/nll/loan_ends_mid_block_pair.rs @@ -1,5 +1,3 @@ -// compile-flags:-Zborrowck=compare - #![allow(warnings)] #![feature(rustc_attrs)] @@ -12,12 +10,9 @@ fn nll_fail() { let c = &mut data.0; capitalize(c); data.0 = 'e'; - //~^ ERROR (Ast) [E0506] - //~| ERROR (Mir) [E0506] + //~^ ERROR [E0506] data.0 = 'f'; - //~^ ERROR (Ast) [E0506] data.0 = 'g'; - //~^ ERROR (Ast) [E0506] capitalize(c); } @@ -26,11 +21,8 @@ fn nll_ok() { let c = &mut data.0; capitalize(c); data.0 = 'e'; - //~^ ERROR (Ast) [E0506] data.0 = 'f'; - //~^ ERROR (Ast) [E0506] data.0 = 'g'; - //~^ ERROR (Ast) [E0506] } fn capitalize(_: &mut char) { diff --git a/src/test/ui/nll/loan_ends_mid_block_pair.stderr b/src/test/ui/nll/loan_ends_mid_block_pair.stderr index 85703bda31c4e..eb8442b31d7c7 100644 --- a/src/test/ui/nll/loan_ends_mid_block_pair.stderr +++ b/src/test/ui/nll/loan_ends_mid_block_pair.stderr @@ -1,59 +1,5 @@ -error[E0506]: cannot assign to `data.0` because it is borrowed (Ast) - --> $DIR/loan_ends_mid_block_pair.rs:14:5 - | -LL | let c = &mut data.0; - | ------ borrow of `data.0` occurs here -LL | capitalize(c); -LL | data.0 = 'e'; - | ^^^^^^^^^^^^ assignment to borrowed `data.0` occurs here - -error[E0506]: cannot assign to `data.0` because it is borrowed (Ast) - --> $DIR/loan_ends_mid_block_pair.rs:17:5 - | -LL | let c = &mut data.0; - | ------ borrow of `data.0` occurs here -... -LL | data.0 = 'f'; - | ^^^^^^^^^^^^ assignment to borrowed `data.0` occurs here - -error[E0506]: cannot assign to `data.0` because it is borrowed (Ast) - --> $DIR/loan_ends_mid_block_pair.rs:19:5 - | -LL | let c = &mut data.0; - | ------ borrow of `data.0` occurs here -... -LL | data.0 = 'g'; - | ^^^^^^^^^^^^ assignment to borrowed `data.0` occurs here - -error[E0506]: cannot assign to `data.0` because it is borrowed (Ast) - --> $DIR/loan_ends_mid_block_pair.rs:28:5 - | -LL | let c = &mut data.0; - | ------ borrow of `data.0` occurs here -LL | capitalize(c); -LL | data.0 = 'e'; - | ^^^^^^^^^^^^ assignment to borrowed `data.0` occurs here - -error[E0506]: cannot assign to `data.0` because it is borrowed (Ast) - --> $DIR/loan_ends_mid_block_pair.rs:30:5 - | -LL | let c = &mut data.0; - | ------ borrow of `data.0` occurs here -... -LL | data.0 = 'f'; - | ^^^^^^^^^^^^ assignment to borrowed `data.0` occurs here - -error[E0506]: cannot assign to `data.0` because it is borrowed (Ast) - --> $DIR/loan_ends_mid_block_pair.rs:32:5 - | -LL | let c = &mut data.0; - | ------ borrow of `data.0` occurs here -... -LL | data.0 = 'g'; - | ^^^^^^^^^^^^ assignment to borrowed `data.0` occurs here - -error[E0506]: cannot assign to `data.0` because it is borrowed (Mir) - --> $DIR/loan_ends_mid_block_pair.rs:14:5 +error[E0506]: cannot assign to `data.0` because it is borrowed + --> $DIR/loan_ends_mid_block_pair.rs:12:5 | LL | let c = &mut data.0; | ----------- borrow of `data.0` occurs here @@ -64,6 +10,6 @@ LL | data.0 = 'e'; LL | capitalize(c); | - borrow later used here -error: aborting due to 7 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/nll/loan_ends_mid_block_vec.rs b/src/test/ui/nll/loan_ends_mid_block_vec.rs index 682e7e3e96fee..2edcdef0af86c 100644 --- a/src/test/ui/nll/loan_ends_mid_block_vec.rs +++ b/src/test/ui/nll/loan_ends_mid_block_vec.rs @@ -1,5 +1,3 @@ -// compile-flags:-Zborrowck=compare - #![allow(warnings)] #![feature(rustc_attrs)] @@ -11,14 +9,11 @@ fn nll_fail() { let slice = &mut data; capitalize(slice); data.push('d'); - //~^ ERROR (Ast) [E0499] - //~| ERROR (Mir) [E0499] + //~^ ERROR [E0499] data.push('e'); - //~^ ERROR (Ast) [E0499] - //~| ERROR (Mir) [E0499] + //~^ ERROR [E0499] data.push('f'); - //~^ ERROR (Ast) [E0499] - //~| ERROR (Mir) [E0499] + //~^ ERROR [E0499] capitalize(slice); } @@ -27,11 +22,8 @@ fn nll_ok() { let slice = &mut data; capitalize(slice); data.push('d'); - //~^ ERROR (Ast) [E0499] data.push('e'); - //~^ ERROR (Ast) [E0499] data.push('f'); - //~^ ERROR (Ast) [E0499] } fn capitalize(_: &mut [char]) { diff --git a/src/test/ui/nll/loan_ends_mid_block_vec.stderr b/src/test/ui/nll/loan_ends_mid_block_vec.stderr index a3f1391f00140..c0b97bea348c4 100644 --- a/src/test/ui/nll/loan_ends_mid_block_vec.stderr +++ b/src/test/ui/nll/loan_ends_mid_block_vec.stderr @@ -1,77 +1,5 @@ -error[E0499]: cannot borrow `data` as mutable more than once at a time (Ast) - --> $DIR/loan_ends_mid_block_vec.rs:13:5 - | -LL | let slice = &mut data; - | ---- first mutable borrow occurs here -LL | capitalize(slice); -LL | data.push('d'); - | ^^^^ second mutable borrow occurs here -... -LL | } - | - first borrow ends here - -error[E0499]: cannot borrow `data` as mutable more than once at a time (Ast) - --> $DIR/loan_ends_mid_block_vec.rs:16:5 - | -LL | let slice = &mut data; - | ---- first mutable borrow occurs here -... -LL | data.push('e'); - | ^^^^ second mutable borrow occurs here -... -LL | } - | - first borrow ends here - -error[E0499]: cannot borrow `data` as mutable more than once at a time (Ast) - --> $DIR/loan_ends_mid_block_vec.rs:19:5 - | -LL | let slice = &mut data; - | ---- first mutable borrow occurs here -... -LL | data.push('f'); - | ^^^^ second mutable borrow occurs here -... -LL | } - | - first borrow ends here - -error[E0499]: cannot borrow `data` as mutable more than once at a time (Ast) - --> $DIR/loan_ends_mid_block_vec.rs:29:5 - | -LL | let slice = &mut data; - | ---- first mutable borrow occurs here -LL | capitalize(slice); -LL | data.push('d'); - | ^^^^ second mutable borrow occurs here -... -LL | } - | - first borrow ends here - -error[E0499]: cannot borrow `data` as mutable more than once at a time (Ast) - --> $DIR/loan_ends_mid_block_vec.rs:31:5 - | -LL | let slice = &mut data; - | ---- first mutable borrow occurs here -... -LL | data.push('e'); - | ^^^^ second mutable borrow occurs here -... -LL | } - | - first borrow ends here - -error[E0499]: cannot borrow `data` as mutable more than once at a time (Ast) - --> $DIR/loan_ends_mid_block_vec.rs:33:5 - | -LL | let slice = &mut data; - | ---- first mutable borrow occurs here -... -LL | data.push('f'); - | ^^^^ second mutable borrow occurs here -LL | -LL | } - | - first borrow ends here - -error[E0499]: cannot borrow `data` as mutable more than once at a time (Mir) - --> $DIR/loan_ends_mid_block_vec.rs:13:5 +error[E0499]: cannot borrow `data` as mutable more than once at a time + --> $DIR/loan_ends_mid_block_vec.rs:11:5 | LL | let slice = &mut data; | --------- first mutable borrow occurs here @@ -82,8 +10,8 @@ LL | data.push('d'); LL | capitalize(slice); | ----- first borrow later used here -error[E0499]: cannot borrow `data` as mutable more than once at a time (Mir) - --> $DIR/loan_ends_mid_block_vec.rs:16:5 +error[E0499]: cannot borrow `data` as mutable more than once at a time + --> $DIR/loan_ends_mid_block_vec.rs:13:5 | LL | let slice = &mut data; | --------- first mutable borrow occurs here @@ -94,18 +22,18 @@ LL | data.push('e'); LL | capitalize(slice); | ----- first borrow later used here -error[E0499]: cannot borrow `data` as mutable more than once at a time (Mir) - --> $DIR/loan_ends_mid_block_vec.rs:19:5 +error[E0499]: cannot borrow `data` as mutable more than once at a time + --> $DIR/loan_ends_mid_block_vec.rs:15:5 | LL | let slice = &mut data; | --------- first mutable borrow occurs here ... LL | data.push('f'); | ^^^^ second mutable borrow occurs here -... +LL | LL | capitalize(slice); | ----- first borrow later used here -error: aborting due to 9 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/nll/region-ends-after-if-condition.rs b/src/test/ui/nll/region-ends-after-if-condition.rs index 1bf13a91b9116..f67de03caf225 100644 --- a/src/test/ui/nll/region-ends-after-if-condition.rs +++ b/src/test/ui/nll/region-ends-after-if-condition.rs @@ -2,8 +2,6 @@ // in the type of `p` includes the points after `&v[0]` up to (but not // including) the call to `use_x`. The `else` branch is not included. -// compile-flags:-Zborrowck=compare - #![allow(warnings)] #![feature(rustc_attrs)] @@ -17,7 +15,6 @@ fn foo1() { let value = &my_struct.field; if value.is_empty() { my_struct.field.push_str("Hello, world!"); - //~^ ERROR (Ast) [E0502] } } @@ -27,8 +24,7 @@ fn foo2() { let value = &my_struct.field; if value.is_empty() { my_struct.field.push_str("Hello, world!"); - //~^ ERROR (Ast) [E0502] - //~| ERROR (Mir) [E0502] + //~^ ERROR [E0502] } drop(value); } diff --git a/src/test/ui/nll/region-ends-after-if-condition.stderr b/src/test/ui/nll/region-ends-after-if-condition.stderr index aa876a0bcb3bf..c03e385790616 100644 --- a/src/test/ui/nll/region-ends-after-if-condition.stderr +++ b/src/test/ui/nll/region-ends-after-if-condition.stderr @@ -1,39 +1,15 @@ -error[E0502]: cannot borrow `my_struct.field` as mutable because it is also borrowed as immutable (Ast) - --> $DIR/region-ends-after-if-condition.rs:19:9 - | -LL | let value = &my_struct.field; - | --------------- immutable borrow occurs here -LL | if value.is_empty() { -LL | my_struct.field.push_str("Hello, world!"); - | ^^^^^^^^^^^^^^^ mutable borrow occurs here -... -LL | } - | - immutable borrow ends here - -error[E0502]: cannot borrow `my_struct.field` as mutable because it is also borrowed as immutable (Ast) - --> $DIR/region-ends-after-if-condition.rs:29:9 - | -LL | let value = &my_struct.field; - | --------------- immutable borrow occurs here -LL | if value.is_empty() { -LL | my_struct.field.push_str("Hello, world!"); - | ^^^^^^^^^^^^^^^ mutable borrow occurs here -... -LL | } - | - immutable borrow ends here - -error[E0502]: cannot borrow `my_struct.field` as mutable because it is also borrowed as immutable (Mir) - --> $DIR/region-ends-after-if-condition.rs:29:9 +error[E0502]: cannot borrow `my_struct.field` as mutable because it is also borrowed as immutable + --> $DIR/region-ends-after-if-condition.rs:26:9 | LL | let value = &my_struct.field; | ---------------- immutable borrow occurs here LL | if value.is_empty() { LL | my_struct.field.push_str("Hello, world!"); - | ^^^^^^^^^^^^^^^ mutable borrow occurs here + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here ... LL | drop(value); | ----- immutable borrow later used here -error: aborting due to 3 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/nll/return_from_loop.rs b/src/test/ui/nll/return_from_loop.rs index 23a1e0b816cbd..49541089405f2 100644 --- a/src/test/ui/nll/return_from_loop.rs +++ b/src/test/ui/nll/return_from_loop.rs @@ -2,8 +2,6 @@ // in the type of `p` includes the points after `&v[0]` up to (but not // including) the call to `use_x`. The `else` branch is not included. -// compile-flags:-Zborrowck=compare - #![allow(warnings)] #![feature(rustc_attrs)] @@ -20,8 +18,7 @@ fn nll_fail() { let value = &mut my_struct.field; loop { my_struct.field.push_str("Hello, world!"); - //~^ ERROR (Ast) [E0499] - //~| ERROR (Mir) [E0499] + //~^ ERROR [E0499] value.len(); return; } @@ -33,7 +30,6 @@ fn nll_ok() { let value = &mut my_struct.field; loop { my_struct.field.push_str("Hello, world!"); - //~^ ERROR (Ast) [E0499] return; } } diff --git a/src/test/ui/nll/return_from_loop.stderr b/src/test/ui/nll/return_from_loop.stderr index 09882d55cb70e..efd56ea2dd542 100644 --- a/src/test/ui/nll/return_from_loop.stderr +++ b/src/test/ui/nll/return_from_loop.stderr @@ -1,39 +1,15 @@ -error[E0499]: cannot borrow `my_struct.field` as mutable more than once at a time (Ast) - --> $DIR/return_from_loop.rs:22:9 - | -LL | let value = &mut my_struct.field; - | --------------- first mutable borrow occurs here -LL | loop { -LL | my_struct.field.push_str("Hello, world!"); - | ^^^^^^^^^^^^^^^ second mutable borrow occurs here -... -LL | } - | - first borrow ends here - -error[E0499]: cannot borrow `my_struct.field` as mutable more than once at a time (Ast) - --> $DIR/return_from_loop.rs:35:9 - | -LL | let value = &mut my_struct.field; - | --------------- first mutable borrow occurs here -LL | loop { -LL | my_struct.field.push_str("Hello, world!"); - | ^^^^^^^^^^^^^^^ second mutable borrow occurs here -... -LL | } - | - first borrow ends here - -error[E0499]: cannot borrow `my_struct.field` as mutable more than once at a time (Mir) - --> $DIR/return_from_loop.rs:22:9 +error[E0499]: cannot borrow `my_struct.field` as mutable more than once at a time + --> $DIR/return_from_loop.rs:20:9 | LL | let value = &mut my_struct.field; | -------------------- first mutable borrow occurs here LL | loop { LL | my_struct.field.push_str("Hello, world!"); | ^^^^^^^^^^^^^^^ second mutable borrow occurs here -... +LL | LL | value.len(); | ----- first borrow later used here -error: aborting due to 3 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0499`. From db6f7a9d1a8b9aeae93e0512f0f236fda36b0314 Mon Sep 17 00:00:00 2001 From: Christopher Vittal Date: Fri, 3 May 2019 17:34:17 -0400 Subject: [PATCH 4/4] Update help message --- src/librustc/infer/mod.rs | 2 +- src/librustc/session/config.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc/infer/mod.rs b/src/librustc/infer/mod.rs index fc209df8516ca..aac89f466389a 100644 --- a/src/librustc/infer/mod.rs +++ b/src/librustc/infer/mod.rs @@ -97,7 +97,7 @@ impl SuppressRegionErrors { // If we're on Migrate mode, report AST region errors BorrowckMode::Migrate => SuppressRegionErrors { suppressed: false }, - // If we're on MIR don't report AST region errors as they should be reported by NLL + // If we're on MIR, don't report AST region errors as they should be reported by NLL BorrowckMode::Mir => SuppressRegionErrors { suppressed: true }, } } diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 4577c06fc68d6..ad80e5d74bd2a 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -1211,7 +1211,7 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, identify_regions: bool = (false, parse_bool, [UNTRACKED], "make unnamed regions display as '# (where # is some non-ident unique id)"), borrowck: Option = (None, parse_opt_string, [UNTRACKED], - "select which borrowck is used (`ast`, `mir`, `migrate`, or `compare`)"), + "select which borrowck is used (`mir` or `migrate`)"), time_passes: bool = (false, parse_bool, [UNTRACKED], "measure time of each rustc pass"), time: bool = (false, parse_bool, [UNTRACKED],