-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Remove whitespaces in doctests' name #89422
Conversation
r? @CraftSpider (rust-highfive has picked a reviewer for you, use r? to override) |
Failed the assignment... r? @jyn514 |
Is it not possible to use a no-break space « » (ie U+00A0) instead of « - » ? |
If we do that, it's very likely that people will simply enter the name (with normal white space) and end up in the original issue. |
r? @CraftSpider I don't have time to review this. |
I'm not sure the look with dashes is great, but I also agree that using no-break spaces is likely to lead people to the same issue. Possible Alternative: How often do spaces show up, and where? If we're pretty sure spaces won't show up between identifiers, would it make sense to just strip them entirely? So we instead end up with |
Great idea! I prefer this alternative much more! I'll update it then. |
1690887
to
3792be6
Compare
Done! |
Awesome, looks good to me |
📌 Commit 3792be6 has been approved by |
@bors rollup |
…arth Rollup of 7 pull requests Successful merges: - rust-lang#85223 (rustdoc: Clarified the attribute which prompts the warning) - rust-lang#88847 (platform-support.md: correct ARMv7+MUSL platform triple notes) - rust-lang#88963 (Coerce const FnDefs to implement const Fn traits ) - rust-lang#89376 (Fix use after drop in self-profile with llvm events) - rust-lang#89422 (Replace whitespaces in doctests' name with dashes) - rust-lang#89440 (Clarify a sentence in the documentation of Vec (rust-lang#84488)) - rust-lang#89441 (Normalize after substituting via `field.ty()`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
…arth Rollup of 7 pull requests Successful merges: - rust-lang#85223 (rustdoc: Clarified the attribute which prompts the warning) - rust-lang#88847 (platform-support.md: correct ARMv7+MUSL platform triple notes) - rust-lang#88963 (Coerce const FnDefs to implement const Fn traits ) - rust-lang#89376 (Fix use after drop in self-profile with llvm events) - rust-lang#89422 (Replace whitespaces in doctests' name with dashes) - rust-lang#89440 (Clarify a sentence in the documentation of Vec (rust-lang#84488)) - rust-lang#89441 (Normalize after substituting via `field.ty()`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
fix: remove whitespaces from doctest names When rustdoc runs doctests, it removes whitespaces from the tests' path ([code](https://github.com/rust-lang/rust/blob/25bb1c13bd472b75ceebee3b8dcf4dcbc431a8be/src/librustdoc/doctest.rs#L951)). 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](https://github.com/rust-lang/rust/blob/25bb1c13bd472b75ceebee3b8dcf4dcbc431a8be/src/librustdoc/config.rs#L513-L514); 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: ```rust 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.
Fixes #88263.
Instead of handling white spaces when we filter tests (which would be quite complicated since we split on them!), I propose to instead replace them with dashes.
So for example, this:
becomes:
r? @jyn514