Skip to content
Permalink
Browse files

rustc_mir: make subst_from_frame_and_normalize_erasing_regions infall…

…ible.
  • Loading branch information...
eddyb committed Aug 12, 2019
1 parent b4f217e commit ada6f1cd3db78f2972275c24f50721467aea4c70
@@ -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
/// 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>>(
&self,
t: T,
) -> InterpResult<'tcx, T> {
match self.stack.last() {
Some(frame) => Ok(self.tcx.subst_and_normalize_erasing_regions(
frame.instance.substs,
self.param_env,
&t,
)),
None => if t.needs_subst() {
throw_inval!(TooGeneric)
} else {
Ok(t)
},
}
value: T,
) -> T {
self.tcx.subst_and_normalize_erasing_regions(
self.frame().instance.substs,
self.param_env,
&value,
)
}

/// The `substs` are assumed to already be in our interpreter "universe" (param_env).
@@ -643,7 +643,7 @@ where
layout: self.layout_of(
self.subst_from_frame_and_normalize_erasing_regions(
self.frame().body.return_ty()
)?
)
)?,
}
}
@@ -254,7 +254,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
}

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)?;
assert!(!layout.is_unsized(),
"SizeOf nullary MIR operator called for unsized type");

0 comments on commit ada6f1c

Please sign in to comment.
You can’t perform that action at this time.