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