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

Rustdoc regression: duplicate macro in sidebar #89852

Closed
dtolnay opened this issue Oct 13, 2021 · 4 comments · Fixed by #89867
Closed

Rustdoc regression: duplicate macro in sidebar #89852

dtolnay opened this issue Oct 13, 2021 · 4 comments · Fixed by #89867
Labels
C-bug Category: This is a bug. regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Milestone

Comments

@dtolnay
Copy link
Member

dtolnay commented Oct 13, 2021

#[macro_export]
macro_rules! repro {
    () => {};
}

pub use crate::repro as repro2;
$ cargo doc --open

In current stable, and nightly-2021-08-28:

Screenshot from 2021-10-13 10-33-42


In current beta, current nightly, and nightly-2021-08-29:

Screenshot from 2021-10-13 10-33-55


Notice that repro appears twice in the sidebar under the list of macros exported by the crate.

Bisects to #88019.

@dtolnay dtolnay added C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression. labels Oct 13, 2021
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Oct 13, 2021
@dtolnay dtolnay added regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. and removed regression-untriaged Untriaged performance or correctness regression. labels Oct 13, 2021
@dtolnay
Copy link
Member Author

dtolnay commented Oct 13, 2021

Bisect

searched nightlies: from nightly-2021-08-10 to nightly-2021-09-26
regressed nightly: nightly-2021-08-29
searched commit range: ac50a53...5eacec9
regressed commit: 05cccdc

bisected with cargo-bisect-rustc v0.6.0

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc 2021-08-10 --end 2021-09-26 --prompt -- doc --open 

@camelid
Copy link
Member

camelid commented Oct 13, 2021

It looks like in both versions there's also a bug where repro2 is not shown.

@jyn514
Copy link
Member

jyn514 commented Oct 13, 2021

I think the fix here is to show "pub use repro as repro2" in the crate root - it sounds like currently it's being unconditionally inlined and then on top of that using the original name instead of the new one.

@Urgau
Copy link
Member

Urgau commented Oct 13, 2021

This also affect the unstable json output of rustdoc.

If we take the example given by @dtolnay there are 3 items (1 reexport + 2 macro) instead of only two:

Module {
    is_crate: true,
    items: [
        Id("0:4"),   // pub use crate::repro as repro2;
        Id("0:3"),   // macro_rules! repro
        Id("0:3"),   // Same as above, but shouldn't be here !
    ],
}

The bug seems that the macro repro appears for whatever reason 2 times instead of only one.

Urgau added a commit to Urgau/rust that referenced this issue Oct 14, 2021
@Mark-Simulacrum Mark-Simulacrum added this to the 1.56.0 milestone Oct 15, 2021
pietroalbini pushed a commit to pietroalbini/rust that referenced this issue Oct 18, 2021
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Oct 18, 2021
…laumeGomez

Fix macro_rules! duplication when reexported in the same module

This can append if within the same module a `#[macro_export] macro_rules!`
is declared but also a reexport of itself producing two export of the same
macro in the same module. In that case we only want to document it once.

Before:
```
Module {
    is_crate: true,
    items: [
        Id("0:4"),   // pub use crate::repro as repro2;
        Id("0:3"),   // macro_rules! repro
        Id("0:3"),   // duplicate, same as above
    ],
}
```

After:
```
Module {
    is_crate: true,
    items: [
        Id("0:4"),   // pub use crate::repro as repro2;
        Id("0:3"),   // macro_rules! repro
    ],
}
```

Fixes rust-lang#89852
@bors bors closed this as completed in 0d990a3 Oct 19, 2021
@camelid camelid removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Oct 19, 2021
MabezDev pushed a commit to esp-rs/rust that referenced this issue Oct 21, 2021
Mark-Simulacrum pushed a commit to Mark-Simulacrum/rust that referenced this issue Oct 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants