X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibrustc_mir%2Finterpret%2Fterminator.rs;h=ff8d6804febbd057e5377d25c321dbd8b0e1e34e;hb=80ff07f30d01da3bed8316af81d3836254ea1769;hp=ba48a28fc83159d2b6b58243ca4202ab9a1c55c3;hpb=bdf24732897e17120753244f76dceba04a027e7d;p=rust.git diff --git a/src/librustc_mir/interpret/terminator.rs b/src/librustc_mir/interpret/terminator.rs index ba48a28fc83..ff8d6804feb 100644 --- a/src/librustc_mir/interpret/terminator.rs +++ b/src/librustc_mir/interpret/terminator.rs @@ -1,18 +1,19 @@ use std::borrow::Cow; use rustc::{mir, ty}; +use rustc::ty::Instance; use rustc::ty::layout::{self, TyLayout, LayoutOf}; use syntax::source_map::Span; use rustc_target::spec::abi::Abi; -use rustc::mir::interpret::{EvalResult, PointerArithmetic, InterpError, Scalar}; +use rustc::mir::interpret::{InterpResult, PointerArithmetic, InterpError, Scalar}; use super::{ InterpretCx, Machine, Immediate, OpTy, ImmTy, PlaceTy, MPlaceTy, StackPopCleanup }; impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> InterpretCx<'a, 'mir, 'tcx, M> { #[inline] - pub fn goto_block(&mut self, target: Option) -> EvalResult<'tcx> { + pub fn goto_block(&mut self, target: Option) -> InterpResult<'tcx> { if let Some(target) = target { self.frame_mut().block = target; self.frame_mut().stmt = 0; @@ -25,7 +26,7 @@ pub fn goto_block(&mut self, target: Option) -> EvalResult<'tcx pub(super) fn eval_terminator( &mut self, terminator: &mir::Terminator<'tcx>, - ) -> EvalResult<'tcx> { + ) -> InterpResult<'tcx> { use rustc::mir::TerminatorKind::*; match terminator.kind { Return => { @@ -112,7 +113,7 @@ pub(super) fn eval_terminator( let ty = place.layout.ty; trace!("TerminatorKind::drop: {:?}, type {}", location, ty); - let instance = crate::monomorphize::resolve_drop_in_place(*self.tcx, ty); + let instance = Instance::resolve_drop_in_place(*self.tcx, ty); self.drop_in_place( place, instance, @@ -205,7 +206,7 @@ fn pass_argument( rust_abi: bool, caller_arg: &mut impl Iterator>, callee_arg: PlaceTy<'tcx, M::PointerTag>, - ) -> EvalResult<'tcx> { + ) -> InterpResult<'tcx> { if rust_abi && callee_arg.layout.is_zst() { // Nothing to do. trace!("Skipping callee ZST"); @@ -233,7 +234,7 @@ fn eval_fn_call( args: &[OpTy<'tcx, M::PointerTag>], dest: Option>, ret: Option, - ) -> EvalResult<'tcx> { + ) -> InterpResult<'tcx> { trace!("eval_fn_call: {:#?}", instance); match instance.def { @@ -280,15 +281,15 @@ fn eval_fn_call( } // We need MIR for this fn - let mir = match M::find_fn(self, instance, args, dest, ret)? { - Some(mir) => mir, + let body = match M::find_fn(self, instance, args, dest, ret)? { + Some(body) => body, None => return Ok(()), }; self.push_stack_frame( instance, span, - mir, + body, dest, StackPopCleanup::Goto(ret), )?; @@ -306,8 +307,8 @@ fn eval_fn_call( ); trace!( "spread_arg: {:?}, locals: {:#?}", - mir.spread_arg, - mir.args_iter() + body.spread_arg, + body.args_iter() .map(|local| (local, self.layout_of_local(self.frame(), local, None).unwrap().ty) ) @@ -336,7 +337,7 @@ fn eval_fn_call( .chain((0..untuple_arg.layout.fields.count()).into_iter() .map(|i| self.operand_field(untuple_arg, i as u64)) ) - .collect::>>>()?) + .collect::>>>()?) } else { // Plain arg passing Cow::from(args) @@ -351,12 +352,12 @@ fn eval_fn_call( // this is a single iterator (that handles `spread_arg`), then // `pass_argument` would be the loop body. It takes care to // not advance `caller_iter` for ZSTs. - let mut locals_iter = mir.args_iter(); + let mut locals_iter = body.args_iter(); while let Some(local) = locals_iter.next() { let dest = self.eval_place( &mir::Place::Base(mir::PlaceBase::Local(local)) )?; - if Some(local) == mir.spread_arg { + if Some(local) == body.spread_arg { // Must be a tuple for i in 0..dest.layout.fields.count() { let dest = self.place_field(dest, i as u64)?; @@ -456,7 +457,7 @@ fn drop_in_place( instance: ty::Instance<'tcx>, span: Span, target: mir::BasicBlock, - ) -> EvalResult<'tcx> { + ) -> InterpResult<'tcx> { trace!("drop_in_place: {:?},\n {:?}, {:?}", *place, place.layout.ty, instance); // We take the address of the object. This may well be unaligned, which is fine // for us here. However, unaligned accesses will probably make the actual drop