1
Fork 0

rustc_mir: make subst_from_frame_and_normalize_erasing_regions infallible.

This commit is contained in:
Eduard-Mihai Burtescu 2019-08-12 16:32:48 +03:00
parent b4f217ed7b
commit ada6f1cd3d
3 changed files with 10 additions and 17 deletions

View file

@ -315,23 +315,16 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
} }
/// Call this on things you got out of the MIR (so it is as generic as the current /// Call this on things you got out of the MIR (so it is as generic as the current
/// stack rameframe), to bring it into the proper environment for this interpreter. /// stack frame), to bring it into the proper environment for this interpreter.
pub(super) fn subst_from_frame_and_normalize_erasing_regions<T: TypeFoldable<'tcx>>( pub(super) fn subst_from_frame_and_normalize_erasing_regions<T: TypeFoldable<'tcx>>(
&self, &self,
t: T, value: T,
) -> InterpResult<'tcx, T> { ) -> T {
match self.stack.last() { self.tcx.subst_and_normalize_erasing_regions(
Some(frame) => Ok(self.tcx.subst_and_normalize_erasing_regions( self.frame().instance.substs,
frame.instance.substs, self.param_env,
self.param_env, &value,
&t, )
)),
None => if t.needs_subst() {
throw_inval!(TooGeneric)
} else {
Ok(t)
},
}
} }
/// The `substs` are assumed to already be in our interpreter "universe" (param_env). /// The `substs` are assumed to already be in our interpreter "universe" (param_env).

View file

@ -643,7 +643,7 @@ where
layout: self.layout_of( layout: self.layout_of(
self.subst_from_frame_and_normalize_erasing_regions( self.subst_from_frame_and_normalize_erasing_regions(
self.frame().body.return_ty() self.frame().body.return_ty()
)? )
)?, )?,
} }
} }

View file

@ -254,7 +254,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
} }
NullaryOp(mir::NullOp::SizeOf, ty) => { NullaryOp(mir::NullOp::SizeOf, ty) => {
let ty = self.subst_from_frame_and_normalize_erasing_regions(ty)?; let ty = self.subst_from_frame_and_normalize_erasing_regions(ty);
let layout = self.layout_of(ty)?; let layout = self.layout_of(ty)?;
assert!(!layout.is_unsized(), assert!(!layout.is_unsized(),
"SizeOf nullary MIR operator called for unsized type"); "SizeOf nullary MIR operator called for unsized type");