-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix emission of niche-filling discriminant values #55701
Conversation
Bug rust-lang#55606 points out a regression introduced by rust-lang#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 rust-lang#55606
(rust_highfive has picked a reviewer for you, use r? to override) |
// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Error",{{.*}}extraData: i64 0{{[,)].*}} | ||
|
||
#![feature(never_type)] | ||
#![feature(nll)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This appears to be unnecessary
@bors r+ |
📌 Commit 4d20dd4 has been approved by |
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
☀️ Test successful - status-appveyor, status-travis |
.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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing the assert is wrong, because you're throwing away bits just below!
After this change, assert_eq!(value as u64 as u128, value);
should be between the truncation (let value = value & ...;
) and the lossy cast (value as u64
).
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