Skip to content

Commit d3fa68e

Browse files
committed
Fix an ICE that can occur while errors are already being emitted
1 parent a30e836 commit d3fa68e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/librustc/ty/sty.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1975,8 +1975,12 @@ impl<'tcx> Const<'tcx> {
19751975
ty: ParamEnvAnd<'tcx, Ty<'tcx>>,
19761976
) -> &'tcx Self {
19771977
let ty = tcx.lift_to_global(&ty).unwrap();
1978-
let layout = tcx.layout_of(ty).unwrap_or_else(|e| {
1979-
panic!("could not compute layout for {:?}: {:?}", ty, e)
1978+
let layout = tcx.layout_of(ty).unwrap_or_else(|_| {
1979+
// FIXME: add delay_span_bug call, we can only get here if there are errors
1980+
// we produce a weird dummy layout with somewhat sane values
1981+
let mut layout = tcx.layout_of(ParamEnv::reveal_all().and(tcx.types.u128)).unwrap();
1982+
layout.ty = ty.value;
1983+
layout
19801984
});
19811985
let mut bytes = [0_u8; 16];
19821986
let endian = tcx.data_layout.endian;

0 commit comments

Comments
 (0)