diff --git a/src/interpreter.rs b/src/interpreter.rs index e71bd8d06188..8db2f18f46fa 100644 --- a/src/interpreter.rs +++ b/src/interpreter.rs @@ -158,16 +158,15 @@ impl<'a, 'tcx: 'a> Interpreter<'a, 'tcx> { } SwitchInt { ref discr, ref values, ref targets, .. } => { - // FIXME(tsion): Handle non-integer switch types. let (discr_ptr, discr_repr) = try!(self.eval_lvalue(discr)); - let discr_val = try!(self.memory.read_i64(discr_ptr)); + let discr_val = try!(self.memory.read_primval(discr_ptr, &discr_repr)); // Branch to the `otherwise` case by default, if no match is found. current_block = targets[targets.len() - 1]; for (index, val_const) in values.iter().enumerate() { let ptr = try!(self.const_to_ptr(val_const)); - let val = try!(self.memory.read_i64(ptr)); + let val = try!(self.memory.read_primval(ptr, &discr_repr)); if discr_val == val { current_block = targets[index]; break; diff --git a/test/bools.rs b/test/bools.rs index 416d4e5f5fee..e835d3e87e4b 100755 --- a/test/bools.rs +++ b/test/bools.rs @@ -16,11 +16,11 @@ fn if_true() -> i64 { if true { 1 } else { 0 } } -// #[miri_run] -// fn match_bool() -> i64 { -// let b = true; -// match b { -// true => 1, -// false => 0, -// } -// } +#[miri_run] +fn match_bool() -> i16 { + let b = true; + match b { + true => 1, + _ => 0, + } +} diff --git a/test/ints.rs b/test/ints.rs index 1885ba48340d..7270a79c32b0 100644 --- a/test/ints.rs +++ b/test/ints.rs @@ -24,13 +24,13 @@ fn indirect_add() -> i64 { } #[miri_run] -fn arith() -> i64 { +fn arith() -> i32 { 3*3 + 4*4 } #[miri_run] -fn match_int() -> i64 { - let n = 2i64; +fn match_int() -> i16 { + let n = 2; match n { 0 => 0, 1 => 10,