1414// Also includes tests of the errors reported when the Box in question
1515// is immutable (#14270).
1616
17+ // revisions: ast mir
18+ //[mir]compile-flags: -Z borrowck=mir
19+
1720#![ feature( box_syntax) ]
1821
1922struct A { a : isize }
@@ -23,7 +26,8 @@ fn indirect_write_to_imm_box() {
2326 let mut x: isize = 1 ;
2427 let y: Box < _ > = box & mut x;
2528 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`
2731 drop ( p) ;
2832}
2933
@@ -32,7 +36,8 @@ fn borrow_in_var_from_var() {
3236 let mut y: Box < _ > = box & mut x;
3337 let p = & y;
3438 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
3641 drop ( p) ;
3742 drop ( q) ;
3843}
@@ -42,7 +47,8 @@ fn borrow_in_var_from_var_via_imm_box() {
4247 let y: Box < _ > = box & mut x;
4348 let p = & y;
4449 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
4652 drop ( p) ;
4753 drop ( q) ;
4854}
@@ -52,7 +58,8 @@ fn borrow_in_var_from_field() {
5258 let mut y: Box < _ > = box & mut x. a ;
5359 let p = & y;
5460 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
5663 drop ( p) ;
5764 drop ( q) ;
5865}
@@ -62,7 +69,8 @@ fn borrow_in_var_from_field_via_imm_box() {
6269 let y: Box < _ > = box & mut x. a ;
6370 let p = & y;
6471 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
6674 drop ( p) ;
6775 drop ( q) ;
6876}
@@ -72,7 +80,8 @@ fn borrow_in_field_from_var() {
7280 let mut y = B { a : box & mut x } ;
7381 let p = & y. a ;
7482 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
7685 drop ( p) ;
7786 drop ( q) ;
7887}
@@ -82,7 +91,8 @@ fn borrow_in_field_from_var_via_imm_box() {
8291 let y = B { a : box & mut x } ;
8392 let p = & y. a ;
8493 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
8696 drop ( p) ;
8797 drop ( q) ;
8898}
@@ -92,7 +102,8 @@ fn borrow_in_field_from_field() {
92102 let mut y = B { a : box & mut x. a } ;
93103 let p = & y. a ;
94104 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
96107 drop ( p) ;
97108 drop ( q) ;
98109}
@@ -102,7 +113,8 @@ fn borrow_in_field_from_field_via_imm_box() {
102113 let y = B { a : box & mut x. a } ;
103114 let p = & y. a ;
104115 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
106118 drop ( p) ;
107119 drop ( q) ;
108120}
0 commit comments