]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/borrowck-macro-interaction-issue-6304.rs
Rollup merge of #106644 - alexcrichton:update-wasi-toolchain, r=cuviper
[rust.git] / tests / ui / borrowck / borrowck-macro-interaction-issue-6304.rs
1 // run-pass
2 #![allow(dead_code)]
3 #![allow(unused_variables)]
4 #![allow(unconditional_recursion)]
5
6 // Check that we do not ICE when compiling this
7 // macro, which reuses the expression `$id`
8
9 #![feature(box_patterns)]
10
11 struct Foo {
12   a: isize
13 }
14
15 pub enum Bar {
16   Bar1, Bar2(isize, Box<Bar>),
17 }
18
19 impl Foo {
20   fn elaborate_stm(&mut self, s: Box<Bar>) -> Box<Bar> {
21     macro_rules! declare {
22       ($id:expr, $rest:expr) => ({
23         self.check_id($id);
24         Box::new(Bar::Bar2($id, $rest))
25       })
26     }
27     match s {
28       box Bar::Bar2(id, rest) => declare!(id, self.elaborate_stm(rest)),
29       _ => panic!()
30     }
31   }
32
33   fn check_id(&mut self, s: isize) { panic!() }
34 }
35
36 pub fn main() { }