Skip to content

Conversation

@huonw
Copy link
Contributor

@huonw huonw commented Mar 18, 2014

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 ().

@alexcrichton
Copy link
Member

r=me, but a test may need to be fixed on travis

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 `()`.
bors added a commit that referenced this pull request Mar 24, 2014
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 `()`.
@bors bors closed this Mar 24, 2014
@bors bors merged commit cda3334 into rust-lang:master Mar 24, 2014
@huonw huonw deleted the log_syntax branch December 4, 2014 02:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants