Eliminate an unwrap

This commit is contained in:
Oliver Scherer 2019-01-30 15:51:20 +01:00
parent 4e0af1fee1
commit 5aa713e1c3

View File

@ -320,17 +320,18 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc
local: mir::Local,
layout: Option<TyLayout<'tcx>>,
) -> EvalResult<'tcx, TyLayout<'tcx>> {
let cell = &frame.locals[local].layout;
if cell.get().is_none() {
match frame.locals[local].layout.get() {
None => {
let layout = ::interpret::operand::from_known_layout(layout, || {
let local_ty = frame.mir.local_decls[local].ty;
let local_ty = self.monomorphize_with_substs(local_ty, frame.instance.substs);
self.layout_of(local_ty)
})?;
cell.set(Some(layout));
frame.locals[local].layout.set(Some(layout));
Ok(layout)
}
Some(layout) => Ok(layout),
}
Ok(cell.get().unwrap())
}
pub fn str_to_immediate(&mut self, s: &str) -> EvalResult<'tcx, Immediate<M::PointerTag>> {