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
This commit is contained in:
commit
d1d79ae3ad
2 changed files with 67 additions and 4 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue