]> git.lizzy.rs Git - rust.git/blob - tests/ui/macros/macro-interpolation.rs
Rollup merge of #106970 - kylematsuda:earlybinder-item-bounds, r=lcnr
[rust.git] / tests / ui / 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 macro_rules! qpath {
18     (path, <$type:ty as $trait:path>::$name:ident) => {
19         <$type as $trait>::$name
20     };
21
22     (ty, <$type:ty as $trait:ty>::$name:ident) => {
23         <$type as $trait>::$name
24     };
25 }
26
27 pub fn main() {
28     let _: qpath!(path, <str as ToOwned>::Owned);
29     let _: qpath!(ty, <str as ToOwned>::Owned);
30
31     assert!(overly_complicated!(f, x, Option<usize>, { return Some(x); },
32                                Some(8), Some(y), y) == 8)
33 }