Skip to content

Commit 700b226

Browse files
committed
derive: assume enum repr defaults to i64
It was originally intended to be i32, but it isn't. Fixes rust-lang#31886.
1 parent 2321994 commit 700b226

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/libsyntax_ext/deriving/generic/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ impl<'a> TraitDef<'a> {
757757

758758
fn find_repr_type_name(diagnostic: &Handler,
759759
type_attrs: &[ast::Attribute]) -> &'static str {
760-
let mut repr_type_name = "i32";
760+
let mut repr_type_name = "i64";
761761
for a in type_attrs {
762762
for r in &attr::find_repr_attrs(diagnostic, a) {
763763
repr_type_name = match *r {

src/test/run-pass/enum-discrim-autosizing.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ enum Ei64 {
4646
Bi64 = 0x8000_0000
4747
}
4848

49+
#[derive(PartialEq)]
4950
enum Eu64 {
5051
Au64 = 0,
5152
Bu64 = 0x8000_0000_0000_0000
@@ -60,4 +61,7 @@ pub fn main() {
6061
assert_eq!(size_of::<Eu32>(), 4);
6162
assert_eq!(size_of::<Ei64>(), 8);
6263
assert_eq!(size_of::<Eu64>(), 8);
64+
65+
// ensure no i32 collisions
66+
assert!(Eu64::Au64 != Eu64::Bu64);
6367
}

0 commit comments

Comments
 (0)