mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 16:54:01 +00:00
Eliminate an unwrap
This commit is contained in:
parent
4e0af1fee1
commit
5aa713e1c3
@ -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() {
|
||||
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));
|
||||
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)
|
||||
})?;
|
||||
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>> {
|
||||
|
Loading…
Reference in New Issue
Block a user