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