2018-07-02 19:00:07 +02:00
|
|
|
#![feature(const_fn_union)]
|
|
|
|
|
2018-05-24 11:03:33 +02:00
|
|
|
fn main() {
|
2018-05-25 15:13:54 +02:00
|
|
|
let n: Int = 40;
|
|
|
|
match n {
|
2018-05-28 19:42:11 -07:00
|
|
|
0..=10 => {},
|
2018-09-04 12:26:21 +02:00
|
|
|
10..=BAR => {}, //~ ERROR could not evaluate constant pattern
|
2018-05-24 11:03:33 +02: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 12:26:21 +02:00
|
|
|
const BAR: Int = unsafe { Foo { r: &42 }.f }; //~ ERROR it is undefined behavior to use this value
|