Skip to content

Commit a1d55be

Browse files
committed
Fixed bug with the implementation that was suppressing expected errors from the same line in other tests.
1 parent bf76ffe commit a1d55be

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Diff for: src/librustc_mir/borrow_check.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)