mir: Gather move at SwitchInt, Assert terminators

Previously, "_1" was not marked as "definitely uninitialized" after a "switchInt(move _1)" terminator.

Related discussion: https://internals.rust-lang.org/t/why-is-2-definitely-initialized-after-switchint-move-2/6760
This commit is contained in:
Federico Poli 2018-02-15 15:04:43 +01:00
parent c83fa5d91c
commit fe0260fbf8

View File

@ -353,9 +353,12 @@ impl<'b, 'a, 'gcx, 'tcx> Gatherer<'b, 'a, 'gcx, 'tcx> {
self.gather_move(&Place::Local(RETURN_PLACE)); self.gather_move(&Place::Local(RETURN_PLACE));
} }
TerminatorKind::Assert { .. } | TerminatorKind::Assert { ref cond, .. } => {
TerminatorKind::SwitchInt { .. } => { self.gather_operand(cond);
// branching terminators - these don't move anything }
TerminatorKind::SwitchInt { ref discr, .. } => {
self.gather_operand(discr);
} }
TerminatorKind::Yield { ref value, .. } => { TerminatorKind::Yield { ref value, .. } => {