]> git.lizzy.rs Git - rust.git/blob - src/test/ui/pattern/issue-92074-macro-ice.rs
Rollup merge of #105555 - krasimirgg:llvm-int-opt-2, r=cuviper
[rust.git] / src / test / ui / pattern / issue-92074-macro-ice.rs
1 pub enum En {
2     A(Vec<u8>)
3 }
4
5 fn get_usize() -> usize {
6     0
7 }
8
9 macro_rules! force_expr {
10     ($e:expr) => { $e }
11 }
12
13 macro_rules! force_pat {
14     ($a:expr, $b:expr) => { $a..=$b }
15 }
16
17 macro_rules! make_vec {
18     () => { force_expr!(Vec::new()) } //~ ERROR arbitrary expressions aren't allowed
19 }
20
21 macro_rules! make_pat {
22     () => { force_pat!(get_usize(), get_usize()) }
23     //~^ ERROR arbitrary expressions aren't allowed
24     //~| ERROR arbitrary expressions aren't allowed
25 }
26
27 #[allow(unreachable_code)]
28 fn f() -> Result<(), impl core::fmt::Debug> {
29     let x: En = loop {};
30
31     assert!(matches!(x, En::A(make_vec!())));
32     assert!(matches!(5, make_pat!()));
33     Ok::<(), &'static str>(())
34 }
35
36 fn main() {}