Skip to content

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

Closed
@dtolnay

Description

@dtolnay
Member

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).

Activity

added
A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)
C-bugCategory: This is a bug.
on Jul 9, 2018
0e4ef622

0e4ef622 commented on Aug 5, 2018

@0e4ef622
Contributor

Is any work being done on this? I found something that could help.

syntax::ext::tt::macro_parser: may_begin_with("literal", Interpolated((NtLiteral(..), None))) = false

kennytm

kennytm commented on Aug 5, 2018

@kennytm
Member

@0e4ef622 you're welcome to submit a PR 😊. Just remember to add a test case in src/test/run-pass.

added a commit that references this issue on Aug 7, 2018

Rollup merge of rust-lang#53093 - 0e4ef622:issue-52169-fix, r=petroch…

c122061
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

    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

        Participants

        @kennytm@dtolnay@0e4ef622

        Issue actions

          Unable to pass a $:literal from one macro to another · Issue #52169 · rust-lang/rust