Skip to content

rustdoc does not filter correctly doctests when their name contain spaces. #88263

Closed
@Kannen

Description

@Kannen

Consider this file main.rs:

struct Iter<T,P>(T,P);

impl<T,P> Iter<T,P> {
    ///```
    ///assert!(true)
    ///```
    fn len() {}
}

struct Iter2<T,P>(T,P);

impl<T,P> Iter2<T,P> {
    ///```
    ///assert!(true)
    ///```
    fn len() {}
}

fn main() {
}

If one run rustdoc main.rs --test --test-args 'Iter<T, P>::len', he will expect that only
the doctest of Iter<T, P>::len will be run. But the two doctests will be run.

Below is the output of rustdoc main.rs --test --test-args 'Iter<T, P>::len'

running 2 tests
test main.rs - Iter<T, P>::len (line 4) ... ok
test main.rs - Iter2<T, P>::len (line 13) ... ok

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

The problem seems to be the space: it looks like, in the example above, rustdoc will run all tests that matches 'P>::len' (in the argument 'Iter<T, P>::len' there is a space between the , and the P).

Meta

This bug is present since at least one year in all releases.

rustc --version --verbose:

rustc 1.56.0-nightly (a0035916e 2021-08-20)
binary: rustc
commit-hash: a0035916e01d8e644ccd44554c57f0874cef8c8c
commit-date: 2021-08-20
host: x86_64-unknown-linux-gnu
release: 1.56.0-nightly
LLVM version: 12.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    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

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions