Skip to content

Macros don't get expanded when used in item name token position #4365

Closed

Description

@vadimcn

All of the examples below fail to compile with an error similar to the following:
test.rs:1:16: 1:17 error: expected ( but found !
test.rs:1 fn concat_idents!(foo, bar) () {}
^

fn concat_idents!(foo, bar) () {}
trait concat_idents!(foo, bar) {}
mod concat_idents!(foo, bar) {}
let concat_idents!(foo, bar) = 0;

Activity

  1. vadimcn commented on Jan 10, 2013

    @vadimcn
    ContributorAuthor

    Hmm, ok, I see. I failed to grok the following sentence during my first ten readings of the Macro Tutorial: "A macro invocation may take the place of (and therefore expand to) either an expression, an item, or a statement".
    Too bad, this makes concat_idents!() way less useful than I thought...

  2. catamorphism commented on Jan 10, 2013

    @catamorphism
    Contributor

    I don't think we're planning to extend the macro system in this way, but feel free to make another issue requesting it as an RFC :-)

  3. added a commit that references this issue on Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions