use rustc_plugin::Registry;
use syntax::tokenstream::TokenTree;
use syntax::codemap::Span;
+ use syntax::ast::*;
use syntax::ext::base::{ExtCtxt, MacEager, MacResult};
+ use syntax::ext::build::AstBuilder;
#[plugin_registrar]
pub fn foo(reg: &mut Registry) {
fn expand_bar(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree])
-> Box<MacResult + 'static> {
- MacEager::expr(quote_expr!(cx, 1))
+ MacEager::expr(cx.expr_lit(sp, LitKind::Int(1, LitIntType::Unsuffixed)))
}
"#)
.build();
use rustc_plugin::Registry;
use syntax::tokenstream::TokenTree;
use syntax::codemap::Span;
+ use syntax::ast::*;
use syntax::ext::base::{ExtCtxt, MacEager, MacResult};
+ use syntax::ext::build::AstBuilder;
+ use syntax::ptr::P;
#[plugin_registrar]
pub fn foo(reg: &mut Registry) {
fn expand_bar(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree])
-> Box<MacResult + 'static> {
- MacEager::expr(quote_expr!(cx, baz::baz()))
+ let bar = Ident::from_str("baz");
+ let path = cx.path(sp, vec![bar.clone(), bar]);
+ MacEager::expr(cx.expr_call(sp, cx.expr_path(path), vec![]))
}
"#)
.build();