@@ -54,80 +54,97 @@ fn borrow_after_move() {
54
54
fn move_after_borrow ( ) {
55
55
let a: Box < _ > = box B { x : box 0 , y : box 1 } ;
56
56
let _x = & a. x ;
57
+ //~^ NOTE borrow of `a.x` occurs here
57
58
let _y = a. y ; //~ ERROR cannot move
58
59
}
59
60
60
61
fn copy_after_mut_borrow ( ) {
61
62
let mut a: Box < _ > = box A { x : box 0 , y : 1 } ;
62
63
let _x = & mut a. x ;
64
+ //~^ NOTE borrow of `a.x` occurs here
63
65
let _y = a. y ; //~ ERROR cannot use
64
66
}
65
67
66
68
fn move_after_mut_borrow ( ) {
67
69
let mut a: Box < _ > = box B { x : box 0 , y : box 1 } ;
68
70
let _x = & mut a. x ;
71
+ //~^ NOTE borrow of `a.x` occurs here
69
72
let _y = a. y ; //~ ERROR cannot move
70
73
}
71
74
72
75
fn borrow_after_mut_borrow ( ) {
73
76
let mut a: Box < _ > = box A { x : box 0 , y : 1 } ;
74
77
let _x = & mut a. x ;
78
+ //~^ NOTE previous borrow of `a` occurs here (through borrowing `a.x`);
75
79
let _y = & a. y ; //~ ERROR cannot borrow
76
80
}
81
+ //~^ NOTE previous borrow ends here
77
82
78
83
fn mut_borrow_after_borrow ( ) {
79
84
let mut a: Box < _ > = box A { x : box 0 , y : 1 } ;
80
85
let _x = & a. x ;
86
+ //~^ NOTE previous borrow of `a` occurs here (through borrowing `a.x`)
81
87
let _y = & mut a. y ; //~ ERROR cannot borrow
82
88
}
89
+ //~^ NOTE previous borrow ends here
83
90
84
91
fn copy_after_move_nested ( ) {
85
92
let a: Box < _ > = box C { x : box A { x : box 0 , y : 1 } , y : 2 } ;
86
93
let _x = a. x . x ;
94
+ //~^ NOTE `a.x.x` moved here because it has type `Box<isize>`, which is moved by default
87
95
let _y = a. y ; //~ ERROR use of collaterally moved
88
96
}
89
97
90
98
fn move_after_move_nested ( ) {
91
99
let a: Box < _ > = box D { x : box A { x : box 0 , y : 1 } , y : box 2 } ;
92
100
let _x = a. x . x ;
101
+ //~^ NOTE `a.x.x` moved here because it has type `Box<isize>`, which is moved by default
93
102
let _y = a. y ; //~ ERROR use of collaterally moved
94
103
}
95
104
96
105
fn borrow_after_move_nested ( ) {
97
106
let a: Box < _ > = box C { x : box A { x : box 0 , y : 1 } , y : 2 } ;
98
107
let _x = a. x . x ;
108
+ //~^ NOTE `a.x.x` moved here because it has type `Box<isize>`, which is moved by default
99
109
let _y = & a. y ; //~ ERROR use of collaterally moved
100
110
}
101
111
102
112
fn move_after_borrow_nested ( ) {
103
113
let a: Box < _ > = box D { x : box A { x : box 0 , y : 1 } , y : box 2 } ;
104
114
let _x = & a. x . x ;
115
+ //~^ NOTE borrow of `a.x.x` occurs here
105
116
let _y = a. y ; //~ ERROR cannot move
106
117
}
107
118
108
119
fn copy_after_mut_borrow_nested ( ) {
109
120
let mut a: Box < _ > = box C { x : box A { x : box 0 , y : 1 } , y : 2 } ;
110
121
let _x = & mut a. x . x ;
122
+ //~^ NOTE borrow of `a.x.x` occurs here
111
123
let _y = a. y ; //~ ERROR cannot use
112
124
}
113
125
114
126
fn move_after_mut_borrow_nested ( ) {
115
127
let mut a: Box < _ > = box D { x : box A { x : box 0 , y : 1 } , y : box 2 } ;
116
128
let _x = & mut a. x . x ;
129
+ //~^ NOTE borrow of `a.x.x` occurs here
117
130
let _y = a. y ; //~ ERROR cannot move
118
131
}
119
132
120
133
fn borrow_after_mut_borrow_nested ( ) {
121
134
let mut a: Box < _ > = box C { x : box A { x : box 0 , y : 1 } , y : 2 } ;
122
135
let _x = & mut a. x . x ;
136
+ //~^ NOTE previous borrow of `a.x.x` occurs here; the mutable borrow prevents
123
137
let _y = & a. y ; //~ ERROR cannot borrow
124
138
}
139
+ //~^ NOTE previous borrow ends here
125
140
126
141
fn mut_borrow_after_borrow_nested ( ) {
127
142
let mut a: Box < _ > = box C { x : box A { x : box 0 , y : 1 } , y : 2 } ;
128
143
let _x = & a. x . x ;
144
+ //~^ NOTE previous borrow of `a.x.x` occurs here; the immutable borrow prevents
129
145
let _y = & mut a. y ; //~ ERROR cannot borrow
130
146
}
147
+ //~^ NOTE previous borrow ends here
131
148
132
149
fn main ( ) {
133
150
copy_after_move ( ) ;
0 commit comments