summaryrefslogtreecommitdiff
path: root/tests/ui/borrowck/borrowck-macro-interaction-issue-6304.rs
blob: 4e969f6ed83d30935dd74dfd89801a0b5ed8f17b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// run-pass
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unconditional_recursion)]

// Check that we do not ICE when compiling this
// macro, which reuses the expression `$id`

#![feature(box_patterns)]

struct Foo {
  a: isize
}

pub enum Bar {
  Bar1, Bar2(isize, Box<Bar>),
}

impl Foo {
  fn elaborate_stm(&mut self, s: Box<Bar>) -> Box<Bar> {
    macro_rules! declare {
      ($id:expr, $rest:expr) => ({
        self.check_id($id);
        Box::new(Bar::Bar2($id, $rest))
      })
    }
    match s {
      box Bar::Bar2(id, rest) => declare!(id, self.elaborate_stm(rest)),
      _ => panic!()
    }
  }

  fn check_id(&mut self, s: isize) { panic!() }
}

pub fn main() { }