Skip to content

Commit 6231720

Browse files
committed
Rollup merge of rust-lang#55700 - pnkfelix:issue-55533-update-ui-tests-wrt-nll, r=davidtwco
Update ui tests with respect to NLL Fix rust-lang#55533
2 parents 1ea1a42 + fff9dde commit 6231720

Some content is hidden

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

43 files changed

+532
-254
lines changed

src/test/ui/binop/binop-move-semantics.nll.stderr

+25-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,29 @@ LL | x.clone(); //~ ERROR: use of moved value
2020
|
2121
= note: move occurs because `x` has type `T`, which does not implement the `Copy` trait
2222

23+
error[E0505]: cannot move out of `x` because it is borrowed
24+
--> $DIR/binop-move-semantics.rs:31:5
25+
|
26+
LL | let m = &x;
27+
| -- borrow of `x` occurs here
28+
...
29+
LL | x //~ ERROR: cannot move out of `x` because it is borrowed
30+
| ^ move out of `x` occurs here
31+
...
32+
LL | use_mut(n); use_imm(m);
33+
| - borrow later used here
34+
35+
error[E0505]: cannot move out of `y` because it is borrowed
36+
--> $DIR/binop-move-semantics.rs:33:5
37+
|
38+
LL | let n = &mut y;
39+
| ------ borrow of `y` occurs here
40+
...
41+
LL | y; //~ ERROR: cannot move out of `y` because it is borrowed
42+
| ^ move out of `y` occurs here
43+
LL | use_mut(n); use_imm(m);
44+
| - borrow later used here
45+
2346
error[E0507]: cannot move out of borrowed content
2447
--> $DIR/binop-move-semantics.rs:40:5
2548
|
@@ -62,7 +85,7 @@ LL | | &mut f; //~ ERROR: cannot borrow `f` as mutable because it is also b
6285
| | immutable borrow later used here
6386
| mutable borrow occurs here
6487

65-
error: aborting due to 6 previous errors
88+
error: aborting due to 8 previous errors
6689

67-
Some errors occurred: E0382, E0502, E0507.
90+
Some errors occurred: E0382, E0502, E0505, E0507.
6891
For more information about an error, try `rustc --explain E0382`.

src/test/ui/binop/binop-move-semantics.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@ fn move_borrowed<T: Add<Output=()>>(x: T, mut y: T) {
3131
x //~ ERROR: cannot move out of `x` because it is borrowed
3232
+
3333
y; //~ ERROR: cannot move out of `y` because it is borrowed
34+
use_mut(n); use_imm(m);
3435
}
35-
3636
fn illegal_dereference<T: Add<Output=()>>(mut x: T, y: T) {
3737
let m = &mut x;
3838
let n = &y;
3939

4040
*m //~ ERROR: cannot move out of borrowed content
4141
+
4242
*n; //~ ERROR: cannot move out of borrowed content
43+
use_imm(n); use_mut(m);
4344
}
44-
4545
struct Foo;
4646

4747
impl<'a, 'b> Add<&'b Foo> for &'a mut Foo {
@@ -73,3 +73,6 @@ fn immut_plus_mut() {
7373
}
7474

7575
fn main() {}
76+
77+
fn use_mut<T>(_: &mut T) { }
78+
fn use_imm<T>(_: &T) { }
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,32 @@
11
error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference
2-
--> $DIR/borrowck-closures-mut-of-imm.rs:23:21
2+
--> $DIR/borrowck-closures-mut-of-imm.rs:23:25
33
|
4-
LL | let c1 = || set(&mut *x);
5-
| ^^^^^^^ cannot borrow as mutable
4+
LL | let mut c1 = || set(&mut *x);
5+
| ^^^^^^^ cannot borrow as mutable
66

77
error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference
8-
--> $DIR/borrowck-closures-mut-of-imm.rs:25:21
8+
--> $DIR/borrowck-closures-mut-of-imm.rs:25:25
99
|
10-
LL | let c2 = || set(&mut *x);
11-
| ^^^^^^^ cannot borrow as mutable
10+
LL | let mut c2 = || set(&mut *x);
11+
| ^^^^^^^ cannot borrow as mutable
1212

13-
error: aborting due to 2 previous errors
13+
error[E0524]: two closures require unique access to `x` at the same time
14+
--> $DIR/borrowck-closures-mut-of-imm.rs:25:18
15+
|
16+
LL | let mut c1 = || set(&mut *x);
17+
| -- - first borrow occurs due to use of `x` in closure
18+
| |
19+
| first closure is constructed here
20+
LL | //~^ ERROR cannot borrow
21+
LL | let mut c2 = || set(&mut *x);
22+
| ^^ - second borrow occurs due to use of `x` in closure
23+
| |
24+
| second closure is constructed here
25+
...
26+
LL | c2(); c1();
27+
| -- first borrow later used here
28+
29+
error: aborting due to 3 previous errors
1430

15-
For more information about this error, try `rustc --explain E0596`.
31+
Some errors occurred: E0524, E0596.
32+
For more information about an error, try `rustc --explain E0524`.

src/test/ui/borrowck/borrowck-closures-mut-of-imm.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ fn set(x: &mut isize) {
2020
}
2121

2222
fn a(x: &isize) {
23-
let c1 = || set(&mut *x);
23+
let mut c1 = || set(&mut *x);
2424
//~^ ERROR cannot borrow
25-
let c2 = || set(&mut *x);
25+
let mut c2 = || set(&mut *x);
2626
//~^ ERROR cannot borrow
2727
//~| ERROR two closures require unique access to `x` at the same time
28+
c2(); c1();
2829
}
2930

3031
fn main() {

src/test/ui/borrowck/borrowck-closures-mut-of-imm.stderr

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
error[E0524]: two closures require unique access to `x` at the same time
2-
--> $DIR/borrowck-closures-mut-of-imm.rs:25:14
2+
--> $DIR/borrowck-closures-mut-of-imm.rs:25:18
33
|
4-
LL | let c1 = || set(&mut *x);
5-
| -- - previous borrow occurs due to use of `x` in closure
6-
| |
7-
| first closure is constructed here
4+
LL | let mut c1 = || set(&mut *x);
5+
| -- - previous borrow occurs due to use of `x` in closure
6+
| |
7+
| first closure is constructed here
88
LL | //~^ ERROR cannot borrow
9-
LL | let c2 = || set(&mut *x);
10-
| ^^ - borrow occurs due to use of `x` in closure
11-
| |
12-
| second closure is constructed here
9+
LL | let mut c2 = || set(&mut *x);
10+
| ^^ - borrow occurs due to use of `x` in closure
11+
| |
12+
| second closure is constructed here
1313
...
1414
LL | }
1515
| - borrow from first closure ends here
1616

1717
error[E0596]: cannot borrow immutable borrowed content `***x` as mutable
18-
--> $DIR/borrowck-closures-mut-of-imm.rs:23:26
18+
--> $DIR/borrowck-closures-mut-of-imm.rs:23:30
1919
|
20-
LL | let c1 = || set(&mut *x);
21-
| ^^ cannot borrow as mutable
20+
LL | let mut c1 = || set(&mut *x);
21+
| ^^ cannot borrow as mutable
2222

2323
error[E0596]: cannot borrow immutable borrowed content `***x` as mutable
24-
--> $DIR/borrowck-closures-mut-of-imm.rs:25:26
24+
--> $DIR/borrowck-closures-mut-of-imm.rs:25:30
2525
|
26-
LL | let c2 = || set(&mut *x);
27-
| ^^ cannot borrow as mutable
26+
LL | let mut c2 = || set(&mut *x);
27+
| ^^ cannot borrow as mutable
2828

2929
error: aborting due to 3 previous errors
3030

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
error[E0524]: two closures require unique access to `x` at the same time
2+
--> $DIR/borrowck-closures-mut-of-mut.rs:14:18
3+
|
4+
LL | let mut c1 = || set(&mut *x);
5+
| -- - first borrow occurs due to use of `x` in closure
6+
| |
7+
| first closure is constructed here
8+
LL | let mut c2 = || set(&mut *x);
9+
| ^^ - second borrow occurs due to use of `x` in closure
10+
| |
11+
| second closure is constructed here
12+
LL | //~^ ERROR two closures require unique access to `x` at the same time
13+
LL | c2(); c1();
14+
| -- first borrow later used here
15+
16+
error: aborting due to previous error
17+
18+
For more information about this error, try `rustc --explain E0524`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Tests that two closures cannot simultaneously both have mutable
2+
// access to the variable. Related to issue #6801.
3+
4+
fn get(x: &isize) -> isize {
5+
*x
6+
}
7+
8+
fn set(x: &mut isize) {
9+
*x = 4;
10+
}
11+
12+
fn a(x: &mut isize) {
13+
let mut c1 = || set(&mut *x);
14+
let mut c2 = || set(&mut *x);
15+
//~^ ERROR two closures require unique access to `x` at the same time
16+
c2(); c1();
17+
}
18+
19+
fn main() {
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
error[E0524]: two closures require unique access to `x` at the same time
2+
--> $DIR/borrowck-closures-mut-of-mut.rs:14:18
3+
|
4+
LL | let mut c1 = || set(&mut *x);
5+
| -- - previous borrow occurs due to use of `x` in closure
6+
| |
7+
| first closure is constructed here
8+
LL | let mut c2 = || set(&mut *x);
9+
| ^^ - borrow occurs due to use of `x` in closure
10+
| |
11+
| second closure is constructed here
12+
...
13+
LL | }
14+
| - borrow from first closure ends here
15+
16+
error: aborting due to previous error
17+
18+
For more information about this error, try `rustc --explain E0524`.

src/test/ui/borrowck/borrowck-lend-flow-loop.stderr renamed to src/test/ui/borrowck/borrowck-lend-flow-loop.ast.stderr

+11-11
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0502]: cannot borrow `*v` as immutable because `v` is also borrowed as mu
44
LL | let mut x = &mut v;
55
| - mutable borrow occurs here
66
...
7-
LL | borrow(&*v); //~ ERROR cannot borrow
7+
LL | borrow(&*v); //[ast]~ ERROR cannot borrow
88
| ^^ immutable borrow occurs here
99
LL | }
1010
LL | }
@@ -16,7 +16,7 @@ error[E0502]: cannot borrow `*v` as immutable because `v` is also borrowed as mu
1616
LL | let mut x = &mut v;
1717
| - mutable borrow occurs here
1818
LL | for _ in 0..3 {
19-
LL | borrow(&*v); //~ ERROR cannot borrow
19+
LL | borrow(&*v); //[ast]~ ERROR cannot borrow
2020
| ^^ immutable borrow occurs here
2121
...
2222
LL | }
@@ -25,7 +25,7 @@ LL | }
2525
error[E0502]: cannot borrow `*v` as mutable because `v` is also borrowed as immutable
2626
--> $DIR/borrowck-lend-flow-loop.rs:57:25
2727
|
28-
LL | borrow_mut(&mut *v); //~ ERROR cannot borrow
28+
LL | borrow_mut(&mut *v); //[ast]~ ERROR cannot borrow
2929
| ^^ mutable borrow occurs here
3030
LL | _x = &v;
3131
| - immutable borrow occurs here
@@ -36,7 +36,7 @@ LL | }
3636
error[E0502]: cannot borrow `*v` as mutable because `v` is also borrowed as immutable
3737
--> $DIR/borrowck-lend-flow-loop.rs:69:25
3838
|
39-
LL | borrow_mut(&mut *v); //~ ERROR cannot borrow
39+
LL | borrow_mut(&mut *v); //[ast]~ ERROR cannot borrow
4040
| ^^ mutable borrow occurs here
4141
LL | _x = &v;
4242
| - immutable borrow occurs here
@@ -50,7 +50,7 @@ error[E0502]: cannot borrow `*v` as mutable because `v` is also borrowed as immu
5050
LL | _x = &v;
5151
| - immutable borrow occurs here
5252
...
53-
LL | borrow_mut(&mut *v); //~ ERROR cannot borrow
53+
LL | borrow_mut(&mut *v); //[ast]~ ERROR cannot borrow
5454
| ^^ mutable borrow occurs here
5555
LL | }
5656
| - immutable borrow ends here
@@ -61,27 +61,27 @@ error[E0502]: cannot borrow `*v` as mutable because `v` is also borrowed as immu
6161
LL | _x = &v;
6262
| - immutable borrow occurs here
6363
...
64-
LL | borrow_mut(&mut *v); //~ ERROR cannot borrow
64+
LL | borrow_mut(&mut *v); //[ast]~ ERROR cannot borrow
6565
| ^^ mutable borrow occurs here
6666
LL | }
6767
| - immutable borrow ends here
6868

6969
error[E0502]: cannot borrow `*v` as immutable because `v` is also borrowed as mutable
7070
--> $DIR/borrowck-lend-flow-loop.rs:109:17
7171
|
72-
LL | borrow(&*v); //~ ERROR cannot borrow
72+
LL | borrow(&*v); //[ast]~ ERROR cannot borrow
7373
| ^^ immutable borrow occurs here
74-
LL | if cond2 {
75-
LL | x = &mut v; //~ ERROR cannot borrow
74+
...
75+
LL | x = &mut v; //[ast]~ ERROR cannot borrow
7676
| - mutable borrow occurs here
7777
...
7878
LL | }
7979
| - mutable borrow ends here
8080

8181
error[E0499]: cannot borrow `v` as mutable more than once at a time
82-
--> $DIR/borrowck-lend-flow-loop.rs:111:22
82+
--> $DIR/borrowck-lend-flow-loop.rs:112:22
8383
|
84-
LL | x = &mut v; //~ ERROR cannot borrow
84+
LL | x = &mut v; //[ast]~ ERROR cannot borrow
8585
| ^ mutable borrow starts here in previous iteration of loop
8686
...
8787
LL | }

src/test/ui/borrowck/borrowck-lend-flow-loop.nll.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ error[E0502]: cannot borrow `*v` as immutable because it is also borrowed as mut
44
LL | let mut x = &mut v;
55
| ------ mutable borrow occurs here
66
LL | for _ in 0..3 {
7-
LL | borrow(&*v); //~ ERROR cannot borrow
7+
LL | borrow(&*v); //[ast]~ ERROR cannot borrow
88
| ^^^ immutable borrow occurs here
9-
LL | }
9+
...
1010
LL | *x = box 5;
1111
| -- mutable borrow used here, in later iteration of loop
1212

@@ -15,10 +15,10 @@ error[E0502]: cannot borrow `*v` as immutable because it is also borrowed as mut
1515
|
1616
LL | **x += 1;
1717
| -------- mutable borrow used here, in later iteration of loop
18-
LL | borrow(&*v); //~ ERROR cannot borrow
18+
LL | borrow(&*v); //[ast]~ ERROR cannot borrow
1919
| ^^^ immutable borrow occurs here
20-
LL | if cond2 {
21-
LL | x = &mut v; //~ ERROR cannot borrow
20+
...
21+
LL | x = &mut v; //[ast]~ ERROR cannot borrow
2222
| ------ mutable borrow occurs here
2323

2424
error: aborting due to 2 previous errors

0 commit comments

Comments
 (0)