Skip to content

Commit c7041a6

Browse files
committed
Updated the most glaring instances of weak tests w.r.t. NLL that came from rust-lang#53196.
See also the bulletpoint list on rust-lang#53351.
1 parent a573305 commit c7041a6

File tree

45 files changed

+626
-130
lines changed

Some content is hidden

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

45 files changed

+626
-130
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
error[E0505]: cannot move out of `x` because it is borrowed
2+
--> $DIR/borrow-tuple-fields.rs:22:13
3+
|
4+
LL | let r = &x.0;
5+
| ---- borrow of `x.0` occurs here
6+
LL | let y = x; //~ ERROR cannot move out of `x` because it is borrowed
7+
| ^ move out of `x` occurs here
8+
LL |
9+
LL | r.use_ref();
10+
| - borrow later used here
11+
12+
error[E0502]: cannot borrow `x.0` as mutable because it is also borrowed as immutable
13+
--> $DIR/borrow-tuple-fields.rs:28:13
14+
|
15+
LL | let a = &x.0;
16+
| ---- immutable borrow occurs here
17+
LL | let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable because it is also borrowed as
18+
| ^^^^^^^^ mutable borrow occurs here
19+
LL | a.use_ref();
20+
| - borrow later used here
21+
22+
error[E0499]: cannot borrow `x.0` as mutable more than once at a time
23+
--> $DIR/borrow-tuple-fields.rs:33:13
24+
|
25+
LL | let a = &mut x.0;
26+
| -------- first mutable borrow occurs here
27+
LL | let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable more than once at a time
28+
| ^^^^^^^^ second mutable borrow occurs here
29+
LL | a.use_ref();
30+
| - borrow later used here
31+
32+
error[E0505]: cannot move out of `x` because it is borrowed
33+
--> $DIR/borrow-tuple-fields.rs:38:13
34+
|
35+
LL | let r = &x.0;
36+
| ---- borrow of `x.0` occurs here
37+
LL | let y = x; //~ ERROR cannot move out of `x` because it is borrowed
38+
| ^ move out of `x` occurs here
39+
LL | r.use_ref();
40+
| - borrow later used here
41+
42+
error[E0502]: cannot borrow `x.0` as mutable because it is also borrowed as immutable
43+
--> $DIR/borrow-tuple-fields.rs:43:13
44+
|
45+
LL | let a = &x.0;
46+
| ---- immutable borrow occurs here
47+
LL | let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable because it is also borrowed as
48+
| ^^^^^^^^ mutable borrow occurs here
49+
LL | a.use_ref();
50+
| - borrow later used here
51+
52+
error[E0499]: cannot borrow `x.0` as mutable more than once at a time
53+
--> $DIR/borrow-tuple-fields.rs:48:13
54+
|
55+
LL | let a = &mut x.0;
56+
| -------- first mutable borrow occurs here
57+
LL | let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable more than once at a time
58+
| ^^^^^^^^ second mutable borrow occurs here
59+
LL | a.use_mut();
60+
| - borrow later used here
61+
62+
error: aborting due to 6 previous errors
63+
64+
Some errors occurred: E0499, E0502, E0505.
65+
For more information about an error, try `rustc --explain E0499`.

src/test/ui/borrowck/borrow-tuple-fields.rs

+12-3
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// ignore-compare-mode-nll
12-
1311
#![feature(box_syntax)]
1412

13+
14+
1515
struct Foo(Box<isize>, isize);
1616

1717
struct Bar(isize, isize);
@@ -21,24 +21,33 @@ fn main() {
2121
let r = &x.0;
2222
let y = x; //~ ERROR cannot move out of `x` because it is borrowed
2323

24+
r.use_ref();
25+
2426
let mut x = (1, 2);
2527
let a = &x.0;
2628
let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable because it is also borrowed as
29+
a.use_ref();
2730

2831
let mut x = (1, 2);
2932
let a = &mut x.0;
3033
let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable more than once at a time
31-
34+
a.use_ref();
3235

3336
let x = Foo(box 1, 2);
3437
let r = &x.0;
3538
let y = x; //~ ERROR cannot move out of `x` because it is borrowed
39+
r.use_ref();
3640

3741
let mut x = Bar(1, 2);
3842
let a = &x.0;
3943
let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable because it is also borrowed as
44+
a.use_ref();
4045

4146
let mut x = Bar(1, 2);
4247
let a = &mut x.0;
4348
let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable more than once at a time
49+
a.use_mut();
4450
}
51+
52+
trait Fake { fn use_mut(&mut self) { } fn use_ref(&self) { } }
53+
impl<T> Fake for T { }

src/test/ui/borrowck/borrow-tuple-fields.stderr

+6-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | let y = x; //~ ERROR cannot move out of `x` because it is borrowed
77
| ^ move out of `x` occurs here
88

99
error[E0502]: cannot borrow `x.0` as mutable because it is also borrowed as immutable
10-
--> $DIR/borrow-tuple-fields.rs:26:18
10+
--> $DIR/borrow-tuple-fields.rs:28:18
1111
|
1212
LL | let a = &x.0;
1313
| --- immutable borrow occurs here
@@ -18,7 +18,7 @@ LL | }
1818
| - immutable borrow ends here
1919

2020
error[E0499]: cannot borrow `x.0` as mutable more than once at a time
21-
--> $DIR/borrow-tuple-fields.rs:30:18
21+
--> $DIR/borrow-tuple-fields.rs:33:18
2222
|
2323
LL | let a = &mut x.0;
2424
| --- first mutable borrow occurs here
@@ -29,15 +29,15 @@ LL | }
2929
| - first borrow ends here
3030

3131
error[E0505]: cannot move out of `x` because it is borrowed
32-
--> $DIR/borrow-tuple-fields.rs:35:9
32+
--> $DIR/borrow-tuple-fields.rs:38:9
3333
|
3434
LL | let r = &x.0;
3535
| --- borrow of `x.0` occurs here
3636
LL | let y = x; //~ ERROR cannot move out of `x` because it is borrowed
3737
| ^ move out of `x` occurs here
3838

3939
error[E0502]: cannot borrow `x.0` as mutable because it is also borrowed as immutable
40-
--> $DIR/borrow-tuple-fields.rs:39:18
40+
--> $DIR/borrow-tuple-fields.rs:43:18
4141
|
4242
LL | let a = &x.0;
4343
| --- immutable borrow occurs here
@@ -48,12 +48,13 @@ LL | }
4848
| - immutable borrow ends here
4949

5050
error[E0499]: cannot borrow `x.0` as mutable more than once at a time
51-
--> $DIR/borrow-tuple-fields.rs:43:18
51+
--> $DIR/borrow-tuple-fields.rs:48:18
5252
|
5353
LL | let a = &mut x.0;
5454
| --- first mutable borrow occurs here
5555
LL | let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable more than once at a time
5656
| ^^^ second mutable borrow occurs here
57+
LL | a.use_mut();
5758
LL | }
5859
| - first borrow ends here
5960

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error[E0499]: cannot borrow `*x` as mutable more than once at a time
2+
--> $DIR/borrowck-borrow-mut-object-twice.rs:23:5
3+
|
4+
LL | let y = x.f1();
5+
| - first mutable borrow occurs here
6+
LL | x.f2(); //~ ERROR cannot borrow `*x` as mutable
7+
| ^ second mutable borrow occurs here
8+
LL | y.use_ref();
9+
| - borrow later used here
10+
11+
error: aborting due to previous error
12+
13+
For more information about this error, try `rustc --explain E0499`.

src/test/ui/borrowck/borrowck-borrow-mut-object-twice.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,23 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// ignore-compare-mode-nll
12-
1311
// Check that `&mut` objects cannot be borrowed twice, just like
1412
// other `&mut` pointers.
1513

14+
15+
1616
trait Foo {
1717
fn f1(&mut self) -> &();
1818
fn f2(&mut self);
1919
}
2020

2121
fn test(x: &mut Foo) {
22-
let _y = x.f1();
22+
let y = x.f1();
2323
x.f2(); //~ ERROR cannot borrow `*x` as mutable
24+
y.use_ref();
2425
}
2526

2627
fn main() {}
28+
29+
trait Fake { fn use_mut(&mut self) { } fn use_ref(&self) { } }
30+
impl<T> Fake for T { }

src/test/ui/borrowck/borrowck-borrow-mut-object-twice.stderr

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
error[E0499]: cannot borrow `*x` as mutable more than once at a time
22
--> $DIR/borrowck-borrow-mut-object-twice.rs:23:5
33
|
4-
LL | let _y = x.f1();
5-
| - first mutable borrow occurs here
4+
LL | let y = x.f1();
5+
| - first mutable borrow occurs here
66
LL | x.f2(); //~ ERROR cannot borrow `*x` as mutable
77
| ^ second mutable borrow occurs here
8+
LL | y.use_ref();
89
LL | }
910
| - first borrow ends here
1011

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error[E0502]: cannot borrow `this.x` as mutable because it is also borrowed as immutable
2+
--> $DIR/borrowck-closures-unique-imm.rs:23:9
3+
|
4+
LL | let p = &this.x;
5+
| ------- immutable borrow occurs here
6+
LL | &mut this.x; //~ ERROR cannot borrow
7+
| ^^^^^^^^^^^ mutable borrow occurs here
8+
LL | p.use_ref();
9+
| - borrow later used here
10+
11+
error: aborting due to previous error
12+
13+
For more information about this error, try `rustc --explain E0502`.

src/test/ui/borrowck/borrowck-closures-unique-imm.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// ignore-compare-mode-nll
11+
1212

