rust-lang / rust-lang/rust-analyzer

Missing "Run Doctest" CodeLens for trait method doctests

Open
#23,326 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-doc-comments C-bug
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

rust-analyzer version: 0.3.3041

rustc version: rustc 1.98.0 (88d9e12ae 2026-08-18)

editor or extension: VSCode

relevant settings: none

code snippet to reproduce:

///```
///assert!(true); // This does have a doctest
///```
trait Trait {
    ///```
    ///assert!(true); // This does not
    ///```
    fn method(&self);
}

The first doc-test has a Run Doctest lens while the second has none.

cargo test --doc correctly finds both doctests and runs them:

running 2 tests
test src/lib.rs - Trait::method (line 5) ... ok
test src/lib.rs - Trait (line 1) ... ok
Example image Image

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

Reproduce the issue in src/lib.rs and run cargo test --doc to confirm that both doctests are discovered. Then trace rust-analyzer's Run Doctest CodeLens handling for the trait and its method; done means the method receives a lens like the trait while cargo test --doc still reports both tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, vscode
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.