2018-08-30 14:18:55 +02:00
|
|
|
// run-pass
|
2015-03-22 13:13:15 -07:00
|
|
|
|
2015-03-25 17:06:52 -07:00
|
|
|
const FOO: isize = 10;
|
|
|
|
const BAR: isize = 3;
|
2019-12-14 00:01:12 +01:00
|
|
|
const ZST: &() = unsafe { std::mem::transmute(1usize) };
|
|
|
|
const ZST_ARR: &[u8; 0] = unsafe { std::mem::transmute(1usize) };
|
2012-11-12 22:10:15 -08:00
|
|
|
|
2015-12-01 17:37:01 +01:00
|
|
|
const fn foo() -> isize { 4 }
|
|
|
|
const BOO: isize = foo();
|
|
|
|
|
2013-02-01 19:43:17 -08:00
|
|
|
pub fn main() {
|
2015-03-25 17:06:52 -07:00
|
|
|
let x: isize = 3;
|
2012-11-12 22:10:15 -08:00
|
|
|
let y = match x {
|
2015-01-25 22:05:03 +01:00
|
|
|
FOO => 1,
|
|
|
|
BAR => 2,
|
2015-12-01 17:37:01 +01:00
|
|
|
BOO => 4,
|
2015-01-25 22:05:03 +01:00
|
|
|
_ => 3
|
2012-11-12 22:10:15 -08:00
|
|
|
};
|
2013-05-18 22:02:45 -04:00
|
|
|
assert_eq!(y, 2);
|
2019-12-14 00:01:12 +01:00
|
|
|
let z = match &() {
|
|
|
|
ZST => 9,
|
|
|
|
};
|
|
|
|
assert_eq!(z, 9);
|
|
|
|
let z = match b"" {
|
|
|
|
ZST_ARR => 10,
|
|
|
|
};
|
|
|
|
assert_eq!(z, 10);
|
2012-11-12 22:10:15 -08:00
|
|
|
}
|