Skip to content

Commit 081bc75

Browse files
committed
Assume the frame has all the locals.
1 parent 0e64ce7 commit 081bc75

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

compiler/rustc_const_eval/src/interpret/eval_context.rs

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -536,24 +536,20 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
536536
local: mir::Local,
537537
layout: Option<TyAndLayout<'tcx>>,
538538
) -> InterpResult<'tcx, TyAndLayout<'tcx>> {
539-
// `const_prop` runs into this with an invalid (empty) frame, so we
540-
// have to support that case (mostly by skipping all caching).
541-
match frame.locals.get(local).and_then(|state| state.layout.get()) {
542-
None => {
543-
let layout = from_known_layout(self.tcx, self.param_env, layout, || {
544-
let local_ty = frame.body.local_decls[local].ty;
545-
let local_ty =
546-
self.subst_from_frame_and_normalize_erasing_regions(frame, local_ty)?;
547-
self.layout_of(local_ty)
548-
})?;
549-
if let Some(state) = frame.locals.get(local) {
550-
// Layouts of locals are requested a lot, so we cache them.
551-
state.layout.set(Some(layout));
552-
}
553-
Ok(layout)
554-
}
555-
Some(layout) => Ok(layout),
539+
let state = &frame.locals[local];
540+
if let Some(layout) = state.layout.get() {
541+
return Ok(layout);
556542
}
543+
544+
let layout = from_known_layout(self.tcx, self.param_env, layout, || {
545+
let local_ty = frame.body.local_decls[local].ty;
546+
let local_ty = self.subst_from_frame_and_normalize_erasing_regions(frame, local_ty)?;
547+
self.layout_of(local_ty)
548+
})?;
549+
550+
// Layouts of locals are requested a lot, so we cache them.
551+
state.layout.set(Some(layout));
552+
Ok(layout)
557553
}
558554

559555
/// Returns the actual dynamic size and alignment of the place at the given type.

0 commit comments

Comments
 (0)