@@ -218,18 +218,29 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
218218
219219 fn report ( & mut self , error : GroupedMoveError < ' tcx > ) {
220220 let ( mut err, err_span) = {
221- let ( span, use_spans, original_path, kind) : (
221+ let ( span, use_spans, original_path, kind, has_complex_bindings ) : (
222222 Span ,
223223 Option < UseSpans < ' tcx > > ,
224224 Place < ' tcx > ,
225225 & IllegalMoveOriginKind < ' _ > ,
226+ bool ,
226227 ) = 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+ ..
230234 }
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 ( ) ) ,
231242 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 )
233244 }
234245 } ;
235246 debug ! (
@@ -248,6 +259,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
248259 target_place,
249260 span,
250261 use_spans,
262+ has_complex_bindings,
251263 ) ,
252264 & IllegalMoveOriginKind :: InteriorOfTypeWithDestructor { container_ty : ty } => {
253265 self . cannot_move_out_of_interior_of_drop ( span, ty)
@@ -290,6 +302,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
290302 deref_target_place : Place < ' tcx > ,
291303 span : Span ,
292304 use_spans : Option < UseSpans < ' tcx > > ,
305+ has_complex_bindings : bool ,
293306 ) -> DiagnosticBuilder < ' a , ErrorGuaranteed > {
294307 // Inspect the type of the content behind the
295308 // borrow to provide feedback about why this
@@ -399,6 +412,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
399412 let diag_name = self . infcx . tcx . get_diagnostic_name ( def_id) ;
400413 if matches ! ( diag_name, Some ( sym:: Option | sym:: Result ) )
401414 && use_spans. map_or ( true , |v| !v. for_closure ( ) )
415+ && !has_complex_bindings
402416 {
403417 err. span_suggestion_verbose (
404418 span. shrink_to_hi ( ) ,
0 commit comments