Skip to content

Documentation of macro-generated macro shows unexpanded matchers #45939

Closed
@dtolnay

Description

@dtolnay

As part of dtolnay/syn#225 I am generating one macro_rules! macro from another macro_rules! macro. Everything works great except that the documentation of the generated macro is misleading.

Simplified example:

macro_rules! outer {
    ($(($n:ident $kw:ident))*) => {
        $(
            #[derive(Debug)]
            pub struct $n;
        )*

        #[macro_export]
        macro_rules! inner {
            $(
                ($kw) => { $n };
            )*
        }
    }
}

outer! {
    (Let let)
    (Loop loop)
    (Match match)
    (Mod mod)
}

fn main() {
    println!("{:?}", inner!(loop));
}

Rustdoc shows the following:

macro_rules! inner {
    ($kw) => { ... };
    ($kw) => { ... };
    ($kw) => { ... };
    ($kw) => { ... };
}

Instead I would expect:

macro_rules! inner {
    (let) => { ... };
    (loop) => { ... };
    (match) => { ... };
    (mod) => { ... };
}

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.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions