2023-09-12 18:13:53 +02:00
|
|
|
//@ignore-32bit
|
2017-09-18 12:47:33 +02:00
|
|
|
|
2020-01-30 11:43:19 +09:00
|
|
|
#![warn(clippy::enum_clike_unportable_variant)]
|
|
|
|
#![allow(unused, non_upper_case_globals)]
|
2016-02-29 09:36:13 +01:00
|
|
|
|
|
|
|
#[repr(usize)]
|
|
|
|
enum NonPortable {
|
2017-02-08 14:58:07 +01:00
|
|
|
X = 0x1_0000_0000,
|
2023-08-24 21:32:12 +02:00
|
|
|
//~^ ERROR: C-like enum variant discriminant is not portable to 32-bit targets
|
|
|
|
//~| NOTE: `-D clippy::enum-clike-unportable-variant` implied by `-D warnings`
|
2016-02-29 09:36:13 +01:00
|
|
|
Y = 0,
|
|
|
|
Z = 0x7FFF_FFFF,
|
|
|
|
A = 0xFFFF_FFFF,
|
|
|
|
}
|
|
|
|
|
|
|
|
enum NonPortableNoHint {
|
2017-02-08 14:58:07 +01:00
|
|
|
X = 0x1_0000_0000,
|
2023-08-24 21:32:12 +02:00
|
|
|
//~^ ERROR: C-like enum variant discriminant is not portable to 32-bit targets
|
2016-02-29 09:36:13 +01:00
|
|
|
Y = 0,
|
|
|
|
Z = 0x7FFF_FFFF,
|
2017-02-08 14:58:07 +01:00
|
|
|
A = 0xFFFF_FFFF,
|
2023-08-24 21:32:12 +02:00
|
|
|
//~^ ERROR: C-like enum variant discriminant is not portable to 32-bit targets
|
2016-02-29 09:36:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#[repr(isize)]
|
|
|
|
enum NonPortableSigned {
|
|
|
|
X = -1,
|
|
|
|
Y = 0x7FFF_FFFF,
|
2017-02-08 14:58:07 +01:00
|
|
|
Z = 0xFFFF_FFFF,
|
2023-08-24 21:32:12 +02:00
|
|
|
//~^ ERROR: C-like enum variant discriminant is not portable to 32-bit targets
|
2017-02-08 14:58:07 +01:00
|
|
|
A = 0x1_0000_0000,
|
2023-08-24 21:32:12 +02:00
|
|
|
//~^ ERROR: C-like enum variant discriminant is not portable to 32-bit targets
|
2020-04-08 00:04:33 +02:00
|
|
|
B = i32::MIN as isize,
|
|
|
|
C = (i32::MIN as isize) - 1,
|
2023-08-24 21:32:12 +02:00
|
|
|
//~^ ERROR: C-like enum variant discriminant is not portable to 32-bit targets
|
2016-02-29 09:36:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
enum NonPortableSignedNoHint {
|
|
|
|
X = -1,
|
|
|
|
Y = 0x7FFF_FFFF,
|
2017-02-08 14:58:07 +01:00
|
|
|
Z = 0xFFFF_FFFF,
|
2023-08-24 21:32:12 +02:00
|
|
|
//~^ ERROR: C-like enum variant discriminant is not portable to 32-bit targets
|
2017-02-08 14:58:07 +01:00
|
|
|
A = 0x1_0000_0000,
|
2023-08-24 21:32:12 +02:00
|
|
|
//~^ ERROR: C-like enum variant discriminant is not portable to 32-bit targets
|
2016-02-29 09:36:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#[repr(usize)]
|
2020-01-30 11:43:19 +09:00
|
|
|
enum NonPortable2 {
|
|
|
|
X = <usize as Trait>::Number,
|
2023-08-24 21:32:12 +02:00
|
|
|
//~^ ERROR: C-like enum variant discriminant is not portable to 32-bit targets
|
2016-02-29 09:36:13 +01:00
|
|
|
Y = 0,
|
|
|
|
}
|
|
|
|
|
|
|
|
trait Trait {
|
|
|
|
const Number: usize = 0x1_0000_0000;
|
|
|
|
}
|
2020-01-30 11:43:19 +09:00
|
|
|
|
|
|
|
impl Trait for usize {}
|
2016-02-29 09:36:13 +01:00
|
|
|
|
2018-12-09 23:26:16 +01:00
|
|
|
fn main() {}
|