Skip to content

Unable to pass a $:literal from one macro to another #52169

Closed
@dtolnay

Description

@dtolnay

I would expect the following program to print right. Instead it prints wrong.

#![feature(macro_literal_matcher)]

macro_rules! a {
    ($i:literal) => { "right" };
    ($i:tt) => { "wrong" };
}

macro_rules! b {
    ($i:literal) => { a!($i) };
}

fn main() {
    println!(b!(0));
}

Originally reported by @jendrikw in #35625 (comment).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions