Skip to content

rustdoc: Correctly handle reexports when --document-private-items is used - #161362

Merged
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
GuillaumeGomez:reexports-document-private
Oct 25, 2026
Merged

rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
GuillaumeGomez:reexports-document-private

Conversation

@GuillaumeGomez

@GuillaumeGomez GuillaumeGomez commented Aug 19, 2026 •

Copy link
Copy Markdown
Member

View all comments

Fixes #159109.

This PR makes the (private) reexport work like the public ones when the --document-private-items option is used. I still differentiate between imports (use) and reexports (pub(...) use) in this PR as I don't think we should display imports.

r? @Urgau

@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 Aug 19, 2026
//@ hasraw - "Mod1Public"
//@ !hasraw - "Mod1Private"
//@ !hasraw - "mod2"
//@ hasraw - "Mod1Private"

@GuillaumeGomez GuillaumeGomez Aug 19, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fun fact: this test was added in 2016 in #37773. :)

View changes since the review

@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez
GuillaumeGomez force-pushed the reexports-document-private branch from bdb8873 to 9baaae5 Compare August 19, 2026 16:10
@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez
GuillaumeGomez force-pushed the reexports-document-private branch from 9baaae5 to 7d595c2 Compare August 19, 2026 16:23
Comment thread src/librustdoc/visit_ast.rs Resolved
@Urgau

Urgau commented Aug 19, 2026 •

Copy link
Copy Markdown
Member

I was wondering if this was a breaking change, but our documentation clearly states:

--document-private-items includes all non-public items in the generated documentation except for #[doc(hidden)] items.

as such, this seems clearly like a bug fix.

@rust-log-analyzer

This comment was marked as resolved.

@Urgau Urgau added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-t-rustdoc Status: Awaiting decision from T-rustdoc and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 22, 2026
@GuillaumeGomez
GuillaumeGomez force-pushed the reexports-document-private branch from 7d595c2 to 819238e Compare October 23, 2026 10:42
@GuillaumeGomez

Copy link
Copy Markdown
Member Author

So now, all use in the crate module are visible.

@GuillaumeGomez

Copy link
Copy Markdown
Member Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 23, 2026
@GuillaumeGomez
GuillaumeGomez force-pushed the reexports-document-private branch from 819238e to 5862ffc Compare October 24, 2026 15:58
@GuillaumeGomez

Copy link
Copy Markdown
Member Author

Applied suggestions.

@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez
GuillaumeGomez force-pushed the reexports-document-private branch 2 times, most recently from 8844d76 to 59f6fd9 Compare October 24, 2026 17:51

@Urgau Urgau left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, r=me with the comment fixed

View changes since this review

Comment thread src/librustdoc/visit_ast.rs Outdated
Comment on lines +494 to +496
// we're documenting private item. If we are, then we want all items, except if it's a
// `use`. In this case, we want to check if it's a reexport. To do so, we check if there is
// a `pub(...)` part with its `vis_span` field.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This comment needs updating, it still talks about checking vis_span.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ah indeed, removing that part.

@Urgau Urgau added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. S-waiting-on-t-rustdoc Status: Awaiting decision from T-rustdoc labels Oct 24, 2026
@rust-bors rust-bors Bot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Oct 25, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 25, 2026
…private, r=Urgau

 rustdoc: Correctly handle reexports when --document-private-items is used

Fixes rust-lang#159109.

This PR makes the (private) reexport work like the public ones when the `--document-private-items` option is used. I still differentiate between imports (`use`) and reexports (`pub(...) use`) in this PR as I don't think we should display imports.

r? @Urgau
rust-bors Bot pushed a commit that referenced this pull request Oct 25, 2026
…uwer

Rollup of 12 pull requests

Successful merges:

 - #161362 ( rustdoc: Correctly handle reexports when --document-private-items is used)
 - #164764 (Test(lib/sync): Fix `test_rwlock_max_readers` for 32bit architectures)
 - #164869 (rustc_codegen_gcc subtree update)
 - #157123 (library: optimize truncate method)
 - #159916 (Optimize `str.escape_default().to_string()`)
 - #164508 (ping me for layout invariant changes)
 - #164758 (Update dependency jinja2 to v3.1.6 [SECURITY])
 - #164836 (Add regression test for #162109)
 - #164857 (Do not checkout Cargo for bootstrap tests)
 - #164868 (Fix skipping library build with `--keep-stage[-std]`)
 - #164872 (cg_llvm: clarify Send / Sync story for modules)
 - #164881 (Add FIXME comments to `from_ascii_bytes_radix_impl`)
rust-bors Bot pushed a commit that referenced this pull request Oct 25, 2026
…uwer

Rollup of 20 pull requests

Successful merges:

 - #160404 (fd-views: AsRef<File>&Co. for BorrowedFd)
 - #161362 ( rustdoc: Correctly handle reexports when --document-private-items is used)
 - #163769 (reborrow: Fix various ICEs related to auto reborrowing of user-space types)
 - #164764 (Test(lib/sync): Fix `test_rwlock_max_readers` for 32bit architectures)
 - #164860 (std::fs: read interrupted by a signal, read_buf_exact_at reports EOF.)
 - #164869 (rustc_codegen_gcc subtree update)
 - #157123 (library: optimize truncate method)
 - #159916 (Optimize `str.escape_default().to_string()`)
 - #163510 (process: Improve the output of `Debug` for `ExitStatus` on Unix)
 - #164508 (ping me for layout invariant changes)
 - #164758 (Update dependency jinja2 to v3.1.6 [SECURITY])
 - #164816 (Take the colon span into account for struct field initializers)
 - #164836 (Add regression test for #162109)
 - #164846 (Remove contradictory inequalities from overflow safety docs)
 - #164857 (Do not checkout Cargo for bootstrap tests)
 - #164868 (Fix skipping library build with `--keep-stage[-std]`)
 - #164872 (cg_llvm: clarify Send / Sync story for modules)
 - #164880 (Add context span showing item that can't be annotated)
 - #164881 (Add FIXME comments to `from_ascii_bytes_radix_impl`)
 - #164884 (Windows: bounds-check the reparse point name in `read_link`)
rust-bors Bot pushed a commit that referenced this pull request Oct 25, 2026
…uwer

Rollup of 20 pull requests

Successful merges:

 - #160404 (fd-views: AsRef<File>&Co. for BorrowedFd)
 - #161362 ( rustdoc: Correctly handle reexports when --document-private-items is used)
 - #163769 (reborrow: Fix various ICEs related to auto reborrowing of user-space types)
 - #164764 (Test(lib/sync): Fix `test_rwlock_max_readers` for 32bit architectures)
 - #164860 (std::fs: read interrupted by a signal, read_buf_exact_at reports EOF.)
 - #164869 (rustc_codegen_gcc subtree update)
 - #157123 (library: optimize truncate method)
 - #159916 (Optimize `str.escape_default().to_string()`)
 - #163510 (process: Improve the output of `Debug` for `ExitStatus` on Unix)
 - #164508 (ping me for layout invariant changes)
 - #164758 (Update dependency jinja2 to v3.1.6 [SECURITY])
 - #164816 (Take the colon span into account for struct field initializers)
 - #164836 (Add regression test for #162109)
 - #164846 (Remove contradictory inequalities from overflow safety docs)
 - #164857 (Do not checkout Cargo for bootstrap tests)
 - #164868 (Fix skipping library build with `--keep-stage[-std]`)
 - #164872 (cg_llvm: clarify Send / Sync story for modules)
 - #164880 (Add context span showing item that can't be annotated)
 - #164881 (Add FIXME comments to `from_ascii_bytes_radix_impl`)
 - #164884 (Windows: bounds-check the reparse point name in `read_link`)
rust-bors Bot pushed a commit that referenced this pull request Oct 25, 2026
Rollup merge of #161362 - GuillaumeGomez:reexports-document-private, r=Urgau

 rustdoc: Correctly handle reexports when --document-private-items is used

Fixes #159109.

This PR makes the (private) reexport work like the public ones when the `--document-private-items` option is used. I still differentiate between imports (`use`) and reexports (`pub(...) use`) in this PR as I don't think we should display imports.

r? @Urgau
@rust-bors
rust-bors Bot merged commit 86e7417 into rust-lang:main Oct 25, 2026
15 of 16 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Oct 25, 2026
@GuillaumeGomez
GuillaumeGomez deleted the reexports-document-private branch October 25, 2026 21:11
@rust-timer

Copy link
Copy Markdown
Collaborator

Note

This PR was benchmarked as part of triage of its containing rollup: triage URL.

Finished benchmarking commit (2c386ff): comparison URL.

Overall result: ❌ regressions - please read:

Our benchmarks found a performance regression caused by this PR.
This might be an actual regression, but it can also be just noise.

Next Steps:

  • If the regression was expected or you think it can be justified,
    please write a comment with sufficient written justification, and add
    @rustbot label: +perf-regression-triaged to it, to mark the regression as triaged.
  • If you think that you know of a way to resolve the regression, try to create
    a new PR with a fix for the regression.
  • If you do not understand the regression or you think that it is just noise,
    you can ask the @rust-lang/wg-compiler-performance working group for help (members of this group
    were already notified of this PR).

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.9% [0.1%, 7.9%] 19
Regressions ❌
(secondary)
27.3% [0.1%, 189.6%] 8
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.9% [0.1%, 7.9%] 19

Max RSS (memory usage)

Results (primary 0.7%, secondary 29.6%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
1.3% [0.5%, 4.8%] 9
Regressions ❌
(secondary)
29.6% [20.3%, 38.9%] 2
Improvements ✅
(primary)
-1.1% [-1.5%, -0.5%] 3
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.7% [-1.5%, 4.8%] 12

Cycles

Results (primary 0.9%, secondary 63.7%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
1.2% [0.4%, 4.9%] 11
Regressions ❌
(secondary)
63.7% [2.3%, 161.8%] 3
Improvements ✅
(primary)
-0.7% [-0.8%, -0.6%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.9% [-0.8%, 4.9%] 13

Binary size

This perf run didn't have relevant results for this metric.

Artifact size: 405.87 MiB -> 405.94 MiB (0.02%)

@rustbot rustbot added the perf-regression Performance regression. label Oct 25, 2026
@GuillaumeGomez

Copy link
Copy Markdown
Member Author

Taking a look at the performance impact.

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 27, 2026
…aumeGomez

rustdoc-search: rank re-export lower

Fixes a side effect of rust-lang#161362 reported on Zulip.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 27, 2026
…aumeGomez

rustdoc-search: rank re-export lower

Fixes a side effect of rust-lang#161362 reported on Zulip.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 27, 2026
…aumeGomez

rustdoc-search: rank re-export lower

Fixes a side effect of rust-lang#161362 reported on Zulip.
rust-bors Bot pushed a commit that referenced this pull request Oct 28, 2026
Rollup merge of #165024 - notriddle:re-export-lower, r=GuillaumeGomez

rustdoc-search: rank re-export lower

Fixes a side effect of #161362 reported on Zulip.
darkraider01 pushed a commit to darkraider01/miri that referenced this pull request Oct 29, 2026
rustdoc-search: rank re-export lower

Fixes a side effect of rust-lang/rust#161362 reported on Zulip.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 30, 2026
…-perf, r=notriddle

rustdoc: Fix performance regression for private documented items

Should help with rust-lang#161362.

The idea is to not (doc) inline private reexports by default. That will save us a lot of `clean`ing for external items and for html pages generation.

r? ghost
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 30, 2026
…-perf, r=notriddle

rustdoc: Fix performance regression for private documented items

Should help with rust-lang#161362.

The idea is to not (doc) inline private reexports by default. That will save us a lot of `clean`ing for external items and for html pages generation.

r? ghost
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 30, 2026
…-perf, r=notriddle

rustdoc: Fix performance regression for private documented items

Should help with rust-lang#161362.

The idea is to not (doc) inline private reexports by default. That will save us a lot of `clean`ing for external items and for html pages generation.

r? ghost
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 31, 2026
…-perf, r=notriddle

rustdoc: Fix performance regression for private documented items

Should help with rust-lang#161362.

The idea is to not (doc) inline private reexports by default. That will save us a lot of `clean`ing for external items and for html pages generation.

r? ghost
@obi1kenobi

Copy link
Copy Markdown
Member

Good news / bad news situation.

This PR fixes the capability gap pointed out in (part of) #111338 and means that cargo-semver-checks will finally be able to fully resolve the public API even in the presence of shadowing due to private use items. Yay! This is a 3.5 year old limitation 🎉

Unfortunately, this is also a material externally-observable change in behavior and it broke our test suite 😅 It probably should have bumped the JSON format version.

Don't worry about bumping it now, I'll find some way to work around it. But in general, I think it'd be better to bump more often than strictly necessary, than to miss a bump. The cargo-semver-checks test suites are quite deep (or else the project would permanently be in debugging hell), but at the same time we've had ~45 format version bumps since I started the project so the operational steps for dealing with a version bump are very well exercised.

Anyway — thanks for building this, I'm excited to have it and even more excited to be able to close the book on a 3.5yr old shortcoming in cargo-semver-checks! The format version thing isn't a huge deal as a one-off, I just wanted to bring it up as an observation and experience report.

rust-bors Bot pushed a commit that referenced this pull request Oct 31, 2026
Rollup merge of #164989 - GuillaumeGomez:rustdoc-doc-private-perf, r=notriddle

rustdoc: Fix performance regression for private documented items

Should help with #161362.

The idea is to not (doc) inline private reexports by default. That will save us a lot of `clean`ing for external items and for html pages generation.

r? ghost
hashcatHitman pushed a commit to hashcatHitman/rustc_codegen_gcc that referenced this pull request Oct 31, 2026
…uwer

Rollup of 20 pull requests

Successful merges:

 - rust-lang/rust#160404 (fd-views: AsRef<File>&Co. for BorrowedFd)
 - rust-lang/rust#161362 ( rustdoc: Correctly handle reexports when --document-private-items is used)
 - rust-lang/rust#163769 (reborrow: Fix various ICEs related to auto reborrowing of user-space types)
 - rust-lang/rust#164764 (Test(lib/sync): Fix `test_rwlock_max_readers` for 32bit architectures)
 - rust-lang/rust#164860 (std::fs: read interrupted by a signal, read_buf_exact_at reports EOF.)
 - rust-lang/rust#164869 (rustc_codegen_gcc subtree update)
 - rust-lang/rust#157123 (library: optimize truncate method)
 - rust-lang/rust#159916 (Optimize `str.escape_default().to_string()`)
 - rust-lang/rust#163510 (process: Improve the output of `Debug` for `ExitStatus` on Unix)
 - rust-lang/rust#164508 (ping me for layout invariant changes)
 - rust-lang/rust#164758 (Update dependency jinja2 to v3.1.6 [SECURITY])
 - rust-lang/rust#164816 (Take the colon span into account for struct field initializers)
 - rust-lang/rust#164836 (Add regression test for rust-lang/rust#162109)
 - rust-lang/rust#164846 (Remove contradictory inequalities from overflow safety docs)
 - rust-lang/rust#164857 (Do not checkout Cargo for bootstrap tests)
 - rust-lang/rust#164868 (Fix skipping library build with `--keep-stage[-std]`)
 - rust-lang/rust#164872 (cg_llvm: clarify Send / Sync story for modules)
 - rust-lang/rust#164880 (Add context span showing item that can't be annotated)
 - rust-lang/rust#164881 (Add FIXME comments to `from_ascii_bytes_radix_impl`)
 - rust-lang/rust#164884 (Windows: bounds-check the reparse point name in `read_link`)
eduardorittner pushed a commit to eduardorittner/miri that referenced this pull request Nov 2, 2026
…notriddle

rustdoc: Fix performance regression for private documented items

Should help with rust-lang/rust#161362.

The idea is to not (doc) inline private reexports by default. That will save us a lot of `clean`ing for external items and for html pages generation.

r? ghost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

perf-regression Performance regression. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

--document-private-items does not document private reexports

8 participants