]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/borrowck-macro-interaction-issue-6304.rs
auto merge of #13967 : richo/rust/features/ICE-fails, r=alexcrichton
[rust.git] / src / test / run-pass / borrowck-macro-interaction-issue-6304.rs
1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // Check that we do not ICE when compiling this
12 // macro, which reuses the expression `$id`
13
14 #![feature(macro_rules)]
15
16
17 struct Foo {
18   a: int
19 }
20
21 pub enum Bar {
22   Bar1, Bar2(int, Box<Bar>),
23 }
24
25 impl Foo {
26   fn elaborate_stm(&mut self, s: Box<Bar>) -> Box<Bar> {
27     macro_rules! declare(
28       ($id:expr, $rest:expr) => ({
29         self.check_id($id);
30         box Bar2($id, $rest)
31       })
32     );
33     match s {
34       box Bar2(id, rest) => declare!(id, self.elaborate_stm(rest)),
35       _ => fail!()
36     }
37   }
38
39   fn check_id(&mut self, s: int) { fail!() }
40 }
41
42 pub fn main() { }