rust-lang / rust-lang/rust

Unable to run a specific doctest

Open
#161,830 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-doctests C-bug needs-triage T-rustdoc
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

I need to run a particular doc test.

To run the docket I use the following command

cargo test --all-features --doc 'package::core::Package\ (line\ 58)'

I expected to see this happen: Only the particular doctest package::core::Package at line 58 is executed.

Instead, this happened: the doc test runs, however 2 different other doc tests also run.

➜  bpx-rs git:(develop) ✗ cargo test --all-features --doc 'package::core::Package\ (line\ 58)'          
    Finished `test` profile [unoptimized + debuginfo] target(s) in 0.06s
   Doc-tests bpx

running 3 tests
test src/sd/debug.rs - sd::debug::Debugger<'a>::set (line 158) ... ok
test src/shader/core.rs - shader::core::ShaderPack (line 58) ... ok
test src/package/core.rs - package::core::Package (line 58) ... ok

test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 48 filtered out; finished in 0.24s
Meta

The same issue occurs on both nightly and stable.

cargo +nightly --version

cargo 1.100.0-nightly (e8cb624d5 2026-08-22)

cargo --version

cargo 1.93.0 (083ac5135 2025-12-15)

rustc --version --verbose:

rustc 1.93.0 (254b59607 2026-01-19)
binary: rustc
commit-hash: 254b59607d4417e9dffbc307138ae5c86280fe4c
commit-date: 2026-01-19
host: aarch64-apple-darwin
release: 1.93.0
LLVM version: 21.1.8

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the reported cargo test --all-features --doc command against the bpx-rs example and compare its filter behavior on stable and nightly. Investigate how Cargo or rustdoc matches the doctest name and line number; done means the command executes only package::core::Package at line 58 while preserving expected doctest filtering.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli, testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.