Simplify const_prop logic
This commit is contained in:
parent
524e575bb4
commit
b40f3c1060
1 changed files with 9 additions and 11 deletions
|
@ -385,19 +385,17 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
|
|||
(),
|
||||
);
|
||||
|
||||
let ret = if let Ok(layout) = ecx.layout_of(body.return_ty().subst(tcx, substs)) {
|
||||
let ret = ecx
|
||||
.layout_of(body.return_ty().subst(tcx, substs))
|
||||
.ok()
|
||||
// Don't bother allocating memory for ZST types which have no values
|
||||
// or for large values.
|
||||
if !layout.is_zst() && layout.size < Size::from_bytes(MAX_ALLOC_LIMIT) {
|
||||
// hopefully all types will allocate, since large types have already been removed,
|
||||
// but check anyways
|
||||
ecx.allocate(layout, MemoryKind::Stack).ok().map(Into::into)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
} else {
|
||||
None
|
||||
};
|
||||
.filter(|ret_layout| {
|
||||
!ret_layout.is_zst() && ret_layout.size < Size::from_bytes(MAX_ALLOC_LIMIT)
|
||||
})
|
||||
// hopefully all types will allocate, since large types have already been removed
|
||||
.and_then(|ret_layout| ecx.allocate(ret_layout, MemoryKind::Stack).ok())
|
||||
.map(Into::into);
|
||||
|
||||
ecx.push_stack_frame(
|
||||
Instance::new(def_id, substs),
|
||||
|
|
Loading…
Add table
Reference in a new issue