@@ -4,7 +4,7 @@ use rustc_middle::ty;
4
4
use rustc_mir_dataflow:: move_paths:: {
5
5
IllegalMoveOrigin , IllegalMoveOriginKind , LookupResult , MoveError , MovePathIndex ,
6
6
} ;
7
- use rustc_span:: { sym , Span } ;
7
+ use rustc_span:: Span ;
8
8
9
9
use crate :: diagnostics:: UseSpans ;
10
10
use crate :: prefixes:: PrefixSet ;
@@ -218,29 +218,13 @@ 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, 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)
234
225
}
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 ( ) ) ,
242
226
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)
244
228
}
245
229
} ;
246
230
debug ! (
@@ -259,7 +243,6 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
259
243
target_place,
260
244
span,
261
245
use_spans,
262
- has_complex_bindings,
263
246
) ,
264
247
& IllegalMoveOriginKind :: InteriorOfTypeWithDestructor { container_ty : ty } => {
265
248
self . cannot_move_out_of_interior_of_drop ( span, ty)
@@ -302,7 +285,6 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
302
285
deref_target_place : Place < ' tcx > ,
303
286
span : Span ,
304
287
use_spans : Option < UseSpans < ' tcx > > ,
305
- has_complex_bindings : bool ,
306
288
) -> DiagnosticBuilder < ' a , ErrorGuaranteed > {
307
289
// Inspect the type of the content behind the
308
290
// borrow to provide feedback about why this
@@ -399,28 +381,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
399
381
}
400
382
}
401
383
} ;
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 {
424
385
self . explain_captures (
425
386
& mut err, span, span, use_spans, move_place, None , "" , "" , "" , false , true ,
426
387
) ;
0 commit comments