Skip to content

Commit dc9e0bf

Browse files
committed
fix a strange ConstProp ICE
1 parent e685530 commit dc9e0bf

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

compiler/rustc_mir_transform/src/const_prop.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,11 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
393393
.layout_of(EarlyBinder(body.return_ty()).subst(tcx, substs))
394394
.ok()
395395
// Don't bother allocating memory for large values.
396-
.filter(|ret_layout| ret_layout.size < Size::from_bytes(MAX_ALLOC_LIMIT))
396+
// I don't know how return types can seem to be unsized but this happens in the
397+
// `type/type-unsatisfiable.rs` test.
398+
.filter(|ret_layout| {
399+
!ret_layout.is_unsized() && ret_layout.size < Size::from_bytes(MAX_ALLOC_LIMIT)
400+
})
397401
.unwrap_or_else(|| ecx.layout_of(tcx.types.unit).unwrap());
398402

399403
let ret = ecx

compiler/rustc_mir_transform/src/const_prop_lint.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,11 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
387387
.layout_of(EarlyBinder(body.return_ty()).subst(tcx, substs))
388388
.ok()
389389
// Don't bother allocating memory for large values.
390-
.filter(|ret_layout| ret_layout.size < Size::from_bytes(MAX_ALLOC_LIMIT))
390+
// I don't know how return types can seem to be unsized but this happens in the
391+
// `type/type-unsatisfiable.rs` test.
392+
.filter(|ret_layout| {
393+
!ret_layout.is_unsized() && ret_layout.size < Size::from_bytes(MAX_ALLOC_LIMIT)
394+
})
391395
.unwrap_or_else(|| ecx.layout_of(tcx.types.unit).unwrap());
392396

393397
let ret = ecx

0 commit comments

Comments
 (0)