From 4aa66dbe01758740fe1e716771db9fdfe9a2e07b Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Thu, 8 Feb 2018 17:15:41 +0200 Subject: [PATCH] rustc: don't ICE when using Rvalue::Discriminant on a non-ADT. --- src/librustc/mir/tcx.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/librustc/mir/tcx.rs b/src/librustc/mir/tcx.rs index 53607764b3984..7c6e065d6a31e 100644 --- a/src/librustc/mir/tcx.rs +++ b/src/librustc/mir/tcx.rs @@ -182,9 +182,8 @@ impl<'tcx> Rvalue<'tcx> { if let ty::TyAdt(adt_def, _) = ty.sty { adt_def.repr.discr_type().to_ty(tcx) } else { - // Undefined behaviour, bug for now; may want to return something for - // the `discriminant` intrinsic later. - bug!("Rvalue::Discriminant on Place of type {:?}", ty); + // This can only be `0`, for now, so `u8` will suffice. + tcx.types.u8 } } Rvalue::NullaryOp(NullOp::Box, t) => tcx.mk_box(t),