diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index 8ceff303774..2013766aa39 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -35,6 +35,7 @@ use std::slice; use std::vec::IntoIter; use std::{iter, mem, option, u32}; use syntax::ast::{self, Name}; +use syntax::attr::SignedInt; use syntax::symbol::InternedString; use syntax_pos::{Span, DUMMY_SP}; use ty::fold::{TypeFoldable, TypeFolder, TypeVisitor}; @@ -2228,7 +2229,7 @@ pub fn fmt_const_val(fmt: &mut W, const_val: &ty::Const) -> fmt::Resul } } -pub fn print_miri_value(value: Value, ty: Ty, f: &mut W) -> fmt::Result { +pub fn print_miri_value<'tcx, W: Write>(value: Value, ty: Ty<'tcx>, f: &mut W) -> fmt::Result { use ty::TypeVariants::*; // print some primitives if let Value::Scalar(ScalarMaybeUndef::Scalar(Scalar::Bits { bits, .. })) = value { diff --git a/src/librustc_mir/hair/pattern/_match.rs b/src/librustc_mir/hair/pattern/_match.rs index 86f0e95a903..c666469f357 100644 --- a/src/librustc_mir/hair/pattern/_match.rs +++ b/src/librustc_mir/hair/pattern/_match.rs @@ -668,19 +668,14 @@ impl<'tcx> IntRange<'tcx> { ty::TyInt(_) => { // FIXME(49937): refactor these bit manipulations into interpret. let bits = tcx.layout_of(ty::ParamEnv::reveal_all().and(ty)) - .unwrap().size.bits() as u128; + .unwrap().size.bits() as u128; let min = 1u128 << (bits - 1); let mask = !0u128 >> (128 - bits); if encode { let offset = |x: u128| x.wrapping_sub(min) & mask; (offset(lo), offset(hi)) } else { - let offset = |x: u128| { - // FIXME: this shouldn't be necessary once `print_miri_value` - // sign-extends `TyInt`. - interpret::sign_extend(tcx, x.wrapping_add(min) & mask, ty) - .expect("layout error for TyInt") - }; + let offset = |x: u128| x.wrapping_add(min) & mask; (offset(lo), offset(hi)) } }