@@ -218,18 +218,29 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
218
218
219
219
fn report ( & mut self , error : GroupedMoveError < ' tcx > ) {
220
220
let ( mut err, err_span) = {
221
- let ( span, use_spans, original_path, kind) : (
221
+ let ( span, use_spans, original_path, kind, has_complex_bindings ) : (
222
222
Span ,
223
223
Option < UseSpans < ' tcx > > ,
224
224
Place < ' tcx > ,
225
225
& IllegalMoveOriginKind < ' _ > ,
226
+ bool ,
226
227
) = match error {
227
- GroupedMoveError :: MovesFromPlace { span, original_path, ref kind, .. }
228
- | GroupedMoveError :: MovesFromValue { span, original_path, ref kind, .. } => {
229
- ( span, None , original_path, kind)
228
+ GroupedMoveError :: MovesFromPlace {
229
+ span,
230
+ original_path,
231
+ ref kind,
232
+ ref binds_to,
233
+ ..
230
234
}
235
+ | GroupedMoveError :: MovesFromValue {
236
+ span,
237
+ original_path,
238
+ ref kind,
239
+ ref binds_to,
240
+ ..
241
+ } => ( span, None , original_path, kind, !binds_to. is_empty ( ) ) ,
231
242
GroupedMoveError :: OtherIllegalMove { use_spans, original_path, ref kind } => {
232
- ( use_spans. args_or_use ( ) , Some ( use_spans) , original_path, kind)
243
+ ( use_spans. args_or_use ( ) , Some ( use_spans) , original_path, kind, false )
233
244
}
234
245
} ;
235
246
debug ! (
@@ -248,6 +259,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
248
259
target_place,
249
260
span,
250
261
use_spans,
262
+ has_complex_bindings,
251
263
) ,
252
264
& IllegalMoveOriginKind :: InteriorOfTypeWithDestructor { container_ty : ty } => {
253
265
self . cannot_move_out_of_interior_of_drop ( span, ty)
@@ -290,6 +302,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
290
302
deref_target_place : Place < ' tcx > ,
291
303
span : Span ,
292
304
use_spans : Option < UseSpans < ' tcx > > ,
305
+ has_complex_bindings : bool ,
293
306
) -> DiagnosticBuilder < ' a , ErrorGuaranteed > {
294
307
// Inspect the type of the content behind the
295
308
// borrow to provide feedback about why this
@@ -399,6 +412,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
399
412
let diag_name = self . infcx . tcx . get_diagnostic_name ( def_id) ;
400
413
if matches ! ( diag_name, Some ( sym:: Option | sym:: Result ) )
401
414
&& use_spans. map_or ( true , |v| !v. for_closure ( ) )
415
+ && !has_complex_bindings
402
416
{
403
417
err. span_suggestion_verbose (
404
418
span. shrink_to_hi ( ) ,
0 commit comments