rust/src/libsyntax_ext/trace_macros.rs

22 lines
698 B
Rust
Raw Normal View History

2019-02-04 12:49:54 +00:00
use syntax::ext::base::{self, ExtCtxt};
use syntax::symbol::kw;
use syntax_pos::Span;
use syntax::tokenstream::TokenTree;
2019-02-04 12:49:54 +00: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 17:45:10 +00:00
}
2012-11-27 03:12:31 +00:00
2018-12-20 00:57:48 +00:00
base::DummyResult::any_valid(sp)
2012-08-15 17:45:10 +00:00
}