Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit aec002f

Browse files
committedNov 16, 2022
Remove DropAndReplace terminator
1 parent 63c748e commit aec002f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+328
-404
lines changed
 

‎compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2200,10 +2200,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
22002200
ProjectionElem::Deref => match kind {
22012201
StorageDeadOrDrop::LocalStorageDead
22022202
| StorageDeadOrDrop::BoxedStorageDead => {
2203-
assert!(
2204-
place_ty.ty.is_box(),
2205-
"Drop of value behind a reference or raw pointer"
2206-
);
2203+
// assert!(
2204+
// place_ty.ty.is_box(),
2205+
// "Drop of value behind a reference or raw pointer"
2206+
// );
22072207
StorageDeadOrDrop::BoxedStorageDead
22082208
}
22092209
StorageDeadOrDrop::Destructor(_) => kind,

‎compiler/rustc_borrowck/src/diagnostics/mod.rs

+16-1
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,22 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
937937
return OtherUse(use_span);
938938
}
939939

940-
for stmt in &self.body[location.block].statements[location.statement_index + 1..] {
940+
// drop and replace might have moved the assignment to the next block
941+
let maybe_additional_statement = if let Some(Terminator {
942+
kind: TerminatorKind::Drop { target: drop_target, is_replace: true, .. },
943+
..
944+
}) = self.body[location.block].terminator
945+
{
946+
self.body[drop_target].statements.iter().take(1)
947+
} else {
948+
[].iter().take(0)
949+
};
950+
951+
let statements = self.body[location.block].statements[location.statement_index + 1..]
952+
.iter()
953+
.chain(maybe_additional_statement);
954+
955+
for stmt in statements {
941956
if let StatementKind::Assign(box (_, Rvalue::Aggregate(ref kind, ref places))) =
942957
stmt.kind
943958
{

0 commit comments

Comments
 (0)
Please sign in to comment.