Skip to content

Documentation of macro-generated macro shows unexpanded matchers #45939

Closed

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) => { ... };
}

Activity

  1. added
    T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
    C-enhancementCategory: An issue proposing an enhancement or a PR with one.
    on Nov 14, 2017
  2. dtolnay commented on Apr 14, 2019

    @dtolnay
    MemberAuthor

    Same behavior as of rustc 1.35.0-nightly (e4c66af 2019-04-13).

  3. added
    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)
    C-bugCategory: This is a bug.
    and removed
    C-enhancementCategory: An issue proposing an enhancement or a PR with one.
    on May 4, 2019
  4. jyn514 commented on Dec 16, 2020

    @jyn514
    Member

    Same behavior as of rustdoc 1.50.0-nightly (0f6f2d6 2020-12-06).

  5. dtolnay commented on Dec 26, 2021

    @dtolnay
    MemberAuthor

    Fixed in nightly-2021-07-06, likely by #86282.

  6. jyn514 commented on Dec 27, 2021

    @jyn514
    Member

    Oh wow, look at that! Congrats @camelid :)

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