@@ -643,16 +643,16 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
643
643
_ => false ,
644
644
} ;
645
645
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 {
649
648
let error_reported;
650
649
651
650
if moves_by_default {
652
651
let kind = match consume_via_drop {
653
652
ConsumeKind :: Drop => WriteKind :: StorageDeadOrDrop ,
654
653
_ => WriteKind :: Move ,
655
654
} ;
655
+
656
656
// move of lvalue: check if this is move of already borrowed path
657
657
error_reported = self . access_lvalue ( context, lvalue_span,
658
658
( Deep , Write ( kind) ) , flow_state) ;
@@ -663,7 +663,9 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
663
663
( Deep , Read ( ReadKind :: Copy ) ) , flow_state) ;
664
664
}
665
665
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 {
667
669
if let Lvalue :: Local ( local) = * lvalue {
668
670
self . storage_drop_or_dead_error_reported . insert ( local) ;
669
671
}
0 commit comments