Skip to content

Commit 92ef0c4

Browse files
committed
Make test robust to NLL, in sense of ensuring borrows extend to something approximating lexical scope.
1 parent 653da4f commit 92ef0c4

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

src/test/ui/borrowck/borrowck-box-insensitivity.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,36 +63,36 @@ fn move_after_borrow() {
6363
let _y = a.y;
6464
//~^ ERROR cannot move
6565
//~| move out of
66+
use_imm(_x);
6667
}
67-
6868
fn copy_after_mut_borrow() {
6969
let mut a: Box<_> = box A { x: box 0, y: 1 };
7070
let _x = &mut a.x;
7171
let _y = a.y; //~ ERROR cannot use
72+
use_mut(_x);
7273
}
73-
7474
fn move_after_mut_borrow() {
7575
let mut a: Box<_> = box B { x: box 0, y: box 1 };
7676
let _x = &mut a.x;
7777
let _y = a.y;
7878
//~^ ERROR cannot move
7979
//~| move out of
80+
use_mut(_x);
8081
}
81-
8282
fn borrow_after_mut_borrow() {
8383
let mut a: Box<_> = box A { x: box 0, y: 1 };
8484
let _x = &mut a.x;
8585
let _y = &a.y; //~ ERROR cannot borrow
8686
//~^ immutable borrow occurs here (via `a.y`)
87+
use_mut(_x);
8788
}
88-
8989
fn mut_borrow_after_borrow() {
9090
let mut a: Box<_> = box A { x: box 0, y: 1 };
9191
let _x = &a.x;
9292
let _y = &mut a.y; //~ ERROR cannot borrow
9393
//~^ mutable borrow occurs here (via `a.y`)
94+
use_imm(_x);
9495
}
95-
9696
fn copy_after_move_nested() {
9797
let a: Box<_> = box C { x: box A { x: box 0, y: 1 }, y: 2 };
9898
let _x = a.x.x;
@@ -124,38 +124,38 @@ fn move_after_borrow_nested() {
124124
let _y = a.y;
125125
//~^ ERROR cannot move
126126
//~| move out of
127+
use_imm(_x);
127128
}
128-
129129
fn copy_after_mut_borrow_nested() {
130130
let mut a: Box<_> = box C { x: box A { x: box 0, y: 1 }, y: 2 };
131131
let _x = &mut a.x.x;
132132
let _y = a.y; //~ ERROR cannot use
133+
use_mut(_x);
133134
}
134-
135135
fn move_after_mut_borrow_nested() {
136136
let mut a: Box<_> = box D { x: box A { x: box 0, y: 1 }, y: box 2 };
137137
let _x = &mut a.x.x;
138138
let _y = a.y;
139139
//~^ ERROR cannot move
140140
//~| move out of
141+
use_mut(_x);
141142
}
142-
143143
fn borrow_after_mut_borrow_nested() {
144144
let mut a: Box<_> = box C { x: box A { x: box 0, y: 1 }, y: 2 };
145145
let _x = &mut a.x.x;
146146
//~^ mutable borrow occurs here
147147
let _y = &a.y; //~ ERROR cannot borrow
148148
//~^ immutable borrow occurs here
149+
use_mut(_x);
149150
}
150-
151151
fn mut_borrow_after_borrow_nested() {
152152
let mut a: Box<_> = box C { x: box A { x: box 0, y: 1 }, y: 2 };
153153
let _x = &a.x.x;
154154
//~^ immutable borrow occurs here
155155
let _y = &mut a.y; //~ ERROR cannot borrow
156156
//~^ mutable borrow occurs here
157+
use_imm(_x);
157158
}
158-
159159
#[rustc_error]
160160
fn main() {
161161
copy_after_move();
@@ -180,3 +180,6 @@ fn main() {
180180
borrow_after_mut_borrow_nested();
181181
mut_borrow_after_borrow_nested();
182182
}
183+
184+
fn use_mut<T>(_: &mut T) { }
185+
fn use_imm<T>(_: &T) { }

src/test/ui/borrowck/borrowck-box-insensitivity.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ LL | let _x = &mut a.x;
6262
| --- mutable borrow occurs here (via `a.x`)
6363
LL | let _y = &a.y; //~ ERROR cannot borrow
6464
| ^^^ immutable borrow occurs here (via `a.y`)
65-
LL | //~^ immutable borrow occurs here (via `a.y`)
65+
...
6666
LL | }
6767
| - mutable borrow ends here
6868

@@ -73,7 +73,7 @@ LL | let _x = &a.x;
7373
| --- immutable borrow occurs here (via `a.x`)
7474
LL | let _y = &mut a.y; //~ ERROR cannot borrow
7575
| ^^^ mutable borrow occurs here (via `a.y`)
76-
LL | //~^ mutable borrow occurs here (via `a.y`)
76+
...
7777
LL | }
7878
| - immutable borrow ends here
7979

@@ -143,7 +143,7 @@ LL | let _x = &mut a.x.x;
143143
LL | //~^ mutable borrow occurs here
144144
LL | let _y = &a.y; //~ ERROR cannot borrow
145145
| ^^^ immutable borrow occurs here
146-
LL | //~^ immutable borrow occurs here
146+
...
147147
LL | }
148148
| - mutable borrow ends here
149149

@@ -155,7 +155,7 @@ LL | let _x = &a.x.x;
155155
LL | //~^ immutable borrow occurs here
156156
LL | let _y = &mut a.y; //~ ERROR cannot borrow
157157
| ^^^ mutable borrow occurs here
158-
LL | //~^ mutable borrow occurs here
158+
...
159159
LL | }
160160
| - immutable borrow ends here
161161

0 commit comments

Comments
 (0)