Skip to content

syntax: allow trace_macros! and log_syntax! in item position. #12998

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 24, 2014

Conversation

huonw
Copy link
Member

@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