diff --git a/src/interpreter/cast.rs b/src/interpreter/cast.rs index 70b39fc882e..f14baa2446c 100644 --- a/src/interpreter/cast.rs +++ b/src/interpreter/cast.rs @@ -92,21 +92,24 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { } fn cast_ptr(&self, ptr: Pointer, ty: Ty<'tcx>) -> EvalResult<'tcx, PrimVal> { - use primval::PrimValKind::*; use rustc::ty::TypeVariants::*; match ty.sty { TyRef(..) | TyRawPtr(_) => Ok(PrimVal::from_ptr(ptr)), TyFnPtr(_) => Ok(PrimVal::from_fn_ptr(ptr)), - TyInt(IntTy::I8) => Ok(PrimVal::new(ptr.to_int()? as u64, I8)), - TyInt(IntTy::I16) => Ok(PrimVal::new(ptr.to_int()? as u64, I16)), - TyInt(IntTy::I32) => Ok(PrimVal::new(ptr.to_int()? as u64, I32)), - TyInt(IntTy::I64) => Ok(PrimVal::new(ptr.to_int()? as u64, I64)), - - TyUint(UintTy::U8) => Ok(PrimVal::new(ptr.to_int()? as u64, U8)), - TyUint(UintTy::U16) => Ok(PrimVal::new(ptr.to_int()? as u64, U16)), - TyUint(UintTy::U32) => Ok(PrimVal::new(ptr.to_int()? as u64, U32)), - TyUint(UintTy::U64) => Ok(PrimVal::new(ptr.to_int()? as u64, U64)), + TyInt(IntTy::I8) | + TyInt(IntTy::I16) | + TyInt(IntTy::I32) | + TyInt(IntTy::I64) | + TyInt(IntTy::Is) | + TyUint(UintTy::U8) | + TyUint(UintTy::U16) | + TyUint(UintTy::U32) | + TyUint(UintTy::U64) | + TyUint(UintTy::Us) => { + let val = PrimVal::from_ptr(ptr); + self.transmute_primval(val, ty) + } _ => Err(EvalError::Unimplemented(format!("ptr to {:?} cast", ty))), } diff --git a/src/interpreter/mod.rs b/src/interpreter/mod.rs index 689ef924536..b15f8b2d2d8 100644 --- a/src/interpreter/mod.rs +++ b/src/interpreter/mod.rs @@ -1699,13 +1699,13 @@ pub fn run_mir_passes<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { let mut passes = ::rustc::mir::transform::Passes::new(); passes.push_hook(Box::new(::rustc_mir::transform::dump_mir::DumpMir)); passes.push_pass(Box::new(::rustc_mir::transform::no_landing_pads::NoLandingPads)); - passes.push_pass(Box::new(::rustc_mir::transform::simplify_cfg::SimplifyCfg::new("no-landing-pads"))); + passes.push_pass(Box::new(::rustc_mir::transform::simplify::SimplifyCfg::new("no-landing-pads"))); passes.push_pass(Box::new(::rustc_mir::transform::erase_regions::EraseRegions)); passes.push_pass(Box::new(::rustc_borrowck::ElaborateDrops)); passes.push_pass(Box::new(::rustc_mir::transform::no_landing_pads::NoLandingPads)); - passes.push_pass(Box::new(::rustc_mir::transform::simplify_cfg::SimplifyCfg::new("elaborate-drops"))); + passes.push_pass(Box::new(::rustc_mir::transform::simplify::SimplifyCfg::new("elaborate-drops"))); passes.push_pass(Box::new(::rustc_mir::transform::dump_mir::Marker("PreMiri"))); passes.run_passes(tcx);