Skip to content

Commit 2348ab4

Browse files
committed
Revert "rustc_trans: don't write discriminants for uninhabited variants"
This reverts commit 4e28c61.
1 parent 3ab24df commit 2348ab4

File tree

2 files changed

+7
-42
lines changed

2 files changed

+7
-42
lines changed

src/librustc_trans/mir/lvalue.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -359,12 +359,14 @@ impl<'a, 'tcx> LvalueRef<'tcx> {
359359
/// Set the discriminant for a new value of the given case of the given
360360
/// representation.
361361
pub fn trans_set_discr(&self, bcx: &Builder<'a, 'tcx>, variant_index: usize) {
362-
if self.layout.for_variant(bcx.ccx, variant_index).abi == layout::Abi::Uninhabited {
363-
return;
364-
}
365-
match self.layout.variants {
362+
match self.layout.variants {
366363
layout::Variants::Single { index } => {
367-
assert_eq!(index, variant_index);
364+
if index != variant_index {
365+
// If the layout of an enum is `Single`, all
366+
// other variants are necessarily uninhabited.
367+
assert_eq!(self.layout.for_variant(bcx.ccx, variant_index).abi,
368+
layout::Abi::Uninhabited);
369+
}
368370
}
369371
layout::Variants::Tagged { .. } => {
370372
let ptr = self.project_field(bcx, 0);

src/test/run-pass/issue-46519.rs

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)