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 {
items: SmallVector<P<ast::Item>>,
impl_items: SmallVector<P<ast::ImplItem>>,
stmts: SmallVector<P<ast::Stmt>>,
+ ty: P<ast::Ty>,
}
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
}
}
+ 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 {
}, rewritten_body)
}
+pub fn expand_type(t: P<ast::Ty>, fld: &mut MacroExpander) -> P<ast::Ty> {
+ let t = match t.node.clone() {
+ ast::Ty_::TyMac(mac) => {
+ let expanded_ty = match expand_mac_invoc(mac, t.span,
+ |r| r.make_ty(),
+ mark_ty,
+ fld) {
+ Some(ty) => ty,
+ None => {
+ return DummyResult::raw_ty(t.span);
+ }
+ };
+
+ // Keep going, outside-in.
+ //
+ let fully_expanded = fld.fold_ty(expanded_ty);
+ fld.cx.bt_pop();
+
+ fully_expanded.map(|t| ast::Ty {
+ id: ast::DUMMY_NODE_ID,
+ node: t.node,
+ span: t.span,
+ })
+ }
+ _ => t
+ };
+ fold::noop_fold_ty(t, fld)
+}
+
/// A tree-folder that performs macro expansion
pub struct MacroExpander<'a, 'b:'a> {
pub cx: &'a mut ExtCtxt<'b>,
.into_iter().map(|i| i.expect_impl_item()).collect()
}
+ fn fold_ty(&mut self, ty: P<ast::Ty>) -> P<ast::Ty> {
+ expand_type(ty, self)
+ }
+
fn new_span(&mut self, span: Span) -> Span {
new_span(self.cx, span)
}
.expect_one("marking an impl item didn't return exactly one impl item")
}
+fn mark_ty(ty: P<ast::Ty>, m: Mrk) -> P<ast::Ty> {
+ Marker { mark: m }.fold_ty(ty)
+}
+
/// Check that there are no macro invocations left in the AST:
pub fn check_for_macros(sess: &parse::ParseSess, krate: &ast::Crate) {
visit::walk_crate(&mut MacroExterminator{sess:sess}, krate);