about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2021-11-14 13:28:47 -0500
committerRalf Jung <post@ralfj.de>2021-11-14 13:29:21 -0500
commiteebf676bf8f76fcdfa610e7e46ab6c135a9cd2d0 (patch)
tree214d029f6c2f58a6ba84b5e830db1856e2159144 /compiler
parentc8e94975a6541e947a1bd4971e084c8ba637f2b6 (diff)
downloadrust-eebf676bf8f76fcdfa610e7e46ab6c135a9cd2d0.tar.gz
rust-eebf676bf8f76fcdfa610e7e46ab6c135a9cd2d0.zip
fix getting the discriminant of a zero-variant enum
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_middle/src/ty/sty.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs
index e57075ed338..59601e14849 100644
--- a/compiler/rustc_middle/src/ty/sty.rs
+++ b/compiler/rustc_middle/src/ty/sty.rs
@@ -2067,7 +2067,9 @@ impl<'tcx> TyS<'tcx> {
     ) -> Option<Discr<'tcx>> {
         match self.kind() {
             TyKind::Adt(adt, _) if adt.variants.is_empty() => {
-                bug!("discriminant_for_variant called on zero variant enum");
+                // This can actually happen during CTFE, see
+                // https://github.com/rust-lang/rust/issues/89765.
+                None
             }
             TyKind::Adt(adt, _) if adt.is_enum() => {
                 Some(adt.discriminant_for_variant(tcx, variant_index))