Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation of macro-generated macro shows unexpanded matchers #45939

Closed
dtolnay opened this issue Nov 12, 2017 · 4 comments
Closed

Documentation of macro-generated macro shows unexpanded matchers #45939

dtolnay opened this issue Nov 12, 2017 · 4 comments
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@dtolnay
Copy link
Member

dtolnay commented Nov 12, 2017

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) => { ... };
}
@TimNN TimNN added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. C-enhancement Category: An issue proposing an enhancement or a PR with one. labels Nov 14, 2017
@dtolnay
Copy link
Member Author

dtolnay commented Apr 14, 2019

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

@jonas-schievink jonas-schievink added A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. and removed C-enhancement Category: An issue proposing an enhancement or a PR with one. labels May 4, 2019
@jyn514
Copy link
Member

jyn514 commented Dec 16, 2020

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

@dtolnay
Copy link
Member Author

dtolnay commented Dec 26, 2021

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

@dtolnay dtolnay closed this as completed Dec 26, 2021
@jyn514
Copy link
Member

jyn514 commented Dec 27, 2021

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
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants