cfail test for #31886

This commit is contained in:
Alex Burka 2016-03-18 13:58:06 -04:00
parent ee4b607dfb
commit 9d0748f7eb
2 changed files with 20 additions and 10 deletions

View File

@ -0,0 +1,20 @@
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// With no repr attribute the discriminant will default to isize.
// On 32-bit architectures this is equivalent to i32 so the variants
// collide. On other architectures we need compilation to fail anyway,
// so force the repr.
#[cfg_attr(not(target_pointer_width = "32"), repr(i32))]
enum Eu64 {
Au64 = 0,
Bu64 = 0x8000_0000_0000_0000 //~ERROR already exists
}

View File

@ -47,12 +47,6 @@ enum Ei64 {
Bi64 = 0x8000_0000
}
#[derive(PartialEq)]
enum Eu64 {
Au64 = 0,
Bu64 = 0x8000_0000_0000_0000
}
pub fn main() {
assert_eq!(size_of::<Ei8>(), 1);
assert_eq!(size_of::<Eu8>(), 1);
@ -64,8 +58,4 @@ pub fn main() {
assert_eq!(size_of::<Ei64>(), 8);
#[cfg(target_pointer_width = "32")]
assert_eq!(size_of::<Ei64>(), 4);
assert_eq!(size_of::<Eu64>(), 8);
// ensure no i32 collisions
assert!(Eu64::Au64 != Eu64::Bu64);
}