Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove -Z borrowck=compare flag #60513

Merged
merged 4 commits into from
May 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/librustc/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
}
}
}
Expand Down
6 changes: 1 addition & 5 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,6 @@ pub enum PrintRequest {
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum BorrowckMode {
Mir,
Compare,
Migrate,
}

Expand All @@ -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,
}
Expand All @@ -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,
}
Expand Down Expand Up @@ -1214,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<String> = (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],
Expand Down Expand Up @@ -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)),
};

Expand Down
24 changes: 4 additions & 20 deletions src/librustc_mir/util/borrowck_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
}

Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass/binding/match-pipe-binding.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// run-pass
// compile-flags: -Z borrowck=compare

fn test1() {
// from issue 6338
Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass/issues/issue-16671.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// run-pass
//compile-flags: -Z borrowck=compare

#![deny(warnings)]

Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass/issues/issue-49955.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// run-pass
// compile-flags: -Z borrowck=compare

const ALL_THE_NUMS: [u32; 1] = [
1
Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass/issues/issue-8860.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass/numbers-arithmetic/i128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

// ignore-emscripten i128 doesn't work

// compile-flags: -Z borrowck=compare

#![feature(test)]

Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass/numbers-arithmetic/u128.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// run-pass
// ignore-emscripten u128 not supported

// compile-flags: -Z borrowck=compare

#![feature(test)]

Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass/weird-exprs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#![allow(dead_code)]
#![allow(unreachable_code)]
#![allow(unused_parens)]
// compile-flags: -Z borrowck=compare

#![recursion_limit = "256"]

Expand Down
7 changes: 0 additions & 7 deletions src/test/ui/borrowck/borrowck-closures-two-mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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: FnMut()>(f: F) -> F { f }
Expand All @@ -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));
}

Expand All @@ -24,15 +21,13 @@ 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));
}

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));
}

Expand All @@ -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));
}

Expand All @@ -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));
}

Expand Down
104 changes: 13 additions & 91 deletions src/test/ui/borrowck/borrowck-closures-two-mut.stderr
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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`.
5 changes: 1 addition & 4 deletions src/test/ui/borrowck/borrowck-reinit.rs
Original file line number Diff line number Diff line change
@@ -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`
}
16 changes: 3 additions & 13 deletions src/test/ui/borrowck/borrowck-reinit.stderr
Original file line number Diff line number Diff line change
@@ -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<i32>`, 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<i32>`, which does not implement the `Copy` trait
Expand All @@ -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`.
5 changes: 1 addition & 4 deletions src/test/ui/borrowck/borrowck-storage-dead.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// compile-flags: -Z borrowck=compare

fn ok() {
loop {
let _x = 1;
Expand All @@ -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]
}
}

Expand Down
Loading