]> git.lizzy.rs Git - rust.git/commit
syntax: allow `trace_macros!` and `log_syntax!` in item position.
authorHuon Wilson <dbau.pp+github@gmail.com>
Tue, 18 Mar 2014 12:14:08 +0000 (23:14 +1100)
committerHuon Wilson <dbau.pp+github@gmail.com>
Fri, 21 Mar 2014 14:27:23 +0000 (01:27 +1100)
commitcda33346d0e9e4d1ff26163583831f96d42a4bc0
tree4ed80fc23ba6ee22c9c9be1c9fe3d093a7110a35
parentaf9368452d8578af219713b34f7e3be4bd085186
syntax: allow `trace_macros!` and `log_syntax!` in item position.

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 `()`.
src/libsyntax/ext/base.rs
src/libsyntax/ext/log_syntax.rs
src/libsyntax/ext/trace_macros.rs
src/test/compile-fail/issue-11692.rs
src/test/compile-fail/trace_macros-format.rs [new file with mode: 0644]
src/test/run-pass/log_syntax-trace_macros-macro-locations.rs [new file with mode: 0644]