break enum variant discriminant inference in case of 32-bit
`assert_eq!(-9223372036854775808isize as u64, 0x8000000000000000);`
fails on 32 bit and succeeds on 64 bit. These commits don't change that behavior.
The following worked before my changes, because the discriminant was
always processed as `u64`.
Now it fails, because the discriminant of `Bu64` is now `0` instead of `-9223372036854775808`. This is more in line with the above assertion's code, since
`-9223372036854775808isize as u64` on 32 bit yielded `0`.
```rust
enum Eu64 {
Au64 = 0,
Bu64 = 0x8000_0000_0000_0000
}
```
This commit is contained in:
parent
d4d6260ef1
commit
fcee002edf
1 changed files with 4 additions and 6 deletions
|
|
@ -8,6 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(stmt_expr_attributes)]
|
||||
|
||||
use std::mem::size_of;
|
||||
|
||||
|
|
@ -46,11 +47,6 @@ enum Ei64 {
|
|||
Bi64 = 0x8000_0000
|
||||
}
|
||||
|
||||
enum Eu64 {
|
||||
Au64 = 0,
|
||||
Bu64 = 0x8000_0000_0000_0000
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
assert_eq!(size_of::<Ei8>(), 1);
|
||||
assert_eq!(size_of::<Eu8>(), 1);
|
||||
|
|
@ -58,6 +54,8 @@ pub fn main() {
|
|||
assert_eq!(size_of::<Eu16>(), 2);
|
||||
assert_eq!(size_of::<Ei32>(), 4);
|
||||
assert_eq!(size_of::<Eu32>(), 4);
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
assert_eq!(size_of::<Ei64>(), 8);
|
||||
assert_eq!(size_of::<Eu64>(), 8);
|
||||
#[cfg(target_pointer_width = "32")]
|
||||
assert_eq!(size_of::<Ei64>(), 4);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue