@@ -643,16 +643,16 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
643643 _ => false ,
644644 } ;
645645
646- // If the error has been reported already, then we don't need the access_lvalue call and we
647- // can set error_reported to false.
648- if !has_storage_drop_or_dead_error_reported {
646+ // If the error has been reported already, then we don't need the access_lvalue call.
647+ if !has_storage_drop_or_dead_error_reported || consume_via_drop != ConsumeKind :: Drop {
649648 let error_reported;
650649
651650 if moves_by_default {
652651 let kind = match consume_via_drop {
653652 ConsumeKind :: Drop => WriteKind :: StorageDeadOrDrop ,
654653 _ => WriteKind :: Move ,
655654 } ;
655+
656656 // move of lvalue: check if this is move of already borrowed path
657657 error_reported = self . access_lvalue ( context, lvalue_span,
658658 ( Deep , Write ( kind) ) , flow_state) ;
@@ -663,7 +663,9 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
663663 ( Deep , Read ( ReadKind :: Copy ) ) , flow_state) ;
664664 }
665665
666- if error_reported {
666+ // If there was an error, then we keep track of it so as to deduplicate it.
667+ // We only do this on ConsumeKind::Drop.
668+ if error_reported && consume_via_drop == ConsumeKind :: Drop {
667669 if let Lvalue :: Local ( local) = * lvalue {
668670 self . storage_drop_or_dead_error_reported . insert ( local) ;
669671 }
0 commit comments