Skip to content
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

Cannot use Macros in Trait Bodies #11403

Closed
mitsuhiko opened this issue Jan 8, 2014 · 4 comments
Closed

Cannot use Macros in Trait Bodies #11403

mitsuhiko opened this issue Jan 8, 2014 · 4 comments
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)

Comments

@mitsuhiko
Copy link
Contributor

I would have expected this to work, but it does not:

#[feature(macro_rules)];

macro_rules! test {
    () => {
        fn foo();
    }
}

trait Foo {
    test!()
}

Currently fails with this error:

test.rs:10:4: 10:8 error: unexpected token: `test`
test.rs:10     test!()
               ^~~~
task 'rustc' failed at 'explicit failure', /Users/mitsuhiko/Development/rust/src/libsyntax/diagnostic.rs:76
task '<main>' failed at 'explicit failure', /Users/mitsuhiko/Development/rust/src/librustc/lib.rs:441
@sfackler
Copy link
Member

sfackler commented Jan 8, 2014

Duplicate of #4621

@alexcrichton
Copy link
Member

Closing as a dupe.

@yuryshulaev
Copy link

Hmm, this doesn’t seem to be fixed. Macros work in impls now, but not in traits.

@sfackler sfackler reopened this Oct 15, 2014
@steveklabnik steveklabnik added the A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) label Jan 23, 2015
@steveklabnik
Copy link
Member

Triage: no change, other than removing the macro_rules.

I don't believe that we're planning on improving the current macro_rules at all, instead focusing on the next-gen macro system. Also, this feels like this would require an RFC. so closing.

flip1995 pushed a commit to flip1995/rust that referenced this issue Sep 7, 2023
Ignore wildcards in function arguments and local bindings

Fix rust-lang#11403

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)
Projects
None yet
Development

No branches or pull requests

5 participants