Skip to content

rustdoc --test doesn't recognize register_tool #143930

@zjp-CN

Description

@zjp-CN

I tried this code:

// lib.rs
#[rapx::tag]
fn f() {}
# ✅ This compiles and generates doc/
$ rustdoc lib.rs -Zcrate-attr="feature(register_tool)" -Zcrate-attr="register_tool(rapx)"
# 💥This doesn't compile
$ rustdoc --test lib.rs -Zcrate-attr="feature(register_tool)" -Zcrate-attr="register_tool(rapx)"
error[E0433]: failed to resolve: use of unresolved module or unlinked crate `rapx`
 --> lib.rs:1:3
  |
1 | #[rapx::tag]
  |   ^^^^ use of unresolved module or unlinked crate `rapx`

I expected to see this happen: rust --test will recognize register_tool as rustdoc does.

Instead, this happened: rust --test doesn't recognize register_tool.

Meta

rustc --version --verbose:

rustc 1.89.0-nightly (45acf54ee 2025-06-16)
binary: rustc
commit-hash: 45acf54eea118ed27927282b5e0bfdcd80b7987c
commit-date: 2025-06-16
host: aarch64-unknown-linux-gnu
release: 1.89.0-nightly
LLVM version: 20.1.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-CLIArea: Command-line interface (CLI) to the compilerA-attributesArea: Attributes (`#[…]`, `#![…]`)A-doctestsArea: Documentation tests, run by rustdocC-bugCategory: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions