about summary refs log tree commit diff
path: root/src/librustc_codegen_llvm
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-11-12 04:12:26 +0000
committerbors <bors@rust-lang.org>2018-11-12 04:12:26 +0000
commitd1d79ae3ad36e82e2be33bea108d6a4e98ddce0b (patch)
tree63d8ea35513193538b311443d50f1606ccdeff3b /src/librustc_codegen_llvm
parentd8f4c9ffacc0da52db27923aa69dda64e9e14b01 (diff)
parent4d20dd4b788a9e825bac43c8c0b0b4858de78296 (diff)
downloadrust-d1d79ae3ad36e82e2be33bea108d6a4e98ddce0b.tar.gz
rust-d1d79ae3ad36e82e2be33bea108d6a4e98ddce0b.zip
Auto merge of #55701 - tromey:ice-fix, r=matthewjasper
Fix emission of niche-filling discriminant values

Bug #55606 points out a regression introduced by #54004; namely that
an assertion can erroneously fire when a niche-filling discriminant
value is emitted.

This fixes the bug by removing the assertion, and furthermore by
arranging for the discriminant value to be masked according to the
size of the niche.  This makes handling the discriminant a bit simpler
for debuggers.

The test case is from Jonathan Turner.

Closes #55606
Diffstat (limited to 'src/librustc_codegen_llvm')
-rw-r--r--src/librustc_codegen_llvm/debuginfo/metadata.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/librustc_codegen_llvm/debuginfo/metadata.rs b/src/librustc_codegen_llvm/debuginfo/metadata.rs
index 00f06645930..38b3a1b9c1a 100644
--- a/src/librustc_codegen_llvm/debuginfo/metadata.rs
+++ b/src/librustc_codegen_llvm/debuginfo/metadata.rs
@@ -1279,7 +1279,7 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> {
                 niche_start,
                 ref variants,
                 dataful_variant,
-                ..
+                ref niche,
             } => {
                 if fallback {
                     let variant = self.layout.for_variant(cx, dataful_variant);
@@ -1361,11 +1361,11 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> {
                         let niche_value = if i == dataful_variant {
                             None
                         } else {
-                            let niche = (i as u128)
+                            let value = (i as u128)
                                 .wrapping_sub(*niche_variants.start() as u128)
                                 .wrapping_add(niche_start);
-                            assert_eq!(niche as u64 as u128, niche);
-                            Some(niche as u64)
+                            let value = value & ((1u128 << niche.value.size(cx).bits()) - 1);
+                            Some(value as u64)
                         };
 
                         MemberDescription {