]> git.proxmox.com Git - rustc.git/blob - src/test/run-pass/macros/macro-interpolation.rs
New upstream version 1.37.0+dfsg1
[rustc.git] / src / test / run-pass / macros / macro-interpolation.rs
1 // run-pass
2
3 macro_rules! overly_complicated {
4 ($fnname:ident, $arg:ident, $ty:ty, $body:block, $val:expr, $pat:pat, $res:path) =>
5 ({
6 fn $fnname($arg: $ty) -> Option<$ty> $body
7 match $fnname($val) {
8 Some($pat) => {
9 $res
10 }
11 _ => { panic!(); }
12 }
13 })
14
15 }
16
17 pub fn main() {
18 assert!(overly_complicated!(f, x, Option<usize>, { return Some(x); },
19 Some(8), Some(y), y) == 8)
20
21 }