rust-lang / rust-lang/rust-analyzer

Doctests can't be triggered for methods of structs with multiple lifetimes

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

Nobody has claimed this yet.

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.2971-standalone (ffcdbbd906 2026-07-13)

rustc version: rustc 1.99.0-nightly (14cae6813 2026-07-08)

editor or extension: VSCode

code snippet to reproduce:

struct Foo<'a, 'b>(&'a (), &'b ());

impl<'a, 'b> Foo<'a, 'b> {
    /// ```
    /// let _ = "Hello, world!";
    /// ```
    fn method(self) {
        unimplemented!()
    }
}

Clicking "Run Doctest" above this doctest gives the following.

 *  Executing task: cargo test --doc --package ra-test -- Foo<'a>::method --nocapture 

    Finished `test` profile [unoptimized + debuginfo] target(s) in 0.00s
   Doc-tests ra_test

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 1 filtered out; finished in 0.00s

all doctests ran in 0.36s; merged doctests compilation took 0.13s
 *  Terminal will be reused by tasks, press any key to close it. 

The parameter 'b is missing from the generated command's filter, and so the command fails to find the right test.

Similar to https://github.com/rust-lang/rust-analyzer/issues/14142, which is fixed in https://github.com/rust-lang/rust-analyzer/pull/14185.

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 reproducing the issue from the provided Rust struct and impl snippet, then inspect the Run Doctest entry point and the generated cargo test --doc filter shown in the report. The fix is done when methods on structs with multiple lifetimes produce a filter containing both lifetime parameters and the doctest runs instead of reporting zero tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
74/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.