Skip to content

Commit 58d9280

Browse files
committed
Update tests for restrictive two-phase borrows
1 parent aa3780b commit 58d9280

11 files changed

+20
-154
lines changed

src/test/ui/borrowck/borrowck-for-loop-head-linkage.nll.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ LL | for &x in &vector {
88
| immutable borrow later used here
99
LL | let cap = vector.capacity();
1010
LL | vector.extend(repeat(0)); //~ ERROR cannot borrow
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here
11+
| ^^^^^^ mutable borrow occurs here
1212

1313
error[E0502]: cannot borrow `vector` as mutable because it is also borrowed as immutable
1414
--> $DIR/borrowck-for-loop-head-linkage.rs:8:9

src/test/ui/borrowck/borrowck-object-lifetime.nll.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0502]: cannot borrow `*x` as mutable because it is also borrowed as immut
44
LL | let y = x.borrowed();
55
| - immutable borrow occurs here
66
LL | let z = x.mut_borrowed(); //~ ERROR cannot borrow
7-
| ^^^^^^^^^^^^^^^^ mutable borrow occurs here
7+
| ^ mutable borrow occurs here
88
LL | y.use_ref();
99
| - immutable borrow later used here
1010

src/test/ui/borrowck/two-phase-cannot-nest-mut-self-calls.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | vec.get({
77
| immutable borrow occurs here
88
LL |
99
LL | vec.push(2);
10-
| ^^^^^^^^^^^ mutable borrow occurs here
10+
| ^^^ mutable borrow occurs here
1111

1212
error: aborting due to previous error
1313

src/test/ui/borrowck/two-phase-reservation-sharing-interference-2.rs

+2-13
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,12 @@
22

33
// This is similar to two-phase-reservation-sharing-interference.rs
44
// in that it shows a reservation that overlaps with a shared borrow.
5-
//
6-
// Currently, this test fails with lexical lifetimes, but succeeds
7-
// with non-lexical lifetimes. (The reason is because the activation
8-
// of the mutable borrow ends up overlapping with a lexically-scoped
9-
// shared borrow; but a non-lexical shared borrow can end before the
10-
// activation occurs.)
11-
//
12-
// So this test is just making a note of the current behavior.
135

14-
#![feature(rustc_attrs)]
15-
16-
#[rustc_error]
17-
fn main() { //~ ERROR compilation successful
6+
fn main() {
187
let mut v = vec![0, 1, 2];
198
let shared = &v;
209

21-
v.push(shared.len());
10+
v.push(shared.len()); //~ ERROR cannot borrow `v` as mutable
2211

2312
assert_eq!(v, [0, 1, 2, 3]);
2413
}
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
error: compilation successful
2-
--> $DIR/two-phase-reservation-sharing-interference-2.rs:17:1
1+
error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable
2+
--> $DIR/two-phase-reservation-sharing-interference-2.rs:10:5
33
|
4-
LL | / fn main() { //~ ERROR compilation successful
5-
LL | | let mut v = vec![0, 1, 2];
6-
LL | | let shared = &v;
7-
LL | |
8-
... |
9-
LL | | assert_eq!(v, [0, 1, 2, 3]);
10-
LL | | }
11-
| |_^
4+
LL | let shared = &v;
5+
| -- immutable borrow occurs here
6+
LL |
7+
LL | v.push(shared.len()); //~ ERROR cannot borrow `v` as mutable
8+
| ^ ------ immutable borrow later used here
9+
| |
10+
| mutable borrow occurs here
1211

1312
error: aborting due to previous error
1413

14+
For more information about this error, try `rustc --explain E0502`.

src/test/ui/error-codes/E0502.nll.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
error[E0502]: cannot borrow `*a` as mutable because it is also borrowed as immutable
2-
--> $DIR/E0502.rs:4:5
2+
--> $DIR/E0502.rs:4:9
33
|
44
LL | let ref y = a;
55
| ----- immutable borrow occurs here
66
LL | bar(a); //~ ERROR E0502
7-
| ^^^^^^ mutable borrow occurs here
7+
| ^ mutable borrow occurs here
88
LL | y.use_ref();
99
| - immutable borrow later used here
1010

src/test/ui/hashmap-iter-value-lifetime.nll.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | let (_, thing) = my_stuff.iter().next().unwrap();
55
| -------- immutable borrow occurs here
66
LL |
77
LL | my_stuff.clear(); //~ ERROR cannot borrow
8-
| ^^^^^^^^^^^^^^^^ mutable borrow occurs here
8+
| ^^^^^^^^ mutable borrow occurs here
99
LL |
1010
LL | println!("{}", *thing);
1111
| ------ immutable borrow later used here

src/test/ui/hashmap-lifetimes.nll.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0502]: cannot borrow `my_stuff` as mutable because it is also borrowed as
44
LL | let mut it = my_stuff.iter();
55
| -------- immutable borrow occurs here
66
LL | my_stuff.insert(1, 43); //~ ERROR cannot borrow
7-
| ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here
7+
| ^^^^^^^^ mutable borrow occurs here
88
LL | it;
99
| -- immutable borrow later used here
1010

src/test/ui/nll/get_default.nll.stderr

-84
This file was deleted.

src/test/ui/nll/region-ends-after-if-condition.nll.stderr

-39
This file was deleted.

src/test/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.nll.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0502]: cannot borrow `foo` as mutable because it is also borrowed as immu
44
LL | while let Some(Ok(string)) = foo.get() {
55
| --- immutable borrow occurs here
66
LL | foo.mutate();
7-
| ^^^^^^^^^^^^ mutable borrow occurs here
7+
| ^^^ mutable borrow occurs here
88
LL | //~^ ERROR cannot borrow `foo` as mutable
99
LL | println!("foo={:?}", *string);
1010
| ------- immutable borrow later used here

0 commit comments

Comments
 (0)