1313
struct Foo {
1414
x: isize,
@@ -21,6 +21,10 @@ pub fn main() {
2121
let mut r = || {
2222
let p = &this.x;
2323
&mut this.x; //~ ERROR cannot borrow
24+
p.use_ref();
2425
};
2526
r()
2627
}
28+
29+
trait Fake { fn use_mut(&mut self) { } fn use_ref(&self) { } }
30+
impl<T> Fake for T { }

src/test/ui/borrowck/borrowck-closures-unique-imm.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | let p = &this.x;
55
| ------ immutable borrow occurs here
66
LL | &mut this.x; //~ ERROR cannot borrow
77
| ^^^^^^ mutable borrow occurs here
8+
LL | p.use_ref();
89
LL | };
910
| - immutable borrow ends here
1011

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error[E0505]: cannot move out of `x` because it is borrowed
2+
--> $DIR/borrowck-issue-2657-1.rs:19:18
3+
|
4+
LL | Some(ref _y) => {
5+
| ------ borrow of `x.0` occurs here
6+
LL | let _a = x; //~ ERROR cannot move
7+
| ^ move out of `x` occurs here
8+
LL | _y.use_ref();
9+
| -- borrow later used here
10+
11+
error: aborting due to previous error
12+
13+
For more information about this error, try `rustc --explain E0505`.

src/test/ui/borrowck/borrowck-issue-2657-1.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,20 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// ignore-compare-mode-nll
12-
1311
#![feature(box_syntax)]
1412

13+
14+
1515
fn main() {
1616
let x: Option<Box<_>> = Some(box 1);
1717
match x {
1818
Some(ref _y) => {
1919
let _a = x; //~ ERROR cannot move
20+
_y.use_ref();
2021
}
2122
_ => {}
2223
}
2324
}
25+
26+
trait Fake { fn use_mut(&mut self) { } fn use_ref(&self) { } }
27+
impl<T> Fake for T { }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
error[E0505]: cannot move out of `v` because it is borrowed
2+
--> $DIR/borrowck-loan-blocks-move-cc.rs:24:19
3+
|
4+
LL | let w = &v;
5+
| -- borrow of `v` occurs here
6+
LL | thread::spawn(move|| {
7+
| ^^^^^^ move out of `v` occurs here
8+
LL | println!("v={}", *v);
9+
| - move occurs due to use in closure
10+
...
11+
LL | w.use_ref();
12+
| - borrow later used here
13+
14+
error[E0505]: cannot move out of `v` because it is borrowed
15+
--> $DIR/borrowck-loan-blocks-move-cc.rs:34:19
16+
|
17+
LL | let w = &v;
18+
| -- borrow of `v` occurs here
19+
LL | thread::spawn(move|| {
20+
| ^^^^^^ move out of `v` occurs here
21+
LL | println!("v={}", *v);
22+
| - move occurs due to use in closure
23+
...
24+
LL | w.use_ref();
25+
| - borrow later used here
26+
27+
error: aborting due to 2 previous errors
28+
29+
For more information about this error, try `rustc --explain E0505`.

src/test/ui/borrowck/borrowck-loan-blocks-move-cc.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,38 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// ignore-compare-mode-nll
12-
1311
#![feature(box_syntax)]
1412

1513
use std::thread;
1614

15+
16+
1717
fn borrow<F>(v: &isize, f: F) where F: FnOnce(&isize) {
1818
f(v);
1919
}
2020

2121
fn box_imm() {
2222
let v: Box<_> = box 3;
23-
let _w = &v;
23+
let w = &v;
2424
thread::spawn(move|| {
2525
println!("v={}", *v);
2626
//~^ ERROR cannot move `v` into closure
2727
});
28+
w.use_ref();
2829
}
2930

3031
fn box_imm_explicit() {
3132
let v: Box<_> = box 3;
32-
let _w = &v;
33+
let w = &v;
3334
thread::spawn(move|| {
3435
println!("v={}", *v);
3536
//~^ ERROR cannot move
3637
});
38+
w.use_ref();
3739
}
3840

3941
fn main() {
4042
}
43+
44+
trait Fake { fn use_mut(&mut self) { } fn use_ref(&self) { } }
45+
impl<T> Fake for T { }

src/test/ui/borrowck/borrowck-loan-blocks-move-cc.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
error[E0504]: cannot move `v` into closure because it is borrowed
22
--> $DIR/borrowck-loan-blocks-move-cc.rs:25:27
33
|
4-
LL | let _w = &v;
5-
| - borrow of `v` occurs here
4+
LL | let w = &v;
5+
| - borrow of `v` occurs here
66
LL | thread::spawn(move|| {
77
LL | println!("v={}", *v);
88
| ^ move into closure occurs here
99

1010
error[E0504]: cannot move `v` into closure because it is borrowed
11-
--> $DIR/borrowck-loan-blocks-move-cc.rs:34:27
11+
--> $DIR/borrowck-loan-blocks-move-cc.rs:35:27
1212
|
13-
LL | let _w = &v;
14-
| - borrow of `v` occurs here
13+
LL | let w = &v;
14+
| - borrow of `v` occurs here
1515
LL | thread::spawn(move|| {
1616
LL | println!("v={}", *v);
1717
| ^ move into closure occurs here

0 commit comments

Comments
 (0)