2019-02-04 12:49:54 +00:00
|
|
|
use syntax::ext::base::{self, ExtCtxt};
|
2019-06-22 13:18:05 +00:00
|
|
|
use syntax::symbol::kw;
|
2016-06-21 22:08:13 +00:00
|
|
|
use syntax_pos::Span;
|
2016-06-20 15:49:33 +00:00
|
|
|
use syntax::tokenstream::TokenTree;
|
2014-05-06 01:56:44 +00:00
|
|
|
|
2019-02-04 12:49:54 +00:00
|
|
|
pub fn expand_trace_macros(cx: &mut ExtCtxt<'_>,
|
2013-08-31 16:13:04 +00:00
|
|
|
sp: Span,
|
2015-11-06 13:52:02 +00:00
|
|
|
tt: &[TokenTree])
|
2018-07-12 09:58:16 +00:00
|
|
|
-> Box<dyn base::MacResult + 'static> {
|
2019-06-08 08:49:46 +00:00
|
|
|
match tt {
|
|
|
|
[TokenTree::Token(token)] if token.is_keyword(kw::True) => {
|
2014-03-18 12:14:08 +00:00
|
|
|
cx.set_trace_macros(true);
|
|
|
|
}
|
2019-06-08 08:49:46 +00:00
|
|
|
[TokenTree::Token(token)] if token.is_keyword(kw::False) => {
|
2014-03-18 12:14:08 +00:00
|
|
|
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
|
|
|
}
|