14
14
// Also includes tests of the errors reported when the Box in question
15
15
// is immutable (#14270).
16
16
17
+ // revisions: ast mir
18
+ //[mir]compile-flags: -Z borrowck=mir
19
+
17
20
#![ feature( box_syntax) ]
18
21
19
22
struct A { a : isize }
@@ -23,7 +26,8 @@ fn indirect_write_to_imm_box() {
23
26
let mut x: isize = 1 ;
24
27
let y: Box < _ > = box & mut x;
25
28
let p = & y;
26
- * * * p = 2 ; //~ ERROR cannot assign to data in a `&` reference
29
+ * * * p = 2 ; //[ast]~ ERROR cannot assign to data in a `&` reference
30
+ //[mir]~^ ERROR cannot assign to immutable item `***p`
27
31
drop ( p) ;
28
32
}
29
33
@@ -32,7 +36,8 @@ fn borrow_in_var_from_var() {
32
36
let mut y: Box < _ > = box & mut x;
33
37
let p = & y;
34
38
let q = & * * * p;
35
- * * y = 2 ; //~ ERROR cannot assign to `**y` because it is borrowed
39
+ * * y = 2 ; //[ast]~ ERROR cannot assign to `**y` because it is borrowed
40
+ //[mir]~^ ERROR cannot assign to `**y` because it is borrowed
36
41
drop ( p) ;
37
42
drop ( q) ;
38
43
}
@@ -42,7 +47,8 @@ fn borrow_in_var_from_var_via_imm_box() {
42
47
let y: Box < _ > = box & mut x;
43
48
let p = & y;
44
49
let q = & * * * p;
45
- * * y = 2 ; //~ ERROR cannot assign to `**y` because it is borrowed
50
+ * * y = 2 ; //[ast]~ ERROR cannot assign to `**y` because it is borrowed
51
+ //[mir]~^ ERROR cannot assign to `**y` because it is borrowed
46
52
drop ( p) ;
47
53
drop ( q) ;
48
54
}
@@ -52,7 +58,8 @@ fn borrow_in_var_from_field() {
52
58
let mut y: Box < _ > = box & mut x. a ;
53
59
let p = & y;
54
60
let q = & * * * p;
55
- * * y = 2 ; //~ ERROR cannot assign to `**y` because it is borrowed
61
+ * * y = 2 ; //[ast]~ ERROR cannot assign to `**y` because it is borrowed
62
+ //[mir]~^ ERROR cannot assign to `**y` because it is borrowed
56
63
drop ( p) ;
57
64
drop ( q) ;
58
65
}
@@ -62,7 +69,8 @@ fn borrow_in_var_from_field_via_imm_box() {
62
69
let y: Box < _ > = box & mut x. a ;
63
70
let p = & y;
64
71
let q = & * * * p;
65
- * * y = 2 ; //~ ERROR cannot assign to `**y` because it is borrowed
72
+ * * y = 2 ; //[ast]~ ERROR cannot assign to `**y` because it is borrowed
73
+ //[mir]~^ ERROR cannot assign to `**y` because it is borrowed
66
74
drop ( p) ;
67
75
drop ( q) ;
68
76
}
@@ -72,7 +80,8 @@ fn borrow_in_field_from_var() {
72
80
let mut y = B { a : box & mut x } ;
73
81
let p = & y. a ;
74
82
let q = & * * * p;
75
- * * y. a = 2 ; //~ ERROR cannot assign to `**y.a` because it is borrowed
83
+ * * y. a = 2 ; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed
84
+ //[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed
76
85
drop ( p) ;
77
86
drop ( q) ;
78
87
}
@@ -82,7 +91,8 @@ fn borrow_in_field_from_var_via_imm_box() {
82
91
let y = B { a : box & mut x } ;
83
92
let p = & y. a ;
84
93
let q = & * * * p;
85
- * * y. a = 2 ; //~ ERROR cannot assign to `**y.a` because it is borrowed
94
+ * * y. a = 2 ; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed
95
+ //[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed
86
96
drop ( p) ;
87
97
drop ( q) ;
88
98
}
@@ -92,7 +102,8 @@ fn borrow_in_field_from_field() {
92
102
let mut y = B { a : box & mut x. a } ;
93
103
let p = & y. a ;
94
104
let q = & * * * p;
95
- * * y. a = 2 ; //~ ERROR cannot assign to `**y.a` because it is borrowed
105
+ * * y. a = 2 ; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed
106
+ //[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed
96
107
drop ( p) ;
97
108
drop ( q) ;
98
109
}
@@ -102,7 +113,8 @@ fn borrow_in_field_from_field_via_imm_box() {
102
113
let y = B { a : box & mut x. a } ;
103
114
let p = & y. a ;
104
115
let q = & * * * p;
105
- * * y. a = 2 ; //~ ERROR cannot assign to `**y.a` because it is borrowed
116
+ * * y. a = 2 ; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed
117
+ //[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed
106
118
drop ( p) ;
107
119
drop ( q) ;
108
120
}
0 commit comments