]>
git.proxmox.com Git - rustc.git/blob - src/libsyntax/ext/trace_macros.rs
1 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
13 use ext
::base
::ExtCtxt
;
16 use parse
::token
::keywords
;
19 pub fn expand_trace_macros(cx
: &mut ExtCtxt
,
21 tt
: &[ast
::TokenTree
])
22 -> Box
<base
::MacResult
+'
static> {
23 if !cx
.ecfg
.enable_trace_macros() {
24 feature_gate
::emit_feature_err(&cx
.parse_sess
.span_diagnostic
,
27 feature_gate
::EXPLAIN_TRACE_MACROS
);
28 return base
::DummyResult
::any(sp
);
31 match (tt
.len(), tt
.first()) {
32 (1, Some(&ast
::TtToken(_
, ref tok
))) if tok
.is_keyword(keywords
::True
) => {
33 cx
.set_trace_macros(true);
35 (1, Some(&ast
::TtToken(_
, ref tok
))) if tok
.is_keyword(keywords
::False
) => {
36 cx
.set_trace_macros(false);
38 _
=> cx
.span_err(sp
, "trace_macros! accepts only `true` or `false`"),
41 base
::DummyResult
::any(sp
)