@@ -4,7 +4,7 @@ use rustc_middle::ty;
44use rustc_mir_dataflow:: move_paths:: {
55 IllegalMoveOrigin , IllegalMoveOriginKind , LookupResult , MoveError , MovePathIndex ,
66} ;
7- use rustc_span:: { sym , Span } ;
7+ use rustc_span:: Span ;
88
99use crate :: diagnostics:: UseSpans ;
1010use crate :: prefixes:: PrefixSet ;
@@ -218,29 +218,13 @@ 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, has_complex_bindings) : (
222- Span ,
223- Option < UseSpans < ' tcx > > ,
224- Place < ' tcx > ,
225- & IllegalMoveOriginKind < ' _ > ,
226- bool ,
227- ) = match error {
228- GroupedMoveError :: MovesFromPlace {
229- span,
230- original_path,
231- ref kind,
232- ref binds_to,
233- ..
221+ let ( span, use_spans, original_path, kind) = match error {
222+ GroupedMoveError :: MovesFromPlace { span, original_path, ref kind, .. }
223+ | GroupedMoveError :: MovesFromValue { span, original_path, ref kind, .. } => {
224+ ( span, None , original_path, kind)
234225 }
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 ( ) ) ,
242226 GroupedMoveError :: OtherIllegalMove { use_spans, original_path, ref kind } => {
243- ( use_spans. args_or_use ( ) , Some ( use_spans) , original_path, kind, false )
227+ ( use_spans. args_or_use ( ) , Some ( use_spans) , original_path, kind)
244228 }
245229 } ;
246230 debug ! (
@@ -259,7 +243,6 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
259243 target_place,
260244 span,
261245 use_spans,
262- has_complex_bindings,
263246 ) ,
264247 & IllegalMoveOriginKind :: InteriorOfTypeWithDestructor { container_ty : ty } => {
265248 self . cannot_move_out_of_interior_of_drop ( span, ty)
@@ -302,7 +285,6 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
302285 deref_target_place : Place < ' tcx > ,
303286 span : Span ,
304287 use_spans : Option < UseSpans < ' tcx > > ,
305- has_complex_bindings : bool ,
306288 ) -> DiagnosticBuilder < ' a , ErrorGuaranteed > {
307289 // Inspect the type of the content behind the
308290 // borrow to provide feedback about why this
@@ -399,28 +381,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
399381 }
400382 }
401383 } ;
402- let ty = move_place. ty ( self . body , self . infcx . tcx ) . ty ;
403- let def_id = match * ty. kind ( ) {
404- ty:: Adt ( self_def, _) => self_def. did ( ) ,
405- ty:: Foreign ( def_id)
406- | ty:: FnDef ( def_id, _)
407- | ty:: Closure ( def_id, _)
408- | ty:: Generator ( def_id, ..)
409- | ty:: Opaque ( def_id, _) => def_id,
410- _ => return err,
411- } ;
412- let diag_name = self . infcx . tcx . get_diagnostic_name ( def_id) ;
413- if matches ! ( diag_name, Some ( sym:: Option | sym:: Result ) )
414- && use_spans. map_or ( true , |v| !v. for_closure ( ) )
415- && !has_complex_bindings
416- {
417- err. span_suggestion_verbose (
418- span. shrink_to_hi ( ) ,
419- & format ! ( "consider borrowing the `{}`'s content" , diag_name. unwrap( ) ) ,
420- ".as_ref()" ,
421- Applicability :: MaybeIncorrect ,
422- ) ;
423- } else if let Some ( use_spans) = use_spans {
384+ if let Some ( use_spans) = use_spans {
424385 self . explain_captures (
425386 & mut err, span, span, use_spans, move_place, None , "" , "" , "" , false , true ,
426387 ) ;
0 commit comments