derive: assume enum repr defaults to isize
It was originally intended to be i32, but it isn't. Fixes #31886.
This commit is contained in:
parent
235d77457d
commit
ee4b607dfb
@ -758,7 +758,7 @@ impl<'a> TraitDef<'a> {
|
|||||||
|
|
||||||
fn find_repr_type_name(diagnostic: &Handler,
|
fn find_repr_type_name(diagnostic: &Handler,
|
||||||
type_attrs: &[ast::Attribute]) -> &'static str {
|
type_attrs: &[ast::Attribute]) -> &'static str {
|
||||||
let mut repr_type_name = "i32";
|
let mut repr_type_name = "isize";
|
||||||
for a in type_attrs {
|
for a in type_attrs {
|
||||||
for r in &attr::find_repr_attrs(diagnostic, a) {
|
for r in &attr::find_repr_attrs(diagnostic, a) {
|
||||||
repr_type_name = match *r {
|
repr_type_name = match *r {
|
||||||
|
@ -47,6 +47,12 @@ enum Ei64 {
|
|||||||
Bi64 = 0x8000_0000
|
Bi64 = 0x8000_0000
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(PartialEq)]
|
||||||
|
enum Eu64 {
|
||||||
|
Au64 = 0,
|
||||||
|
Bu64 = 0x8000_0000_0000_0000
|
||||||
|
}
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
assert_eq!(size_of::<Ei8>(), 1);
|
assert_eq!(size_of::<Ei8>(), 1);
|
||||||
assert_eq!(size_of::<Eu8>(), 1);
|
assert_eq!(size_of::<Eu8>(), 1);
|
||||||
@ -58,4 +64,8 @@ pub fn main() {
|
|||||||
assert_eq!(size_of::<Ei64>(), 8);
|
assert_eq!(size_of::<Ei64>(), 8);
|
||||||
#[cfg(target_pointer_width = "32")]
|
#[cfg(target_pointer_width = "32")]
|
||||||
assert_eq!(size_of::<Ei64>(), 4);
|
assert_eq!(size_of::<Ei64>(), 4);
|
||||||
|
assert_eq!(size_of::<Eu64>(), 8);
|
||||||
|
|
||||||
|
// ensure no i32 collisions
|
||||||
|
assert!(Eu64::Au64 != Eu64::Bu64);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user