rust/src/libsyntax_ext/trace_macros.rs

22 lines
698 B
Rust
Raw Normal View History

2019-02-04 21:49:54 +09:00
use syntax::ext::base::{self, ExtCtxt};
use syntax::symbol::kw;
use syntax_pos::Span;
use syntax::tokenstream::TokenTree;
2019-02-04 21:49:54 +09:00
pub fn expand_trace_macros(cx: &mut ExtCtxt<'_>,
sp: Span,
tt: &[TokenTree])
-> Box<dyn base::MacResult + 'static> {
match tt {
[TokenTree::Token(token)] if token.is_keyword(kw::True) => {
cx.set_trace_macros(true);
}
[TokenTree::Token(token)] if token.is_keyword(kw::False) => {
cx.set_trace_macros(false);
}
_ => cx.span_err(sp, "trace_macros! accepts only `true` or `false`"),
2012-08-15 10:45:10 -07:00
}
2012-11-26 22:12:31 -05:00
2018-12-20 03:57:48 +03:00
base::DummyResult::any_valid(sp)
2012-08-15 10:45:10 -07:00
}