Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Kannen opened this issue Aug 23, 2021 · 1 comment · Fixed by #89422
Closed

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

Kannen opened this issue Aug 23, 2021 · 1 comment · Fixed by #89422
Labels
A-doctests Area: Documentation tests, run by rustdoc C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@Kannen
Copy link

Kannen commented Aug 23, 2021

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
@Kannen Kannen added the C-bug Category: This is a bug. label Aug 23, 2021
@camelid camelid added A-doctests Area: Documentation tests, run by rustdoc T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Aug 30, 2021
@GuillaumeGomez
Copy link
Member

I think that the solution here would be to replace white spaces with dash because we split on white spaces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-doctests Area: Documentation tests, run by rustdoc C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants