print-expansion for all your expansion printing needs
This commit is contained in:
parent
d7d5679e6e
commit
e5711929e3
3 changed files with 10 additions and 2 deletions
|
@ -1,3 +1,3 @@
|
||||||
language: rust
|
language: rust
|
||||||
script:
|
script:
|
||||||
- ( cd maud_macros && cargo test --verbose )
|
- ( cd maud_macros && cargo test --features print-expansion --verbose )
|
||||||
|
|
|
@ -12,6 +12,9 @@ description = """
|
||||||
Compile-time HTML templates.
|
Compile-time HTML templates.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
[features]
|
||||||
|
print-expansion = []
|
||||||
|
|
||||||
[dependencies.maud]
|
[dependencies.maud]
|
||||||
path = "../maud"
|
path = "../maud"
|
||||||
version = "=0.3.4"
|
version = "=0.3.4"
|
||||||
|
|
|
@ -10,13 +10,18 @@ extern crate maud;
|
||||||
use syntax::ast::TokenTree;
|
use syntax::ast::TokenTree;
|
||||||
use syntax::codemap::Span;
|
use syntax::codemap::Span;
|
||||||
use syntax::ext::base::{ExtCtxt, MacEager, MacResult};
|
use syntax::ext::base::{ExtCtxt, MacEager, MacResult};
|
||||||
|
use syntax::print::pprust;
|
||||||
use rustc::plugin::Registry;
|
use rustc::plugin::Registry;
|
||||||
|
|
||||||
mod parse;
|
mod parse;
|
||||||
mod render;
|
mod render;
|
||||||
|
|
||||||
fn expand_html<'cx>(cx: &'cx mut ExtCtxt, sp: Span, args: &[TokenTree]) -> Box<MacResult + 'cx> {
|
fn expand_html<'cx>(cx: &'cx mut ExtCtxt, sp: Span, args: &[TokenTree]) -> Box<MacResult + 'cx> {
|
||||||
MacEager::expr(parse::parse(cx, args, sp))
|
let expr = parse::parse(cx, args, sp);
|
||||||
|
if cfg!(feature = "print-expansion") {
|
||||||
|
println!("{}", pprust::expr_to_string(&expr));
|
||||||
|
}
|
||||||
|
MacEager::expr(expr)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[plugin_registrar]
|
#[plugin_registrar]
|
||||||
|
|
Loading…
Add table
Reference in a new issue