Skip to content

docs(cuda-macros): seven rustdoc errors the docs gate cannot see - #1014

Merged
nihalpasham merged 1 commit into
NVIDIA:mainfrom
vyncint:docs/cuda-macros-private-doc-links
Aug 19, 2026
Merged

nihalpasham merged 1 commit into
NVIDIA:mainfrom
vyncint:docs/cuda-macros-private-doc-links

Conversation

@vyncint

@vyncint vyncint commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Summary

cargo doc --no-deps --document-private-items -p cuda-macros reports seven errors under -D warnings. The CI gate omits --document-private-items, so it reports none of them:

lib.rs:2461  unresolved link to `SizeRequirementOverflow`
lib.rs:2462  unresolved link to `SizeRequirementViolated`
lib.rs:7664  unresolved link to `SchedulingPolicy`
lib.rs:7665  unresolved link to `AsyncKernelLaunch`
lib.rs:7671  unresolved link to `LaunchConfig`
lib.rs:4653  could not parse code block as Rust code
lib.rs:4664  could not parse code block as Rust code

The five links

All five name types in crates this one does not depend on — cuda-macros takes only quote, syn, proc-macro2 and reserved-oxide-symbols, while SizeRequirement* are cuda_core::LaunchContractError variants, SchedulingPolicy/AsyncKernelLaunch are cuda-async, and LaunchConfig is cuda-core. Rustdoc has nothing to resolve them against, so the brackets render as literal text.

The file already contains both correct idioms and uses them elsewhere, so this matches the local convention rather than inventing one:

Idiom Already used at For
plain code span lib.rs:6012, :6014 the same two SizeRequirement* variants, 3,500 lines above the broken links
explicit docs.rs URL lib.rs:508, :5927 the same LaunchConfig type as the broken link at :7671

The two code blocks

Both are ```ignore fences whose contents are path-rewrite illustrations, not Rust:

index_1d()   →  ::cuda_device::thread::__internal::index_1d(&scope)

ignore still asks rustdoc to parse the block for invalid_rust_codeblocks, and it stops on the → (U+2192) with "unknown start of token". These are ```text now, which is what the file's two existing ```text blocks are for. The other 27 ```ignore blocks are real Rust and are untouched.

Not proposing the gate change here

Three other crates have private-doc errors too — llvm-export, mir-importer, mir-lower, six between them — and two of the four files involved are being edited by open PRs right now. Adding --document-private-items to the docs gate is its own change once the tree is clean, and worth doing, since this class is otherwise only found by looking.

Testing

Local, no GPU.

  • --document-private-items on cuda-macros now passes under -D warnings where it reported seven errors
  • The CI docs gate still passes; --lib tests unchanged (99 passed)
  • Counts move exactly as intended — ```ignore 29→27, ```text 2→4. Both fences edited by line number after a text-match replace hit the wrong block on my first attempt
  • cargo oxide run <example> — not applicable, doc comments only

`cargo doc --no-deps --document-private-items` on this crate reports seven
errors under `-D warnings`. The CI gate omits `--document-private-items`, so
it reports none of them:

  lib.rs:2461  unresolved link to `SizeRequirementOverflow`
  lib.rs:2462  unresolved link to `SizeRequirementViolated`
  lib.rs:7664  unresolved link to `SchedulingPolicy`
  lib.rs:7665  unresolved link to `AsyncKernelLaunch`
  lib.rs:7671  unresolved link to `LaunchConfig`
  lib.rs:4653  could not parse code block as Rust code
  lib.rs:4664  could not parse code block as Rust code

**The five links.** All five name types in crates this one does not depend on
-- `cuda-macros` takes only `quote`, `syn`, `proc-macro2` and
`reserved-oxide-symbols`, while `SizeRequirement*` are `cuda_core`
`LaunchContractError` variants, `SchedulingPolicy` and `AsyncKernelLaunch` are
`cuda-async`, and `LaunchConfig` is `cuda-core`. Rustdoc has nothing to resolve
them against, so the brackets render as literal text.

The file already contains both correct idioms and uses them elsewhere, so this
matches the local convention rather than inventing one:

  * plain code span -- `LaunchContractError::SizeRequirementViolated` at
    lib.rs:6012 and :6014, describing the same two variants as the broken
    links 3,500 lines above;
  * explicit URL -- `[`LaunchConfig`](https://docs.rs/cuda-core/...)` at
    lib.rs:508 and :5927, for the same type as the broken link at :7671.

So `SizeRequirement*`, `SchedulingPolicy` and `AsyncKernelLaunch` become plain
spans, and `LaunchConfig` at :7671 gets the docs.rs URL its two siblings
already use.

