Skip to content

Can't define a function name using concat_idents!() #12249

Closed
@kmcallister

Description

@kmcallister

I want mymacro!(bar) to expand to fn foo_bar() { }.

#[feature(macro_rules)];

macro_rules! mymacro( ($x:ident) => (
    fn concat_idents!(foo_, $x)() { }
))

mymacro!(bar)

fn main() {
    foo_bar();
}

gives

foo.rs:4:21: 4:22 error: expected `(` but found `!`
foo.rs:4     fn concat_idents!(foo_, $x)() { }

on

rustc 0.9 (d3b3c66 2014-01-12 19:44:26 -0700)
host: x86_64-unknown-linux-gnu

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-syntaxextArea: Syntax extensions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions