]> git.proxmox.com Git - rustc.git/blame - src/test/ui/consts/consts-in-patterns.rs
New upstream version 1.46.0~beta.2+dfsg1
[rustc.git] / src / test / ui / consts / consts-in-patterns.rs
CommitLineData
b7449926 1// run-pass
c34b1796
AL
2
3const FOO: isize = 10;
4const BAR: isize = 3;
dfeec247
XL
5const ZST: &() = unsafe { std::mem::transmute(1usize) };
6const ZST_ARR: &[u8; 0] = unsafe { std::mem::transmute(1usize) };
223e47cc 7
9cc50fc6
SL
8const fn foo() -> isize { 4 }
9const BOO: isize = foo();
10
223e47cc 11pub fn main() {
c34b1796 12 let x: isize = 3;
223e47cc 13 let y = match x {
85aaf69f
SL
14 FOO => 1,
15 BAR => 2,
9cc50fc6 16 BOO => 4,
85aaf69f 17 _ => 3
223e47cc 18 };
970d7e83 19 assert_eq!(y, 2);
dfeec247
XL
20 let z = match &() {
21 ZST => 9,
22 // FIXME: this should not be required
23 _ => 42,
24 };
25 assert_eq!(z, 9);
26 let z = match b"" {
27 ZST_ARR => 10,
28 };
29 assert_eq!(z, 10);
223e47cc 30}