From fe0260fbf892d5b49e79ee310b5e198c72c3d576 Mon Sep 17 00:00:00 2001 From: Federico Poli Date: Thu, 15 Feb 2018 15:04:43 +0100 Subject: [PATCH] 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 --- src/librustc_mir/dataflow/move_paths/builder.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/librustc_mir/dataflow/move_paths/builder.rs b/src/librustc_mir/dataflow/move_paths/builder.rs index 635d99e7737..d6f419f6cfb 100644 --- a/src/librustc_mir/dataflow/move_paths/builder.rs +++ b/src/librustc_mir/dataflow/move_paths/builder.rs @@ -353,9 +353,12 @@ impl<'b, 'a, 'gcx, 'tcx> Gatherer<'b, 'a, 'gcx, 'tcx> { self.gather_move(&Place::Local(RETURN_PLACE)); } - TerminatorKind::Assert { .. } | - TerminatorKind::SwitchInt { .. } => { - // branching terminators - these don't move anything + TerminatorKind::Assert { ref cond, .. } => { + self.gather_operand(cond); + } + + TerminatorKind::SwitchInt { ref discr, .. } => { + self.gather_operand(discr); } TerminatorKind::Yield { ref value, .. } => {