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