Skip to content

Commit 0cec659

Browse files
author
Cameron Zwarich
committed
---
yaml --- r: 152358 b: refs/heads/try2 c: 4666792 h: refs/heads/master v: v3
1 parent 184e6d9 commit 0cec659

File tree

3 files changed

+34
-28
lines changed

3 files changed

+34
-28
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 653f57af2085534ced338bd146e2528b81c9fd11
8+
refs/heads/try2: 4666792ac600f4e4e1c09a37b88f40f6125b57b8
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/test/compile-fail/borrowck-field-sensitivity.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
struct A { a: int, b: Box<int> }
1212

13-
fn borrow<T>(_: &T) { }
14-
1513
fn deref_after_move() {
1614
let x = A { a: 1, b: box 2 };
1715
drop(x.b);
@@ -27,35 +25,37 @@ fn deref_after_fu_move() {
2725
fn borrow_after_move() {
2826
let x = A { a: 1, b: box 2 };
2927
drop(x.b);
30-
borrow(&x.b); //~ ERROR use of moved value: `x.b`
28+
let p = &x.b; //~ ERROR use of moved value: `x.b`
29+
drop(**p);
3130
}
3231

3332
fn borrow_after_fu_move() {
3433
let x = A { a: 1, b: box 2 };
3534
let _y = A { a: 3, .. x };
36-
borrow(&x.b); //~ ERROR use of moved value: `x.b`
35+
let p = &x.b; //~ ERROR use of moved value: `x.b`
36+
drop(**p);
3737
}
3838

3939
fn move_after_borrow() {
4040
let x = A { a: 1, b: box 2 };
41-
let y = &x.b;
41+
let p = &x.b;
4242
drop(x.b); //~ ERROR cannot move out of `x.b` because it is borrowed
43-
borrow(&*y);
43+
drop(**p);
4444
}
4545

4646
fn fu_move_after_borrow() {
4747
let x = A { a: 1, b: box 2 };
48-
let y = &x.b;
49-
let _z = A { a: 3, .. x }; //~ ERROR cannot move out of `x.b` because it is borrowed
50-
borrow(&*y);
48+
let p = &x.b;
49+
let _y = A { a: 3, .. x }; //~ ERROR cannot move out of `x.b` because it is borrowed
50+
drop(**p);
5151
}
5252

5353
fn mut_borrow_after_mut_borrow() {
5454
let mut x = A { a: 1, b: box 2 };
55-
let y = &mut x.a;
56-
let z = &mut x.a; //~ ERROR cannot borrow `x.a` as mutable more than once at a time
57-
drop(*y);
58-
drop(*z);
55+
let p = &mut x.a;
56+
let q = &mut x.a; //~ ERROR cannot borrow `x.a` as mutable more than once at a time
57+
drop(*p);
58+
drop(*q);
5959
}
6060

6161
fn move_after_move() {
@@ -107,7 +107,8 @@ fn copy_after_field_assign_after_uninit() {
107107
fn borrow_after_field_assign_after_uninit() {
108108
let mut x: A;
109109
x.a = 1;
110-
borrow(&x.a); //~ ERROR use of possibly uninitialized variable: `x.a`
110+
let p = &x.a; //~ ERROR use of possibly uninitialized variable: `x.a`
111+
drop(*p);
111112
}
112113

113114
fn move_after_field_assign_after_uninit() {

branches/try2/src/test/run-pass/borrowck-field-sensitivity.rs

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
struct A { a: int, b: Box<int> }
1212
struct B { a: Box<int>, b: Box<int> }
1313

14-
fn borrow<T>(_: &T) { }
15-
1614
fn move_after_copy() {
1715
let x = A { a: 1, b: box 2 };
1816
drop(x.a);
@@ -64,21 +62,23 @@ fn fu_copy_after_fu_move() {
6462
fn borrow_after_move() {
6563
let x = A { a: 1, b: box 2 };
6664
drop(x.b);
67-
borrow(&x.a);
65+
let p = &x.a;
66+
drop(*p);
6867
}
6968

7069
fn borrow_after_fu_move() {
7170
let x = A { a: 1, b: box 2 };
7271
let _y = A { a: 3, .. x };
73-
borrow(&x.a);
72+
let p = &x.a;
73+
drop(*p);
7474
}
7575

7676
fn mut_borrow_after_mut_borrow() {
7777
let mut x = A { a: 1, b: box 2 };
78-
let y = &mut x.a;
79-
let z = &mut x.b;
80-
drop(*y);
81-
drop(**z);
78+
let p = &mut x.a;
79+
let q = &mut x.b;
80+
drop(*p);
81+
drop(**q);
8282
}
8383

8484
fn move_after_move() {
@@ -138,28 +138,32 @@ fn borrow_after_assign_after_move() {
138138
let mut x = A { a: 1, b: box 2 };
139139
drop(x.b);
140140
x = A { a: 3, b: box 4 };
141-
borrow(&x.b);
141+
let p = &x.b;
142+
drop(**p);
142143
}
143144

144145
fn borrow_after_assign_after_fu_move() {
145146
let mut x = A { a: 1, b: box 2 };
146147
let _y = A { a: 3, .. x };
147148
x = A { a: 3, b: box 4 };
148-
borrow(&x.b);
149+
let p = &x.b;
150+
drop(**p);
149151
}
150152

151153
fn borrow_after_field_assign_after_move() {
152154
let mut x = A { a: 1, b: box 2 };
153155
drop(x.b);
154156
x.b = box 3;
155-
borrow(&x.b);
157+
let p = &x.b;
158+
drop(**p);
156159
}
157160

158161
fn borrow_after_field_assign_after_fu_move() {
159162
let mut x = A { a: 1, b: box 2 };
160163
let _y = A { a: 3, .. x };
161164
x.b = box 3;
162-
borrow(&x.b);
165+
let p = &x.b;
166+
drop(**p);
163167
}
164168

165169
fn move_after_assign_after_move() {
@@ -199,7 +203,8 @@ fn copy_after_assign_after_uninit() {
199203
fn borrow_after_assign_after_uninit() {
200204
let mut x: A;
201205
x = A { a: 1, b: box 2 };
202-
borrow(&x.a);
206+
let p = &x.a;
207+
drop(*p);
203208
}
204209

205210
fn move_after_assign_after_uninit() {

0 commit comments

Comments
 (0)