mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-05 13:13:40 +00:00
rustc_mir: make subst_from_frame_and_normalize_erasing_regions infallible.
This commit is contained in:
parent
b4f217ed7b
commit
ada6f1cd3d
@ -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");
|
||||
|
Loading…
Reference in New Issue
Block a user