]> git.lizzy.rs Git - rust.git/blob - tests/ui/macros/macro-pat-neg-lit.rs
Rollup merge of #107127 - uweigand:s390x-sanitizer, r=Mark-Simulacrum
[rust.git] / tests / ui / macros / macro-pat-neg-lit.rs
1 // run-pass
2 macro_rules! enum_number {
3     ($name:ident { $($variant:ident = $value:expr, )* }) => {
4         enum $name {
5             $($variant = $value,)*
6         }
7
8         fn foo(value: i32) -> Option<$name> {
9             match value {
10                 $( $value => Some($name::$variant), )*
11                 _ => None
12             }
13         }
14     }
15 }
16
17 enum_number!(Change {
18     Down = -1,
19     None = 0,
20     Up = 1,
21 });
22
23 fn main() {
24     if let Some(Change::Down) = foo(-1) {} else { panic!() }
25 }