Skip to content

Commit ffc33b3

Browse files
authored
Rollup merge of rust-lang#60513 - chrisvittal:remove-borrowck-compare, r=matthewjasper
Remove -Z borrowck=compare flag This is the start of the work that needs to be done on rust-lang#59193. It just removes the flag and updates the tests. r? @matthewjasper
2 parents 0399d13 + db6f7a9 commit ffc33b3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+128
-675
lines changed

src/librustc/infer/mod.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,8 @@ impl SuppressRegionErrors {
9797
// If we're on Migrate mode, report AST region errors
9898
BorrowckMode::Migrate => SuppressRegionErrors { suppressed: false },
9999

100-
// If we're on MIR or Compare mode, don't report AST region errors as they should
101-
// be reported by NLL
102-
BorrowckMode::Compare | BorrowckMode::Mir => SuppressRegionErrors { suppressed: true },
100+
// If we're on MIR, don't report AST region errors as they should be reported by NLL
101+
BorrowckMode::Mir => SuppressRegionErrors { suppressed: true },
103102
}
104103
}
105104
}

src/librustc/session/config.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,6 @@ pub enum PrintRequest {
462462
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
463463
pub enum BorrowckMode {
464464
Mir,
465-
Compare,
466465
Migrate,
467466
}
468467

@@ -471,7 +470,6 @@ impl BorrowckMode {
471470
/// on the AST borrow check if the MIR-based one errors.
472471
pub fn migrate(self) -> bool {
473472
match self {
474-
BorrowckMode::Compare => false,
475473
BorrowckMode::Mir => false,
476474
BorrowckMode::Migrate => true,
477475
}
@@ -480,7 +478,6 @@ impl BorrowckMode {
480478
/// Should we emit the AST-based borrow checker errors?
481479
pub fn use_ast(self) -> bool {
482480
match self {
483-
BorrowckMode::Compare => true,
484481
BorrowckMode::Mir => false,
485482
BorrowckMode::Migrate => false,
486483
}
@@ -1214,7 +1211,7 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
12141211
identify_regions: bool = (false, parse_bool, [UNTRACKED],
12151212
"make unnamed regions display as '# (where # is some non-ident unique id)"),
12161213
borrowck: Option<String> = (None, parse_opt_string, [UNTRACKED],
1217-
"select which borrowck is used (`ast`, `mir`, `migrate`, or `compare`)"),
1214+
"select which borrowck is used (`mir` or `migrate`)"),
12181215
time_passes: bool = (false, parse_bool, [UNTRACKED],
12191216
"measure time of each rustc pass"),
12201217
time: bool = (false, parse_bool, [UNTRACKED],
@@ -2315,7 +2312,6 @@ pub fn build_session_options_and_crate_config(
23152312
let borrowck_mode = match debugging_opts.borrowck.as_ref().map(|s| &s[..]) {
23162313
None | Some("migrate") => BorrowckMode::Migrate,
23172314
Some("mir") => BorrowckMode::Mir,
2318-
Some("compare") => BorrowckMode::Compare,
23192315
Some(m) => early_error(error_format, &format!("unknown borrowck mode `{}`", m)),
23202316
};
23212317

src/librustc_mir/util/borrowck_errors.rs

+4-20
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,10 @@ pub enum Origin {
1212
}
1313

1414
impl fmt::Display for Origin {
15-
fn fmt(&self, w: &mut fmt::Formatter<'_>) -> fmt::Result {
16-
// If the user passed `-Z borrowck=compare`, then include
17-
// origin info as part of the error report,
18-
// otherwise
19-
let display_origin = ty::tls::with_opt(|opt_tcx| {
20-
if let Some(tcx) = opt_tcx {
21-
tcx.sess.opts.borrowck_mode == BorrowckMode::Compare
22-
} else {
23-
false
24-
}
25-
});
26-
if display_origin {
27-
match *self {
28-
Origin::Mir => write!(w, " (Mir)"),
29-
Origin::Ast => write!(w, " (Ast)"),
30-
}
31-
} else {
32-
// Print no origin info
33-
Ok(())
34-
}
15+
fn fmt(&self, _w: &mut fmt::Formatter<'_>) -> fmt::Result {
16+
// FIXME(chrisvittal) remove Origin entirely
17+
// Print no origin info
18+
Ok(())
3519
}
3620
}
3721

src/test/run-pass/binding/match-pipe-binding.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// run-pass
2-
// compile-flags: -Z borrowck=compare
32

43
fn test1() {
54
// from issue 6338

src/test/run-pass/issues/issue-16671.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// run-pass
2-
//compile-flags: -Z borrowck=compare
32

43
#![deny(warnings)]
54

src/test/run-pass/issues/issue-49955.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// run-pass
2-
// compile-flags: -Z borrowck=compare
32

43
const ALL_THE_NUMS: [u32; 1] = [
54
1

src/test/run-pass/issues/issue-8860.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// run-pass
22
#![allow(dead_code)]
3-
// compile-flags: -Z borrowck=compare
43

54
static mut DROP: isize = 0;
65
static mut DROP_S: isize = 0;

src/test/run-pass/numbers-arithmetic/i128.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
// ignore-emscripten i128 doesn't work
55

6-
// compile-flags: -Z borrowck=compare
76

87
#![feature(test)]
98

src/test/run-pass/numbers-arithmetic/u128.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// run-pass
22
// ignore-emscripten u128 not supported
33

4-
// compile-flags: -Z borrowck=compare
54

65
#![feature(test)]
76

src/test/run-pass/weird-exprs.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#![allow(dead_code)]
33
#![allow(unreachable_code)]
44
#![allow(unused_parens)]
5-
// compile-flags: -Z borrowck=compare
65

76
#![recursion_limit = "256"]
87

src/test/ui/borrowck/borrowck-closures-two-mut.rs

-7
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// access to the variable, whether that mutable access be used
33
// for direct assignment or for taking mutable ref. Issue #6801.
44

5-
// compile-flags: -Z borrowck=compare
6-
75
#![feature(box_syntax)]
86

97
fn to_fn_mut<F: FnMut()>(f: F) -> F { f }
@@ -12,7 +10,6 @@ fn a() {
1210
let mut x = 3;
1311
let c1 = to_fn_mut(|| x = 4);
1412
let c2 = to_fn_mut(|| x = 5); //~ ERROR cannot borrow `x` as mutable more than once
15-
//~| ERROR cannot borrow `x` as mutable more than once
1613
drop((c1, c2));
1714
}
1815

@@ -24,15 +21,13 @@ fn b() {
2421
let mut x = 3;
2522
let c1 = to_fn_mut(|| set(&mut x));
2623
let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once
27-
//~| ERROR cannot borrow `x` as mutable more than once
2824
drop((c1, c2));
2925
}
3026

3127
fn c() {
3228
let mut x = 3;
3329
let c1 = to_fn_mut(|| x = 5);
3430
let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once
35-
//~| ERROR cannot borrow `x` as mutable more than once
3631
drop((c1, c2));
3732
}
3833

@@ -41,7 +36,6 @@ fn d() {
4136
let c1 = to_fn_mut(|| x = 5);
4237
let c2 = to_fn_mut(|| { let _y = to_fn_mut(|| set(&mut x)); }); // (nested closure)
4338
//~^ ERROR cannot borrow `x` as mutable more than once
44-
//~| ERROR cannot borrow `x` as mutable more than once
4539
drop((c1, c2));
4640
}
4741

@@ -54,7 +48,6 @@ fn g() {
5448
let c1 = to_fn_mut(|| set(&mut *x.f));
5549
let c2 = to_fn_mut(|| set(&mut *x.f));
5650
//~^ ERROR cannot borrow `x` as mutable more than once
57-
//~| ERROR cannot borrow `x` as mutable more than once
5851
drop((c1, c2));
5952
}
6053

Original file line numberDiff line numberDiff line change
@@ -1,80 +1,5 @@
1-
error[E0499]: cannot borrow `x` as mutable more than once at a time (Ast)
2-
--> $DIR/borrowck-closures-two-mut.rs:14:24
3-
|
4-
LL | let c1 = to_fn_mut(|| x = 4);
5-
| -- - previous borrow occurs due to use of `x` in closure
6-
| |
7-
| first mutable borrow occurs here
8-
LL | let c2 = to_fn_mut(|| x = 5);
9-
| ^^ - borrow occurs due to use of `x` in closure
10-
| |
11-
| second mutable borrow occurs here
12-
...
13-
LL | }
14-
| - first borrow ends here
15-
16-
error[E0499]: cannot borrow `x` as mutable more than once at a time (Ast)
17-
--> $DIR/borrowck-closures-two-mut.rs:26:24
18-
|
19-
LL | let c1 = to_fn_mut(|| set(&mut x));
20-
| -- - previous borrow occurs due to use of `x` in closure
21-
| |
22-
| first mutable borrow occurs here
23-
LL | let c2 = to_fn_mut(|| set(&mut x));
24-
| ^^ - borrow occurs due to use of `x` in closure
25-
| |
26-
| second mutable borrow occurs here
27-
...
28-
LL | }
29-
| - first borrow ends here
30-
31-
error[E0499]: cannot borrow `x` as mutable more than once at a time (Ast)
32-
--> $DIR/borrowck-closures-two-mut.rs:34:24
33-
|
34-
LL | let c1 = to_fn_mut(|| x = 5);
35-
| -- - previous borrow occurs due to use of `x` in closure
36-
| |
37-
| first mutable borrow occurs here
38-
LL | let c2 = to_fn_mut(|| set(&mut x));
39-
| ^^ - borrow occurs due to use of `x` in closure
40-
| |
41-
| second mutable borrow occurs here
42-
...
43-
LL | }
44-
| - first borrow ends here
45-
46-
error[E0499]: cannot borrow `x` as mutable more than once at a time (Ast)
47-
--> $DIR/borrowck-closures-two-mut.rs:42:24
48-
|
49-
LL | let c1 = to_fn_mut(|| x = 5);
50-
| -- - previous borrow occurs due to use of `x` in closure
51-
| |
52-
| first mutable borrow occurs here
53-
LL | let c2 = to_fn_mut(|| { let _y = to_fn_mut(|| set(&mut x)); }); // (nested closure)
54-
| ^^ - borrow occurs due to use of `x` in closure
55-
| |
56-
| second mutable borrow occurs here
57-
...
58-
LL | }
59-
| - first borrow ends here
60-
61-
error[E0499]: cannot borrow `x` as mutable more than once at a time (Ast)
62-
--> $DIR/borrowck-closures-two-mut.rs:55:24
63-
|
64-
LL | let c1 = to_fn_mut(|| set(&mut *x.f));
65-
| -- - previous borrow occurs due to use of `x` in closure
66-
| |
67-
| first mutable borrow occurs here
68-
LL | let c2 = to_fn_mut(|| set(&mut *x.f));
69-
| ^^ - borrow occurs due to use of `x` in closure
70-
| |
71-
| second mutable borrow occurs here
72-
...
73-
LL | }
74-
| - first borrow ends here
75-
76-
error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir)
77-
--> $DIR/borrowck-closures-two-mut.rs:14:24
1+
error[E0499]: cannot borrow `x` as mutable more than once at a time
2+
--> $DIR/borrowck-closures-two-mut.rs:12:24
783
|
794
LL | let c1 = to_fn_mut(|| x = 4);
805
| -- - first borrow occurs due to use of `x` in closure
@@ -84,12 +9,11 @@ LL | let c2 = to_fn_mut(|| x = 5);
849
| ^^ - second borrow occurs due to use of `x` in closure
8510
| |
8611
| second mutable borrow occurs here
87-
LL |
8812
LL | drop((c1, c2));
8913
| -- first borrow later used here
9014

91-
error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir)
92-
--> $DIR/borrowck-closures-two-mut.rs:26:24
15+
error[E0499]: cannot borrow `x` as mutable more than once at a time
16+
--> $DIR/borrowck-closures-two-mut.rs:23:24
9317
|
9418
LL | let c1 = to_fn_mut(|| set(&mut x));
9519
| -- - first borrow occurs due to use of `x` in closure
@@ -99,12 +23,11 @@ LL | let c2 = to_fn_mut(|| set(&mut x));
9923
| ^^ - second borrow occurs due to use of `x` in closure
10024
| |
10125
| second mutable borrow occurs here
102-
LL |
10326
LL | drop((c1, c2));
10427
| -- first borrow later used here
10528

106-
error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir)
107-
--> $DIR/borrowck-closures-two-mut.rs:34:24
29+
error[E0499]: cannot borrow `x` as mutable more than once at a time
30+
--> $DIR/borrowck-closures-two-mut.rs:30:24
10831
|
10932
LL | let c1 = to_fn_mut(|| x = 5);
11033
| -- - first borrow occurs due to use of `x` in closure
@@ -114,12 +37,11 @@ LL | let c2 = to_fn_mut(|| set(&mut x));
11437
| ^^ - second borrow occurs due to use of `x` in closure
11538
| |
11639
| second mutable borrow occurs here
117-
LL |
11840
LL | drop((c1, c2));
11941
| -- first borrow later used here
12042

121-
error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir)
122-
--> $DIR/borrowck-closures-two-mut.rs:42:24
43+
error[E0499]: cannot borrow `x` as mutable more than once at a time
44+
--> $DIR/borrowck-closures-two-mut.rs:37:24
12345
|
12446
LL | let c1 = to_fn_mut(|| x = 5);
12547
| -- - 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
12951
| ^^ - second borrow occurs due to use of `x` in closure
13052
| |
13153
| second mutable borrow occurs here
132-
...
54+
LL |
13355
LL | drop((c1, c2));
13456
| -- first borrow later used here
13557

