2018-09-04 05:05:53 -05:00
|
|
|
// run-pass
|
2018-09-25 16:51:35 -05:00
|
|
|
#![allow(dead_code)]
|
|
|
|
#![allow(unused_variables)]
|
2018-09-06 06:51:09 -05:00
|
|
|
#![allow(unconditional_recursion)]
|
|
|
|
|
2013-09-06 21:11:55 -05:00
|
|
|
// Check that we do not ICE when compiling this
|
|
|
|
// macro, which reuses the expression `$id`
|
|
|
|
|
2015-02-10 15:52:00 -06:00
|
|
|
#![feature(box_patterns)]
|
2014-05-05 20:56:44 -05:00
|
|
|
|
2013-09-06 21:11:55 -05:00
|
|
|
struct Foo {
|
2015-03-25 19:06:52 -05:00
|
|
|
a: isize
|
2013-09-06 21:11:55 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
pub enum Bar {
|
2015-03-25 19:06:52 -05:00
|
|
|
Bar1, Bar2(isize, Box<Bar>),
|
2013-09-06 21:11:55 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Foo {
|
2014-05-05 20:56:44 -05:00
|
|
|
fn elaborate_stm(&mut self, s: Box<Bar>) -> Box<Bar> {
|
2015-01-02 16:44:21 -06:00
|
|
|
macro_rules! declare {
|
2013-09-06 21:11:55 -05:00
|
|
|
($id:expr, $rest:expr) => ({
|
|
|
|
self.check_id($id);
|
2021-08-24 19:39:40 -05:00
|
|
|
Box::new(Bar::Bar2($id, $rest))
|
2013-09-06 21:11:55 -05:00
|
|
|
})
|
2015-01-02 16:44:21 -06:00
|
|
|
}
|
2013-09-06 21:11:55 -05:00
|
|
|
match s {
|
2014-11-06 02:05:53 -06:00
|
|
|
box Bar::Bar2(id, rest) => declare!(id, self.elaborate_stm(rest)),
|
2014-10-09 14:17:22 -05:00
|
|
|
_ => panic!()
|
2013-09-06 21:11:55 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-25 19:06:52 -05:00
|
|
|
fn check_id(&mut self, s: isize) { panic!() }
|
2013-09-06 21:11:55 -05:00
|
|
|
}
|
2013-09-29 21:23:57 -05:00
|
|
|
|
2013-09-25 02:43:37 -05:00
|
|
|
pub fn main() { }
|