Skip to content

recursive macro --- macro doesn't exist #14946

Closed
@BurntSushi

Description

@BurntSushi

I believe this should output the string abc:

#![feature(macro_rules)]

macro_rules! rec(
    () => ("");
    ($a:ident) => (stringify!($a));
    ($a:ident, $($rest:tt),*) => (
        concat!(stringify!($a), rec!($($rest),*))
    );
)

fn main() {
    println!("{}", rec!(a, b, c));
}

But I get this error:

reem.rs:7:33: 7:36 error: macro undefined: 'rec'
reem.rs:7         concat!(stringify!($a), rec!($($rest),*))

Rust version:

[andrew@Liger rust] rustc --version
rustc 0.11.0-pre (6d8342f 2014-06-14 17:51:49 +0000)
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