1
Fork 0

Update match branches

This updates all places where match branches check on StatementKind or UseContext.
This doesn't properly implement them, but adds TODOs where they are, and also adds some best
guesses to what they should be in some cases.
This commit is contained in:
kadmin 2020-10-05 22:53:00 +00:00
parent 72c734d001
commit 89f45ed9f3
19 changed files with 1346 additions and 24 deletions

View file

@ -92,6 +92,21 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
self.consume_operand(location, input);
}
}
StatementKind::CopyNonOverlapping(box rustc_middle::mir::CopyNonOverlapping {
ref src,
ref dst,
ref size,
}) => {
self.consume_operand(location, src);
self.consume_operand(location, dst);
self.consume_operand(location, size);
match dst {
Operand::Move(ref place) | Operand::Copy(ref place) => {
self.mutate_place(location, *place, Deep, JustWrite);
}
_ => {}
}
}
StatementKind::Nop
| StatementKind::Coverage(..)
| StatementKind::AscribeUserType(..)

View file

@ -626,6 +626,8 @@ impl<'cx, 'tcx> dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtxt<'cx, 'tc
self.consume_operand(location, (input, span), flow_state);
}
}
StatementKind::CopyNonOverlapping(..) => todo!(),
StatementKind::Nop
| StatementKind::Coverage(..)
| StatementKind::AscribeUserType(..)

View file

@ -1520,6 +1520,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
);
}
}
StatementKind::CopyNonOverlapping(..) => todo!(),
StatementKind::FakeRead(..)
| StatementKind::StorageLive(..)
| StatementKind::StorageDead(..)

View file

@ -306,6 +306,8 @@ impl<'tcx> dataflow::GenKillAnalysis<'tcx> for Borrows<'_, 'tcx> {
| mir::StatementKind::AscribeUserType(..)
| mir::StatementKind::Coverage(..)
| mir::StatementKind::Nop => {}
mir::StatementKind::CopyNonOverlapping(..) => todo!(),
}
}

View file

@ -150,6 +150,8 @@ impl<'mir, 'tcx> dataflow::GenKillAnalysis<'tcx> for MaybeRequiresStorage<'mir,
| StatementKind::Nop
| StatementKind::Retag(..)
| StatementKind::StorageLive(..) => {}
StatementKind::CopyNonOverlapping(..) => todo!(),
}
}

View file

@ -319,6 +319,8 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
| StatementKind::AscribeUserType(..)
| StatementKind::Coverage(..)
| StatementKind::Nop => {}
StatementKind::CopyNonOverlapping(..) => todo!(),
}
}

View file

@ -113,6 +113,23 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
M::retag(self, *kind, &dest)?;
}
// Call CopyNonOverlapping
CopyNonOverlapping(box rustc_middle::mir::CopyNonOverlapping { dst, src, size }) => {
let size = self.eval_operand(size, None)?;
let dst = {
let dst = self.eval_operand(dst, None)?;
dst.assert_mem_place(self)
};
let src = {
let src = self.eval_operand(src, None)?;
src.assert_mem_place(self)
};
// Not sure how to convert an MPlaceTy<'_, <M as Machine<'_, '_>>::PointerTag>
// to a pointer, or OpTy to a size
self.memory.copy(src, dst, size, /*nonoverlapping*/ true)?;
}
// Statements we do not track.
AscribeUserType(..) => {}

View file

@ -808,6 +808,7 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> {
| StatementKind::Retag { .. }
| StatementKind::AscribeUserType(..)
| StatementKind::Coverage(..)
| StatementKind::CopyNonOverlapping(..)
| StatementKind::Nop => {}
}
}

View file

@ -115,6 +115,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> {
| StatementKind::Retag { .. }
| StatementKind::AscribeUserType(..)
| StatementKind::Coverage(..)
| StatementKind::CopyNonOverlapping(..)
| StatementKind::Nop => {
// safe (at least as emitted during MIR construction)
}

View file

@ -587,6 +587,7 @@ impl Conflicts<'a> {
| StatementKind::FakeRead(..)
| StatementKind::AscribeUserType(..)
| StatementKind::Coverage(..)
| StatementKind::CopyNonOverlapping(..)
| StatementKind::Nop => {}
}
}

View file

@ -1454,6 +1454,7 @@ impl Visitor<'tcx> for EnsureGeneratorFieldAssignmentsNeverAlias<'_> {
| StatementKind::Retag(..)
| StatementKind::AscribeUserType(..)
| StatementKind::Coverage(..)
| StatementKind::CopyNonOverlapping(..)
| StatementKind::Nop => {}
}
}

File diff suppressed because it is too large Load diff

View file

@ -39,6 +39,7 @@ impl RemoveNoopLandingPads {
| StatementKind::StorageDead(_)
| StatementKind::AscribeUserType(..)
| StatementKind::Coverage(..)
| StatementKind::CopyNonOverlapping(..)
| StatementKind::Nop => {
// These are all nops in a landing pad
}

View file

@ -245,6 +245,7 @@ pub fn statement_kind_name(statement: &Statement<'_>) -> &'static str {
Retag(..) => "Retag",
AscribeUserType(..) => "AscribeUserType",
Coverage(..) => "Coverage",
CopyNonOverlapping(..) => "CopyNonOverlapping",
Nop => "Nop",
}
}