Skip to content

Commit 5aa713e

Browse files
committed
Eliminate an unwrap
1 parent 4e0af1f commit 5aa713e

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/librustc_mir/interpret/eval_context.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -320,17 +320,18 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc
320320
local: mir::Local,
321321
layout: Option<TyLayout<'tcx>>,
322322
) -> EvalResult<'tcx, TyLayout<'tcx>> {
323-
let cell = &frame.locals[local].layout;
324-
if cell.get().is_none() {
325-
let layout = ::interpret::operand::from_known_layout(layout, || {
326-
let local_ty = frame.mir.local_decls[local].ty;
327-
let local_ty = self.monomorphize_with_substs(local_ty, frame.instance.substs);
328-
self.layout_of(local_ty)
329-
})?;
330-
cell.set(Some(layout));
323+
match frame.locals[local].layout.get() {
324+
None => {
325+
let layout = ::interpret::operand::from_known_layout(layout, || {
326+
let local_ty = frame.mir.local_decls[local].ty;
327+
let local_ty = self.monomorphize_with_substs(local_ty, frame.instance.substs);
328+
self.layout_of(local_ty)
329+
})?;
330+
frame.locals[local].layout.set(Some(layout));
331+
Ok(layout)
332+
}
333+
Some(layout) => Ok(layout),
331334
}
332-
333-
Ok(cell.get().unwrap())
334335
}
335336

336337
pub fn str_to_immediate(&mut self, s: &str) -> EvalResult<'tcx, Immediate<M::PointerTag>> {

0 commit comments

Comments
 (0)