diff --git a/src/interpreter/terminator/mod.rs b/src/interpreter/terminator/mod.rs index 823caae623e0..38768483d1d8 100644 --- a/src/interpreter/terminator/mod.rs +++ b/src/interpreter/terminator/mod.rs @@ -104,13 +104,10 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { } Drop { ref location, target, .. } => { - // FIXME(solson) - let lvalue = self.eval_lvalue(location)?; - let lvalue = self.force_allocation(lvalue)?; + let val = self.eval_and_read_lvalue(location)?; - let ptr = lvalue.to_ptr(); let ty = self.lvalue_ty(location); - self.drop(ptr, ty)?; + self.drop(val, ty)?; self.goto_block(target); } @@ -471,7 +468,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { self.tcx.type_needs_drop_given_env(ty, &self.tcx.empty_parameter_environment()) } - fn drop(&mut self, ptr: Pointer, ty: Ty<'tcx>) -> EvalResult<'tcx, ()> { + fn drop(&mut self, val: Value, ty: Ty<'tcx>) -> EvalResult<'tcx, ()> { if !self.type_needs_drop(ty) { debug!("no need to drop {:?}", ty); return Ok(()); @@ -482,7 +479,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { match ty.sty { ty::TyBox(_contents_ty) => { - let contents_ptr = self.memory.read_ptr(ptr)?; + let contents_ptr = val.read_ptr(&self.memory)?; // self.drop(contents_ptr, contents_ty)?; trace!("-deallocating box"); self.memory.deallocate(contents_ptr)?; diff --git a/src/interpreter/value.rs b/src/interpreter/value.rs index 22698f978184..d9285a41e41a 100644 --- a/src/interpreter/value.rs +++ b/src/interpreter/value.rs @@ -23,12 +23,9 @@ impl<'a, 'tcx: 'a> Value { match *self { ByRef(ptr) => mem.read_ptr(ptr), - ByVal(ptr) if ptr.try_as_ptr().is_some() => { - Ok(ptr.try_as_ptr().unwrap()) + ByVal(ptr) | ByValPair(ptr, _) => { + Ok(ptr.try_as_ptr().expect("unimplemented: `read_ptr` on non-ptr primval")) } - - ByValPair(..) => unimplemented!(), - ByVal(_other) => unimplemented!(), } }