From 3ab29d337834383c159b2a4e275581f97ad34a25 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Wed, 21 Oct 2015 17:28:51 -0400 Subject: [PATCH] Add adt_def into Switch, since it's convenient to have in trans --- src/librustc_mir/build/matches/test.rs | 1 + src/librustc_mir/repr.rs | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/librustc_mir/build/matches/test.rs b/src/librustc_mir/build/matches/test.rs index d5745eb28c7..0d01df485fa 100644 --- a/src/librustc_mir/build/matches/test.rs +++ b/src/librustc_mir/build/matches/test.rs @@ -92,6 +92,7 @@ pub fn perform_test(&mut self, .collect(); self.cfg.terminate(block, Terminator::Switch { discr: lvalue.clone(), + adt_def: adt_def, targets: target_blocks.clone() }); target_blocks diff --git a/src/librustc_mir/repr.rs b/src/librustc_mir/repr.rs index 5bf326ba5a5..eb919f36cc3 100644 --- a/src/librustc_mir/repr.rs +++ b/src/librustc_mir/repr.rs @@ -247,6 +247,7 @@ pub enum Terminator<'tcx> { /// lvalue evaluates to some enum; jump depending on the branch Switch { discr: Lvalue<'tcx>, + adt_def: AdtDef<'tcx>, targets: Vec, }, @@ -279,7 +280,7 @@ pub fn successors(&self) -> &[BasicBlock] { Goto { target: ref b } => slice::ref_slice(b), Panic { target: ref b } => slice::ref_slice(b), If { cond: _, targets: ref b } => b, - Switch { discr: _, targets: ref b } => b, + Switch { discr: _, adt_def: _, targets: ref b } => b, Diverge => &[], Return => &[], Call { data: _, targets: ref b } => b, @@ -318,7 +319,7 @@ fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error> { write!(fmt, "panic -> {:?}", target), If { cond: ref lv, ref targets } => write!(fmt, "if({:?}) -> {:?}", lv, targets), - Switch { discr: ref lv, ref targets } => + Switch { discr: ref lv, adt_def: _, ref targets } => write!(fmt, "switch({:?}) -> {:?}", lv, targets), Diverge => write!(fmt, "diverge"),