@@ -113,23 +113,32 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
113
113
}
114
114
}
115
115
116
- let msg = "" ; //FIXME: add "partially " or "collaterally "
116
+ let is_partial_move = move_site_vec. iter ( ) . any ( |move_site| {
117
+ let move_out = self . move_data . moves [ ( * move_site) . moi ] ;
118
+ let moved_place = & self . move_data . move_paths [ move_out. path ] . place ;
119
+ // `*(_1)` where `_1` is a `Box` is actually a move out.
120
+ let is_box_move = moved_place. as_ref ( ) . projection == & [ ProjectionElem :: Deref ]
121
+ && self . body . local_decls [ moved_place. local ] . ty . is_box ( ) ;
122
+
123
+ !is_box_move
124
+ && used_place != moved_place. as_ref ( )
125
+ && used_place. is_prefix_of ( moved_place. as_ref ( ) )
126
+ } ) ;
127
+
128
+ let partial_str = if is_partial_move { "partial " } else { "" } ;
129
+ let partially_str = if is_partial_move { "partially " } else { "" } ;
117
130
118
131
let mut err = self . cannot_act_on_moved_value (
119
132
span,
120
133
desired_action. as_noun ( ) ,
121
- msg ,
134
+ partially_str ,
122
135
self . describe_place_with_options ( moved_place, IncludingDowncast ( true ) ) ,
123
136
) ;
124
137
125
138
self . add_moved_or_invoked_closure_note ( location, used_place, & mut err) ;
126
139
127
140
let mut is_loop_move = false ;
128
- let is_partial_move = move_site_vec. iter ( ) . any ( |move_site| {
129
- let move_out = self . move_data . moves [ ( * move_site) . moi ] ;
130
- let moved_place = & self . move_data . move_paths [ move_out. path ] . place ;
131
- used_place != moved_place. as_ref ( ) && used_place. is_prefix_of ( moved_place. as_ref ( ) )
132
- } ) ;
141
+
133
142
for move_site in & move_site_vec {
134
143
let move_out = self . move_data . moves [ ( * move_site) . moi ] ;
135
144
let moved_place = & self . move_data . move_paths [ move_out. path ] . place ;
@@ -142,13 +151,19 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
142
151
if location == move_out. source {
143
152
err. span_label (
144
153
span,
145
- format ! ( "value moved{} here, in previous iteration of loop" , move_msg) ,
154
+ format ! (
155
+ "value {}moved{} here, in previous iteration of loop" ,
156
+ partially_str, move_msg
157
+ ) ,
146
158
) ;
147
159
is_loop_move = true ;
148
160
} else if move_site. traversed_back_edge {
149
161
err. span_label (
150
162
move_span,
151
- format ! ( "value moved{} here, in previous iteration of loop" , move_msg) ,
163
+ format ! (
164
+ "value {}moved{} here, in previous iteration of loop" ,
165
+ partially_str, move_msg
166
+ ) ,
152
167
) ;
153
168
} else {
154
169
if let UseSpans :: FnSelfUse { var_span, fn_call_span, fn_span, kind } =
@@ -162,7 +177,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
162
177
FnSelfUseKind :: FnOnceCall => {
163
178
err. span_label (
164
179
fn_call_span,
165
- & format ! ( "{} moved due to this call" , place_name) ,
180
+ & format ! (
181
+ "{} {}moved due to this call" ,
182
+ place_name, partially_str
183
+ ) ,
166
184
) ;
167
185
err. span_note (
168
186
var_span,
@@ -172,7 +190,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
172
190
FnSelfUseKind :: Operator { self_arg } => {
173
191
err. span_label (
174
192
fn_call_span,
175
- & format ! ( "{} moved due to usage in operator" , place_name) ,
193
+ & format ! (
194
+ "{} {}moved due to usage in operator" ,
195
+ place_name, partially_str
196
+ ) ,
176
197
) ;
177
198
if self . fn_self_span_reported . insert ( fn_span) {
178
199
err. span_note (
@@ -186,14 +207,17 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
186
207
err. span_label (
187
208
fn_call_span,
188
209
& format ! (
189
- "{} moved due to this implicit call to `.into_iter()`" ,
190
- place_name
210
+ "{} {} moved due to this implicit call to `.into_iter()`" ,
211
+ place_name, partially_str
191
212
) ,
192
213
) ;
193
214
} else {
194
215
err. span_label (
195
216
fn_call_span,
196
- & format ! ( "{} moved due to this method call" , place_name) ,
217
+ & format ! (
218
+ "{} {}moved due to this method call" ,
219
+ place_name, partially_str
220
+ ) ,
197
221
) ;
198
222
}
199
223
// Avoid pointing to the same function in multiple different
@@ -207,10 +231,17 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
207
231
}
208
232
}
209
233
} else {
210
- err. span_label ( move_span, format ! ( "value moved{} here" , move_msg) ) ;
234
+ err. span_label (
235
+ move_span,
236
+ format ! ( "value {}moved{} here" , partially_str, move_msg) ,
237
+ ) ;
211
238
move_spans. var_span_label (
212
239
& mut err,
213
- format ! ( "variable moved due to use{}" , move_spans. describe( ) ) ,
240
+ format ! (
241
+ "variable {}moved due to use{}" ,
242
+ partially_str,
243
+ move_spans. describe( )
244
+ ) ,
214
245
) ;
215
246
}
216
247
}
@@ -250,9 +281,9 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
250
281
err. span_label (
251
282
span,
252
283
format ! (
253
- "value {} here {} " ,
284
+ "value {} here after {}move " ,
254
285
desired_action. as_verb_in_past_tense( ) ,
255
- if is_partial_move { "after partial move" } else { "after move" } ,
286
+ partial_str
256
287
) ,
257
288
) ;
258
289
}
@@ -321,7 +352,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
321
352
} else {
322
353
None
323
354
} ;
324
- self . note_type_does_not_implement_copy ( & mut err, & note_msg, ty, span) ;
355
+ self . note_type_does_not_implement_copy ( & mut err, & note_msg, ty, span, partial_str ) ;
325
356
}
326
357
327
358
if let Some ( ( _, mut old_err) ) =
@@ -1398,8 +1429,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1398
1429
1399
1430
for moi in & self . move_data . loc_map [ location] {
1400
1431
debug ! ( "report_use_of_moved_or_uninitialized: moi={:?}" , moi) ;
1401
- if mpis. contains ( & self . move_data . moves [ * moi] . path ) {
1402
- debug ! ( "report_use_of_moved_or_uninitialized: found" ) ;
1432
+ let path = self . move_data . moves [ * moi] . path ;
1433
+ if mpis. contains ( & path) {
1434
+ debug ! (
1435
+ "report_use_of_moved_or_uninitialized: found {:?}" ,
1436
+ move_paths[ path] . place
1437
+ ) ;
1403
1438
result. push ( MoveSite { moi : * moi, traversed_back_edge : is_back_edge } ) ;
1404
1439
1405
1440
// Strictly speaking, we could continue our DFS here. There may be
0 commit comments