Skip to content

Commit ada6f1c

Browse files
committed
rustc_mir: make subst_from_frame_and_normalize_erasing_regions infallible.
1 parent b4f217e commit ada6f1c

File tree

3 files changed

+10
-17
lines changed

3 files changed

+10
-17
lines changed

src/librustc_mir/interpret/eval_context.rs

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -315,23 +315,16 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
315315
}
316316

317317
/// Call this on things you got out of the MIR (so it is as generic as the current
318-
/// stack rameframe), to bring it into the proper environment for this interpreter.
318+
/// stack frame), to bring it into the proper environment for this interpreter.
319319
pub(super) fn subst_from_frame_and_normalize_erasing_regions<T: TypeFoldable<'tcx>>(
320320
&self,
321-
t: T,
322-
) -> InterpResult<'tcx, T> {
323-
match self.stack.last() {
324-
Some(frame) => Ok(self.tcx.subst_and_normalize_erasing_regions(
325-
frame.instance.substs,
326-
self.param_env,
327-
&t,
328-
)),
329-
None => if t.needs_subst() {
330-
throw_inval!(TooGeneric)
331-
} else {
332-
Ok(t)
333-
},
334-
}
321+
value: T,
322+
) -> T {
323+
self.tcx.subst_and_normalize_erasing_regions(
324+
self.frame().instance.substs,
325+
self.param_env,
326+
&value,
327+
)
335328
}
336329

337330
/// The `substs` are assumed to already be in our interpreter "universe" (param_env).

src/librustc_mir/interpret/place.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ where
643643
layout: self.layout_of(
644644
self.subst_from_frame_and_normalize_erasing_regions(
645645
self.frame().body.return_ty()
646-
)?
646+
)
647647
)?,
648648
}
649649
}

src/librustc_mir/interpret/step.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
254254
}
255255

256256
NullaryOp(mir::NullOp::SizeOf, ty) => {
257-
let ty = self.subst_from_frame_and_normalize_erasing_regions(ty)?;
257+
let ty = self.subst_from_frame_and_normalize_erasing_regions(ty);
258258
let layout = self.layout_of(ty)?;
259259
assert!(!layout.is_unsized(),
260260
"SizeOf nullary MIR operator called for unsized type");

0 commit comments

Comments
 (0)