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