Extend macro machinery to expand macros in types

Reapplied the changes from 7aafe24139
to a clean branch of master
This commit is contained in:
Jared Roesch
2015-07-25 21:54:19 -07:00
parent edca562c87
commit 9fb11fe9f2
3 changed files with 58 additions and 0 deletions

View File

@@ -290,6 +290,10 @@ pub trait MacResult {
fn make_stmts(self: Box<Self>) -> Option<SmallVector<P<ast::Stmt>>> {
make_stmts_default!(self)
}
fn make_ty(self: Box<Self>) -> Option<P<ast::Ty>> {
None
}
}
macro_rules! make_MacEager {
@@ -322,6 +326,7 @@ make_MacEager! {
items: SmallVector<P<ast::Item>>,
impl_items: SmallVector<P<ast::ImplItem>>,
stmts: SmallVector<P<ast::Stmt>>,
ty: P<ast::Ty>,
}
impl MacResult for MacEager {
@@ -359,6 +364,10 @@ impl MacResult for MacEager {
}
None
}
fn make_ty(self: Box<Self>) -> Option<P<ast::Ty>> {
self.ty
}
}
/// Fill-in macro expansion result, to allow compilation to continue
@@ -405,6 +414,12 @@ impl DummyResult {
}
}
pub fn raw_ty(sp: Span) -> P<ast::Ty> {
P(ast::Ty {
id: ast:DUMMY_NODE_ID,
node: ast::TyInfer,
span: sp
})
}
impl MacResult for DummyResult {