Update for changes in rustc.

This commit is contained in:
Scott Olson 2016-11-06 22:25:54 -08:00
parent 33b1676bda
commit a8d90ff12e
2 changed files with 15 additions and 12 deletions

View File

@ -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))),
}

View File

@ -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);