Skip to content

fix: remove whitespaces from doctest names #12918

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

Merged
merged 1 commit into from
Aug 1, 2022

Conversation

lowr
Copy link
Contributor

@lowr lowr commented Aug 1, 2022

When rustdoc runs doctests, it removes whitespaces from the tests' path (code). See rust-lang/rust#89422 for details.

Interestingly enough, "Run doctest" has been working without much problem even though rust-analyzer hasn't followed the change. This is because cargo passes the test name to rustdoc via --test-args option, and then rustdoc splits it by whitespace; the last element of the split test name always matches the test name that rustdoc generates.

However, it may run other tests unexpectedly (to be precise, this has long since been a thing because of the split). Consider the following example:

struct A<T, U>(T, U);
struct B<T, U>(T, U);
/// ```
/// doctest here
/// ```
impl<T, U> A<T, U> {}
/// ```
/// doctest here
/// ```
impl<T, U> B<T, U> {}

When you "Run doctest" either of the two, rustdoc considers "U>" one of the test specs and both doctests are run. This patch fixes it by following rustdoc and removing the whitespace from the doctests' name.

@lowr lowr force-pushed the fix/doctest-names branch from 75c572d to d40ab66 Compare August 1, 2022 08:57
@Veykril
Copy link
Member

Veykril commented Aug 1, 2022

Thanks!
@bors r+

@bors
Copy link
Contributor

bors commented Aug 1, 2022

📌 Commit d40ab66 has been approved by Veykril

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Aug 1, 2022

⌛ Testing commit d40ab66 with merge 5edbdd1...

@bors
Copy link
Contributor

bors commented Aug 1, 2022

☀️ Test successful - checks-actions
Approved by: Veykril
Pushing 5edbdd1 to master...

@bors bors merged commit 5edbdd1 into rust-lang:master Aug 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants