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