9
9
// except according to those terms.
10
10
11
11
// ignore-tidy-linelength
12
+ // revisions: ast mir
13
+ //[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
12
14
13
15
#[ derive( Clone , Copy ) ]
14
16
union U {
@@ -30,11 +32,15 @@ fn main() {
30
32
}
31
33
{
32
34
let ra = & u. a ;
33
- let rma = & mut u. a ; //~ ERROR cannot borrow `u.a` as mutable because it is also borrowed as immutable
35
+ let rma = & mut u. a ; //[ast]~ ERROR cannot borrow `u.a` as mutable because it is also borrowed as immutable
36
+ //[mir]~^ ERROR cannot borrow `u.a` as mutable because it is also borrowed as immutable (Ast)
37
+ //[mir]~| ERROR cannot borrow `u.0` as mutable because it is also borrowed as immutable (Mir)
34
38
}
35
39
{
36
40
let ra = & u. a ;
37
- u. a = 1 ; //~ ERROR cannot assign to `u.a` because it is borrowed
41
+ u. a = 1 ; //[ast]~ ERROR cannot assign to `u.a` because it is borrowed
42
+ //[mir]~^ ERROR cannot assign to `u.a` because it is borrowed (Ast)
43
+ //[mir]~| ERROR cannot assign to `u.0` because it is borrowed (Mir)
38
44
}
39
45
// Imm borrow, other field
40
46
{
@@ -47,45 +53,65 @@ fn main() {
47
53
}
48
54
{
49
55
let ra = & u. a ;
50
- let rmb = & mut u. b ; //~ ERROR cannot borrow `u` (via `u.b`) as mutable because `u` is also borrowed as immutable (via `u.a`)
56
+ let rmb = & mut u. b ; //[ast]~ ERROR cannot borrow `u` (via `u.b`) as mutable because `u` is also borrowed as immutable (via `u.a`)
57
+ //[mir]~^ ERROR cannot borrow `u` (via `u.b`) as mutable because `u` is also borrowed as immutable (via `u.a`) (Ast)
58
+ // FIXME Error for MIR (needs support for union)
51
59
}
52
60
{
53
61
let ra = & u. a ;
54
- u. b = 1 ; //~ ERROR cannot assign to `u.b` because it is borrowed
62
+ u. b = 1 ; //[ast]~ ERROR cannot assign to `u.b` because it is borrowed
63
+ //[mir]~^ ERROR cannot assign to `u.b` because it is borrowed (Ast)
64
+ // FIXME Error for MIR (needs support for union)
55
65
}
56
66
// Mut borrow, same field
57
67
{
58
68
let rma = & mut u. a ;
59
- let ra = & u. a ; //~ ERROR cannot borrow `u.a` as immutable because it is also borrowed as mutable
69
+ let ra = & u. a ; //[ast]~ ERROR cannot borrow `u.a` as immutable because it is also borrowed as mutable
70
+ //[mir]~^ ERROR cannot borrow `u.a` as immutable because it is also borrowed as mutable (Ast)
71
+ //[mir]~| ERROR cannot borrow `u.0` as immutable because it is also borrowed as mutable (Mir)
60
72
}
61
73
{
62
74
let ra = & mut u. a ;
63
- let a = u. a ; //~ ERROR cannot use `u.a` because it was mutably borrowed
75
+ let a = u. a ; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed
76
+ //[mir]~^ ERROR cannot use `u.a` because it was mutably borrowed (Ast)
77
+ //[mir]~| ERROR cannot use `u.0` because it was mutably borrowed (Mir)
64
78
}
65
79
{
66
80
let rma = & mut u. a ;
67
- let rma2 = & mut u. a ; //~ ERROR cannot borrow `u.a` as mutable more than once at a time
81
+ let rma2 = & mut u. a ; //[ast]~ ERROR cannot borrow `u.a` as mutable more than once at a time
82
+ //[mir]~^ ERROR cannot borrow `u.a` as mutable more than once at a time (Ast)
83
+ //[mir]~| ERROR cannot borrow `u.0` as mutable more than once at a time (Mir)
68
84
}
69
85
{
70
86
let rma = & mut u. a ;
71
- u. a = 1 ; //~ ERROR cannot assign to `u.a` because it is borrowed
87
+ u. a = 1 ; //[ast]~ ERROR cannot assign to `u.a` because it is borrowed
88
+ //[mir]~^ ERROR cannot assign to `u.a` because it is borrowed (Ast)
89
+ //[mir]~| ERROR cannot assign to `u.0` because it is borrowed (Mir)
72
90
}
73
91
// Mut borrow, other field
74
92
{
75
93
let rma = & mut u. a ;
76
- let rb = & u. b ; //~ ERROR cannot borrow `u` (via `u.b`) as immutable because `u` is also borrowed as mutable (via `u.a`)
94
+ let rb = & u. b ; //[ast]~ ERROR cannot borrow `u` (via `u.b`) as immutable because `u` is also borrowed as mutable (via `u.a`)
95
+ //[mir]~^ ERROR cannot borrow `u` (via `u.b`) as immutable because `u` is also borrowed as mutable (via `u.a`) (Ast)
96
+ // FIXME Error for MIR (needs support for union)
77
97
}
78
98
{
79
99
let ra = & mut u. a ;
80
- let b = u. b ; //~ ERROR cannot use `u.b` because it was mutably borrowed
100
+ let b = u. b ; //[ast]~ ERROR cannot use `u.b` because it was mutably borrowed
101
+ //[mir]~^ ERROR cannot use `u.b` because it was mutably borrowed (Ast)
102
+ // FIXME Error for MIR (needs support for union)
81
103
}
82
104
{
83
105
let rma = & mut u. a ;
84
- let rmb2 = & mut u. b ; //~ ERROR cannot borrow `u` (via `u.b`) as mutable more than once at a time
106
+ let rmb2 = & mut u. b ; //[ast]~ ERROR cannot borrow `u` (via `u.b`) as mutable more than once at a time
107
+ //[mir]~^ ERROR cannot borrow `u` (via `u.b`) as mutable more than once at a time (Ast)
108
+ // FIXME Error for MIR (needs support for union)
85
109
}
86
110
{
87
111
let rma = & mut u. a ;
88
- u. b = 1 ; //~ ERROR cannot assign to `u.b` because it is borrowed
112
+ u. b = 1 ; //[ast]~ ERROR cannot assign to `u.b` because it is borrowed
113
+ //[mir]~^ ERROR cannot assign to `u.b` because it is borrowed (Ast)
114
+ // FIXME Error for MIR (needs support for union)
89
115
}
90
116
}
91
117
}
0 commit comments