Skip to content

Fix weird rustdoc output when single and glob reexport conflict on a name #143590

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

GuillaumeGomez
Copy link
Member

@GuillaumeGomez GuillaumeGomez commented Jul 7, 2025

Fixes #143107.

The problem was that the second reexport would overwrite the first, leading to having unexpected results. To fix it, I now group items by their original DefId and their name and keep tracks of all imports for this item (should very rarely be more than one though, and even less often more than 2).

cc @lolbinarycat

@rustbot
Copy link
Collaborator

rustbot commented Jul 7, 2025

r? @notriddle

rustbot has assigned @notriddle.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Jul 7, 2025
@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez
Copy link
Member Author

Ah bad luck. A function I modified was used in a more up-to-date version. ^^'

Anyway, rebased and fixed the CI failure.

Copy link
Contributor

@lolbinarycat lolbinarycat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some things could use clarification. i don't entirely understand if things are getting merged or overwritten. the unit test comment is confusing: all glob attrs are ignored, or just those on shadowed items? this should be clarified.

the test could also include coverage for the case where an item is renamed to itself. also what happens if an item is renamed then renamed back to the original name in a chain?

@@ -152,8 +152,12 @@ pub(crate) fn try_inline(
};

cx.inlined.insert(did.into());
let import_def_ids: &[LocalDefId] = match import_def_id {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't Option::as_slice be used here?

/// ```
///
/// So in this case, we don't want to have two items but just one with attributes from both
/// imports to be merged.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is merging the attributes correct? i thought that per the reference, only items not shadowed by non-glob imports would actually be shadowed. i guess that doesn't exactly say what happens when you shadow a glob import with an identical item...

not that i see putting docs on glob imports to be a common usecase, i think much more common is docs on the regular import and no docs on the glob import.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[rustdoc] adding docs on a reexport that shadows a glob reexport does not work properly
5 participants