2018-07-02 12:00:07 -05:00
|
|
|
#![feature(const_fn_union)]
|
|
|
|
|
2018-05-24 04:03:33 -05:00
|
|
|
fn main() {
|
2018-05-25 08:13:54 -05:00
|
|
|
let n: Int = 40;
|
|
|
|
match n {
|
2018-05-28 21:42:11 -05:00
|
|
|
0..=10 => {},
|
2018-09-04 05:26:21 -05:00
|
|
|
10..=BAR => {}, //~ ERROR could not evaluate constant pattern
|
2018-05-24 04:03:33 -05:00
|
|
|
_ => {},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-30 02:35:02 -05:00
|
|
|
#[repr(C)]
|
2018-05-24 04:03:33 -05:00
|
|
|
union Foo {
|
|
|
|
f: Int,
|
|
|
|
r: &'static u32,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(target_pointer_width="64")]
|
|
|
|
type Int = u64;
|
|
|
|
|
|
|
|
#[cfg(target_pointer_width="32")]
|
|
|
|
type Int = u32;
|
|
|
|
|
2018-09-04 05:26:21 -05:00
|
|
|
const BAR: Int = unsafe { Foo { r: &42 }.f }; //~ ERROR it is undefined behavior to use this value
|