Skip to content

rust: expose compilation helpers for custom doctest rules - #4306

Open
jrandolf wants to merge 3 commits into
bazelbuild:mainfrom
jrandolf:feat/public-rustdoc-compilation
Open

jrandolf wants to merge 3 commits into
bazelbuild:mainfrom
jrandolf:feat/public-rustdoc-compilation

Conversation

@jrandolf

@jrandolf jrandolf commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Expose the existing rustdoc action builder, dependency conversion helper and LintsInfo provider through public load paths so custom doctest rules can reuse compiler setup without loading private modules.

The public contract documents required rule attributes, toolchains, the C++ fragment, every returned action field, mutation of caller-supplied Args, and the distinction between build-time and runfiles-based invocations. The action builder now creates a fresh Args object when flags are omitted, so optional lint handling works with its default argument. Provider identities are unchanged.

Build-time invocations pass rustdoc as a File so Bazel can rewrite its executable path when path mapping is enabled. A custom rule using only public loads compiles and executes a native doctest with a normal dependency, a procedural macro and lint configuration. It checks dependency-provider conversion and the identity of the exported lint provider. This is a low-level API proposal; the caller still declares outputs and supplies any cross-platform test runner.

Fixes #4301.

Validation: bazel test //test/unit/public_rustdoc:public_rustdoc_test //test/unit/lint_flags:all (4 tests passed), also with --experimental_output_paths=strip --config=clippy --config=rustfmt (4 tests passed). The path-mapping case failed before the fix. Formatting and whitespace checks passed.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide a public compilation interface for custom doctest rules

1 participant