Skip to content

add new rustdoc::hidden_intra_doc_links lint #144750

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

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

lolbinarycat
Copy link
Contributor

@rustbot
Copy link
Collaborator

rustbot commented Jul 31, 2025

r? @GuillaumeGomez

rustbot has assigned @GuillaumeGomez.
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. labels Jul 31, 2025
@lolbinarycat lolbinarycat force-pushed the rustdoc-intra-doc-hidden-144664 branch from 1b659dd to d59f4ae Compare July 31, 2025 19:52
@rust-log-analyzer

This comment has been minimized.

@lolbinarycat lolbinarycat force-pushed the rustdoc-intra-doc-hidden-144664 branch from d59f4ae to fa4eb64 Compare July 31, 2025 20:02
@rust-log-analyzer

This comment has been minimized.

@lolbinarycat lolbinarycat force-pushed the rustdoc-intra-doc-hidden-144664 branch from fa4eb64 to 9be4ffa Compare August 1, 2025 19:28
@rustbot
Copy link
Collaborator

rustbot commented Aug 1, 2025

Unknown labels: T-rustdoc-frontend

@lolbinarycat
Copy link
Contributor Author

lolbinarycat commented Aug 1, 2025

current issue: reexports. an item is only truly "hidden" if there are no non-hidden paths to it. there doesn't seem to be any easy queries to find all the reexports of an item, so the only way to do this would be traversing the entire crate, like how strip_hidden works.

one potential workaround that would get rid of false positives at the cost of way more false negatives would be to only emit the lint if we only emit the lint when linking from something that is not hidden anywhere in the path to something that is directly marked as hidden.

i think the correct solution however is to rework how the strip_hidden pass works to always run, and in --document-hidden-items mode, collect a DefIdSet of all the hidden items.

the lint could also just be based on if an item is actually going to be documented, but then it doesn't work consistently in --document-hidden-items mode...

EDIT: we apparently collect the paths of things before stripping, so that doesn't work, but strip_hidden only runs on non-local crates, so that doesn't work either.

@lolbinarycat lolbinarycat marked this pull request as draft August 1, 2025 19:44
@rustbot
Copy link
Collaborator

rustbot commented Aug 1, 2025

Unknown labels: S-waiting-on-author

@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu-llvm-19-2 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
    Checking gimli v0.32.0
[RUSTC-TIMING] panic_unwind test:false 0.062
[RUSTC-TIMING] std_detect test:false 0.258
    Checking hashbrown v0.15.4
error: non-hidden documentation for `std_detect` links to hidden item `is_x86_feature_detected`
 --> library/std_detect/src/lib.rs:6:29
  |
6 | //! * `x86` and `x86_64`: [`is_x86_feature_detected`]
  |                             ^^^^^^^^^^^^^^^^^^^^^^^ this item is hidden
  |
  = note: this link will resolve properly if you pass `--document-hidden-items`
  = note: `-D rustdoc::hidden-intra-doc-links` implied by `-D warnings`
  = help: to override `-D warnings` add `#[allow(rustdoc::hidden_intra_doc_links)]`

error: non-hidden documentation for `std_detect` links to hidden item `is_arm_feature_detected`
 --> library/std_detect/src/lib.rs:7:16
  |
7 | //! * `arm`: [`is_arm_feature_detected`]
  |                ^^^^^^^^^^^^^^^^^^^^^^^ this item is hidden
  |
  = note: this link will resolve properly if you pass `--document-hidden-items`

error: non-hidden documentation for `std_detect` links to hidden item `is_aarch64_feature_detected`
 --> library/std_detect/src/lib.rs:8:20
  |
8 | //! * `aarch64`: [`is_aarch64_feature_detected`]
  |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^ this item is hidden
  |
  = note: this link will resolve properly if you pass `--document-hidden-items`

error: non-hidden documentation for `std_detect` links to hidden item `is_riscv_feature_detected`
 --> library/std_detect/src/lib.rs:9:18
  |
9 | //! * `riscv`: [`is_riscv_feature_detected`]
  |                  ^^^^^^^^^^^^^^^^^^^^^^^^^ this item is hidden
  |
  = note: this link will resolve properly if you pass `--document-hidden-items`

error: non-hidden documentation for `std_detect` links to hidden item `is_mips_feature_detected`
  --> library/std_detect/src/lib.rs:10:17
   |
10 | //! * `mips`: [`is_mips_feature_detected`]
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^ this item is hidden
   |
   = note: this link will resolve properly if you pass `--document-hidden-items`

error: non-hidden documentation for `std_detect` links to hidden item `is_mips64_feature_detected`
  --> library/std_detect/src/lib.rs:11:19
   |
11 | //! * `mips64`: [`is_mips64_feature_detected`]
   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^ this item is hidden
   |
   = note: this link will resolve properly if you pass `--document-hidden-items`

error: non-hidden documentation for `std_detect` links to hidden item `is_powerpc_feature_detected`
  --> library/std_detect/src/lib.rs:12:20
   |
12 | //! * `powerpc`: [`is_powerpc_feature_detected`]
   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^ this item is hidden
   |
   = note: this link will resolve properly if you pass `--document-hidden-items`

error: non-hidden documentation for `std_detect` links to hidden item `is_powerpc64_feature_detected`
  --> library/std_detect/src/lib.rs:13:22
   |
13 | //! * `powerpc64`: [`is_powerpc64_feature_detected`]
   |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this item is hidden
   |
   = note: this link will resolve properly if you pass `--document-hidden-items`

error: non-hidden documentation for `std_detect` links to hidden item `is_loongarch_feature_detected`
  --> library/std_detect/src/lib.rs:14:22
   |
14 | //! * `loongarch`: [`is_loongarch_feature_detected`]
   |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this item is hidden
   |
   = note: this link will resolve properly if you pass `--document-hidden-items`

error: non-hidden documentation for `std_detect` links to hidden item `is_s390x_feature_detected`
  --> library/std_detect/src/lib.rs:15:18
   |
15 | //! * `s390x`: [`is_s390x_feature_detected`]
   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^ this item is hidden
   |
   = note: this link will resolve properly if you pass `--document-hidden-items`

error: could not document `std_detect`
warning: build failed, waiting for other jobs to finish...
[RUSTC-TIMING] hashbrown test:false 1.150
[RUSTC-TIMING] gimli test:false 4.180
[RUSTC-TIMING] object test:false 6.962
Command has failed. Rerun with -v to see more details.
Build completed unsuccessfully in 0:29:52
  local time: Fri Aug  1 20:06:02 UTC 2025
  network time: Fri, 01 Aug 2025 20:06:02 GMT
##[error]Process completed with exit code 1.
Post job cleanup.

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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Warn for intra-doc links to doc(hidden) items.
4 participants