mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-31 05:26:23 +03:00
cda33346d0
Previously
trace_macros!(true)
fn main() {}
would complain about `trace_macros` being an expression macro in item
position. This is a pointless limitation, because the macro is purely
compile-time, with no runtime effect. (And similarly for log_syntax.)
This also changes the behaviour of `trace_macros!` very slightly, it
used to be equivalent to
macro_rules! trace_macros {
(true $($_x: tt)*) => { true };
(false $($_x: tt)*) => { false }
}
I.e. you could invoke it with arbitrary trailing arguments, which were
ignored. It is changed to accept only exactly `true` or `false` (with no
trailing arguments) and expands to `()`.
28 lines
961 B
Rust
28 lines
961 B
Rust
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
// file at the top-level directory of this distribution and at
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
// option. This file may not be copied, modified, or distributed
|
|
// except according to those terms.
|
|
|
|
use ast;
|
|
use codemap;
|
|
use ext::base;
|
|
use print;
|
|
|
|
pub fn expand_syntax_ext(cx: &mut base::ExtCtxt,
|
|
sp: codemap::Span,
|
|
tt: &[ast::TokenTree])
|
|
-> base::MacResult {
|
|
|
|
cx.print_backtrace();
|
|
println!("{}", print::pprust::tt_to_str(&ast::TTDelim(
|
|
@tt.iter().map(|x| (*x).clone()).collect())));
|
|
|
|
// any so that `log_syntax` can be invoked as an expression and item.
|
|
base::MacResult::dummy_any(sp)
|
|
}
|