136-
error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir)
137-
--> $DIR/borrowck-closures-two-mut.rs:55:24
58+
error[E0499]: cannot borrow `x` as mutable more than once at a time
59+
--> $DIR/borrowck-closures-two-mut.rs:49:24
13860
|
13961
LL | let c1 = to_fn_mut(|| set(&mut *x.f));
14062
| -- - first borrow occurs due to use of `x` in closure
@@ -144,10 +66,10 @@ LL | let c2 = to_fn_mut(|| set(&mut *x.f));
14466
| ^^ - second borrow occurs due to use of `x` in closure
14567
| |
14668
| second mutable borrow occurs here
147-
...
69+
LL |
14870
LL | drop((c1, c2));
14971
| -- first borrow later used here
15072

151-
error: aborting due to 10 previous errors
73+
error: aborting due to 5 previous errors
15274

15375
For more information about this error, try `rustc --explain E0499`.
+1-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
// compile-flags: -Z borrowck=compare
2-
31
fn main() {
42
let mut x = Box::new(0);
53
let _u = x; // error shouldn't note this move
64
x = Box::new(1);
75
drop(x);
8-
let _ = (1,x); //~ ERROR use of moved value: `x` (Ast)
9-
//~^ ERROR use of moved value: `x` (Mir)
6+
let _ = (1,x); //~ ERROR use of moved value: `x`
107
}
+3-13
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
1-
error[E0382]: use of moved value: `x` (Ast)
2-
--> $DIR/borrowck-reinit.rs:8:16
3-
|
4-
LL | drop(x);
5-
| - value moved here
6-
LL | let _ = (1,x);
7-
| ^ value used here after move
8-
|
9-
= note: move occurs because `x` has type `std::boxed::Box<i32>`, which does not implement the `Copy` trait
10-
11-
error[E0382]: use of moved value: `x` (Mir)
12-
--> $DIR/borrowck-reinit.rs:8:16
1+
error[E0382]: use of moved value: `x`
2+
--> $DIR/borrowck-reinit.rs:6:16
133
|
144
LL | let mut x = Box::new(0);
155
| ----- move occurs because `x` has type `std::boxed::Box<i32>`, which does not implement the `Copy` trait
@@ -19,6 +9,6 @@ LL | drop(x);
199
LL | let _ = (1,x);
2010
| ^ value used here after move
2111

22-
error: aborting due to 2 previous errors
12+
error: aborting due to previous error
2313

2414
For more information about this error, try `rustc --explain E0382`.

src/test/ui/borrowck/borrowck-storage-dead.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// compile-flags: -Z borrowck=compare
2-
31
fn ok() {
42
loop {
53
let _x = 1;
@@ -15,8 +13,7 @@ fn also_ok() {
1513
fn fail() {
1614
loop {
1715
let x: i32;
18-
let _ = x + 1; //~ERROR (Ast) [E0381]
19-
//~^ ERROR (Mir) [E0381]
16+
let _ = x + 1; //~ERROR [E0381]
2017
}
2118
}
2219

0 commit comments

Comments
 (0)