**The two code blocks.** Both are ```ignore fences whose contents are
path-rewrite illustrations, not Rust:

    /// index_1d()   →  ::cuda_device::thread::__internal::index_1d(&scope)

`ignore` still asks rustdoc to parse the block for `invalid_rust_codeblocks`,
and it stops on the `→` (U+2192) with "unknown start of token". These are
```text now, which is what the file's two existing ```text blocks are for. The
other 27 ```ignore blocks are real Rust and are left alone.

Not proposing to add `--document-private-items` to the docs gate here: three
other crates have private-doc errors too (`llvm-export`, `mir-importer`,
`mir-lower`, six between them), and two of the four files involved are being
edited by open PRs right now. That is its own change once the tree is clean --
and worth doing, since this class is otherwise only found by looking.

Verified: `--document-private-items` on `cuda-macros` now passes under
`-D warnings` where it reported seven errors; the CI gate still passes; the
crate's `--lib` tests are unchanged. Counts move exactly as intended --
```ignore 29 -> 27, ```text 2 -> 4 -- with both fences edited by line number
after a text-match replace hit the wrong block on the first attempt.

Signed-off-by: Vyncint Ng <[email protected]>
@nihalpasham nihalpasham added documentation Improvements or additions to documentation build-related Build scripts, toolchain discovery, or compilation setup host-apis Host-side runtime APIs (cuda-host, cuda-core, cuda-async) labels Aug 19, 2026
@nihalpasham

Copy link
Copy Markdown
Collaborator
  • Verified all seven errors reproduce on main under cargo doc --document-private-items -D warnings and disappear with this diff; the five cross-crate names genuinely are not in cuda-macros' dependency graph, so plain spans and the docs.rs URL are the right endpoints.
  • Leaving the CI flag off until the other crates' private-doc errors are cleaned is deliberate; that cleanup is a follow-up.

@nihalpasham
nihalpasham merged commit 3812a47 into NVIDIA:main Aug 19, 2026
48 checks passed
nihalpasham pushed a commit that referenced this pull request Aug 19, 2026
…not see (#1042)

`cargo doc` without `--document-private-items` never renders a private item,
so it never checks the intra-doc links in a private item's documentation.
Every one of these five sites is on a private fn or method of
`DeviceCollector`, and all five are errors the moment that flag is on:

    error: unresolved link to `kernel`                collector.rs:727
    error: unresolved link to `device`                collector.rs:727
    error: unresolved link to `fqdn`                  collector.rs:1942
    error: unresolved link to `process_call_operand`  collector.rs:2130
    error: unresolved link to `collect`              collector.rs:2269

The first two are not links at all: line 727 quotes a runtime panic message
that contains `#[kernel]` / `#[device]`, and rustdoc reads the brackets as
reference syntax. The message is a literal string, so it becomes one code
span and stops being parsed.

The other three name methods on the same `impl<'tcx> DeviceCollector<'tcx>`
block that the documented items live in, so they only need the `Self::`
prefix to resolve; `fqdn` also loses its `()` suffix, which rustdoc does not
accept on a method path. All three now resolve to the intended methods
(`fqdn` at :994, `collect` at :1031, `process_call_operand` at :1336) rather
than silently pointing nowhere.

This is part of the cleanup named in #1014's merge note. Four more of these
errors remain, in `llvm-export/src/export/ops.rs`,
`mir-importer/src/translator/rvalue.rs` and
`mir-lower/src/convert/ops/aggregate.rs`; all three files are under open
pull requests right now, so they are left for a follow-up rather than
raced. `--document-private-items` can join the docs gate once they land.

Verified: `RUSTDOCFLAGS="-D warnings" cargo doc --no-deps
--document-private-items` in `crates/rustc-codegen-cuda` reports the five
errors above on `main` and exits 0 with this change; the gate's own
invocation (without the flag) exits 0 both before and after.

Signed-off-by: Vyncint Ng <[email protected]>
nihalpasham pushed a commit that referenced this pull request Aug 20, 2026
The docs gate runs `cargo doc` without `--document-private-items`, so it never
renders a private item and never checks the intra-doc links in one. #1014 and
#1042 cleaned `cuda-macros`, `mir-importer/statement.rs` and the codegen
backend's collector; this is one of the four that were left:

    error: unresolved link to `classify_op`
      --> crates/llvm-export/src/export/ops.rs:55

`classify_op` is a `macro_rules!` defined further down the same file, at :138.
A `macro_rules!` macro is in scope only textually after its definition unless
it is exported, so no path resolves from a doc comment above it -- rustdoc says
as much: "`macro_rules` named `classify_op` exists in this crate, but it is not
in scope at this link's location". It becomes a plain code span, and since the
sentence is one step of a four-step contract about this file, it gains "below"
so the reference still points somewhere.

Three of the four remain. One is `make_disjoint_slice_struct` in
`mir-lower/src/convert/ops/aggregate.rs`, which needs only a
`crate::convert::types::` prefix; the other two are `MirFieldAddrOp` and
`MirArrayElementAddrOp` in `mir-importer/src/translator/rvalue.rs`. Both files
are under open pull requests (#1062 and #1064 for the first, #1059 and #1062
for the second), so they are left rather than raced.
`--document-private-items` can join the docs gate once they land.

Verified: `RUSTDOCFLAGS="-D warnings" cargo doc --no-deps
--document-private-items -p llvm-export` reports one unresolved link on `main`
and none with this change. The gate's own invocation passes before and after.
fmt clean.

Comment-only change.

Signed-off-by: Vyncint Ng <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build-related Build scripts, toolchain discovery, or compilation setup documentation Improvements or additions to documentation host-apis Host-side runtime APIs (cuda-host, cuda-core, cuda-async)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants