Skip to content

docs: repair the rustdoc links that no longer resolve - #7489

Merged
oferchen merged 1 commit into
masterfrom
docs/rustdoc-staleness
Aug 25, 2026
Merged

oferchen merged 1 commit into
masterfrom
docs/rustdoc-staleness

Conversation

@oferchen

Copy link
Copy Markdown
Owner

The workspace had never been run under rustdoc's link lints, so doc comments had drifted from the code they describe with nothing reporting it.

RUSTDOCFLAGS="-W rustdoc::broken_intra_doc_links \
              -W rustdoc::private_intra_doc_links \
              -W rustdoc::invalid_codeblock_attributes \
              -W rustdoc::invalid_html_tags -W rustdoc::bare_urls" \
  cargo doc --workspace --all-features --no-deps \
            --document-private-items --keep-going
lint before after
unresolved link 98 0
public doc linking a private item 30 0
ambiguous link (hard error) 4 0
crates that fail to document 6 4

engine and branding build their docs again. missing_docs reported four crate- and binary-level headers with no //! at all; those are written rather than suppressed.

Why this is not one mechanical pass

The failing links needed opposite repairs:

  • Unresolvable targets - platform-gated items, private items named from a public doc, items that no longer exist. These become plain code spans. An unresolved link already renders as literal [`Foo`], so the brackets were costing readability and buying no navigation.
  • Bracketed prose that was never a link - T[i] in a formula, argv[0], info_verbosity[0], the IPv6 literal [::1], and editorial [s]/[if] inside quotations from the upstream source. These keep their text and escape the bracket.
  • Reference-style links, where the use site and its separate [`X`]: path definition line only make sense together, so both halves go.
  • Ambiguous targets naming both a function and a module. Which spelling is correct is a question about the prose, not the code: all four sentences describe a call ("the multiplier used by bounded", "mirrors metadata()"), so all four take the function form. mod@ would have pointed the reader at a container none of them mean.

Scope constraint

Every edit is confined to /// and //! lines - git diff shows zero changed lines outside doc comments. That constraint is load-bearing rather than cosmetic: a pattern broad enough to catch a bare [X] also matches m[i], K[i] and S[i] in the MD5 scalar loop, which would not compile.

Deliberately not in this PR

Seven links whose targets sit in modules inlined into a parent through a re-export. rustdoc re-resolves those in the importing module's scope and reports them against a mod statement that does not contain the text. Measured on the unmodified base commit, so cargo doc does not complete on this workspace today either - these are inherited, not introduced. Repairing them needs a per-item scope decision rather than a rewrite rule.

A -D rustdoc::broken_intra_doc_links CI gate is the natural follow-up, and is only defensible once those seven are gone.

Verification

  • git diff -U0 filtered to non-doc lines: 0
  • rebased onto current master; footprint unchanged at 77 files, which shows master does not already carry it
  • lint counts above measured before and after on the same host

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Aug 24, 2026
Nobody had run the workspace under rustdoc's link lints, so the doc comments
had drifted from the code they describe without anything reporting it:

    RUSTDOCFLAGS="-W rustdoc::broken_intra_doc_links \
                  -W rustdoc::private_intra_doc_links \
                  -W rustdoc::invalid_codeblock_attributes \
                  -W rustdoc::invalid_html_tags -W rustdoc::bare_urls" \
      cargo doc --workspace --all-features --no-deps \
                --document-private-items --keep-going

That reported 98 unresolved links and 30 links from public docs at private
items. Both are now zero. Four crates additionally failed outright, because
they deny broken_intra_doc_links and carried links rustdoc could not
disambiguate; `engine` and `branding` build their docs again.

The targets fell into classes that need opposite repairs, so this is not one
mechanical pass:

  * unresolvable targets - platform-gated items, private items named from a
    public doc, and items that no longer exist. These become plain code spans:
    an unresolved link already renders as literal `[`Foo`]`, so the brackets
    were costing readability and buying no navigation.
  * bracketed prose that was never a link - `T[i]` in a formula, `argv[0]`,
    `info_verbosity[0]`, the IPv6 literal `[::1]`, and editorial `[s]`/`[if]`
    inside quotations from the upstream source. These keep their text and
    escape the bracket.
  * reference-style links, where the use site and its separate `[`X`]: path`
    definition line only make sense together, so both halves go.
  * ambiguous targets naming both a function and a module. Which spelling is
    correct is a question about the prose, not the code: all four sentences
    describe a call ("the multiplier used by `bounded`", "mirrors
    `metadata()`"), so all four take the function form. `mod@` would have
    pointed the reader at a container none of them mean.

Four crate-level and binary-level doc headers were missing entirely, which is
what the `missing_docs` count was measuring; those are written rather than
suppressed.

Every edit is confined to `///` and `//!` lines - `git diff` shows zero
changed lines outside doc comments. That constraint is load-bearing: an
earlier revision matched a bare `[X]` pattern across whole files and rewrote
`m[i]`, `K[i]` and `S[i]` inside the MD5 scalar loop, which would not have
compiled.

Not fixed here, and inherited rather than introduced - seven links whose
targets sit in modules inlined into a parent through a re-export, so rustdoc
re-resolves them in the importing module's scope and reports them against a
`mod` statement that does not contain the text. Measured on the unmodified
base commit, so `cargo doc` does not complete on this workspace today either.
Repairing them needs a per-item scope decision rather than a rewrite rule,
and a `-D rustdoc::broken_intra_doc_links` gate is only defensible once they
are gone.
@oferchen
oferchen force-pushed the docs/rustdoc-staleness branch from c72d81d to 6f1e0c9 Compare August 24, 2026 22:10
@oferchen
oferchen merged commit b2c291e into master Aug 25, 2026
77 checks passed
@oferchen
oferchen deleted the docs/rustdoc-staleness branch August 25, 2026 00:12
oferchen added a commit that referenced this pull request Sep 2, 2026
`cargo doc` ran in exactly one place - pages.yml, on `push: branches:
[master]` - so a broken intra-doc link was discoverable only after it landed
and reddened master. Four PRs (#7264, #7489, #7555 and the commit before this
one) repaired the same class post-merge.

The new job mirrors pages.yml's invocation exactly, RUSTDOCFLAGS included.
Matching it is the substance: a divergent flag set would gate a different
question than the one Pages actually asks, so a PR could pass here and still
redden master. `crates/fast_io/src/io_uring` is
`cfg(all(target_os = "linux", feature = "io_uring"))`, so ubuntu plus
--all-features is the only combination that compiles the files where the last
three occurrences of this class lived.

`continue-on-error: true`, matching unsafe-safety-comment-audit: it reports
the link before it lands without adding a merge-blocking context to a queue
that already carries ~60 checks per PR. Promoting it to a required context is
a repo-ruleset change and a separate decision.

Ordered second deliberately - the gate is red on the parent commit, and green
on this one.

tools/ci/check_pr_check_name_uniqueness.py passes: 76 pull_request check
names, each with one publisher.
oferchen added a commit that referenced this pull request Sep 2, 2026
* docs(fast_io): stop linking public docs at private items

The Pages job runs `cargo doc --workspace --all-features --no-deps` with
RUSTDOCFLAGS=-D rustdoc::broken_intra_doc_links, and it has been failing on
master since a622325:

    error: unresolved link to `super::send_zc_pipeline::SendZcPipeline`
      --> crates/fast_io/src/io_uring/mod.rs:117:1
      = note: no item named `send_zc_pipeline` in module `fast_io`
    error: could not document `fast_io`

`send_zc_pipeline` is declared `mod`, not `pub mod`, so no path through the
public module tree reaches `SendZcPipeline` and the link can never resolve.
Four sibling links have the same shape - a public item's doc pointing at an
item that is private, `pub(super)`, or in a private module:

  - send_zc.rs:22        `super::send_zc_pipeline::SendZcPipeline` (the error)
  - socket_writer.rs:20  `send_zc_pipeline::SendZcPipeline`
  - socket_writer.rs:308 `SendZcPipeline::drop`
  - file_writer.rs:37    `super::batching::MIN_RING_BATCH_CHUNKS`
  - receiver.rs:472,524  `Self::absorb_commit_error` (x2)

Each becomes plain backticks instead of an intra-doc link. The prose still
names the item for a reader of the source; what it no longer does is ask
rustdoc to resolve a path that leads out of the public tree. Making these
items public to satisfy the doc tool would widen the crate's API for a
formatting reason, and `send_zc_pipeline` in particular is an implementation
detail of `socket_writer`. socket_writer.rs:306 already spells the same module
name in plain backticks, so this is the file's own existing convention.

Measured on Linux with the exact Pages invocation, since `io_uring` is
`cfg(all(target_os = "linux", feature = "io_uring"))` and cannot be reached
from a macOS `cargo doc` at all:

  before: EXIT=101, 1 error + 2 fast_io warnings (reproduces the CI failure)
  after:  EXIT=0,   zero errors, zero warnings across the whole workspace

* ci: run the rustdoc link check on pull requests

`cargo doc` ran in exactly one place - pages.yml, on `push: branches:
[master]` - so a broken intra-doc link was discoverable only after it landed
and reddened master. Four PRs (#7264, #7489, #7555 and the commit before this
one) repaired the same class post-merge.

The new job mirrors pages.yml's invocation exactly, RUSTDOCFLAGS included.
Matching it is the substance: a divergent flag set would gate a different
question than the one Pages actually asks, so a PR could pass here and still
redden master. `crates/fast_io/src/io_uring` is
`cfg(all(target_os = "linux", feature = "io_uring"))`, so ubuntu plus
--all-features is the only combination that compiles the files where the last
three occurrences of this class lived.

`continue-on-error: true`, matching unsafe-safety-comment-audit: it reports
the link before it lands without adding a merge-blocking context to a queue
that already carries ~60 checks per PR. Promoting it to a required context is
a repo-ruleset change and a separate decision.

Ordered second deliberately - the gate is red on the parent commit, and green
on this one.

tools/ci/check_pr_check_name_uniqueness.py passes: 76 pull_request check
names, each with one publisher.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant