Uh oh!
There was an error while loading. Please reload this page.
Remove whitespaces in doctests' name - #89422
Conversation
rust-highfive
commented
Oct 1, 2021
r? @CraftSpider (rust-highfive has picked a reviewer for you, use r? to override) |
GuillaumeGomez
commented
Oct 1, 2021
Failed the assignment... r? @jyn514 |
Urgau
commented
Oct 1, 2021
Is it not possible to use a no-break space « » (ie U+00A0) instead of « - » ? |
GuillaumeGomez
commented
Oct 1, 2021
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. |
jyn514
commented
Oct 1, 2021
r? @CraftSpider I don't have time to review this. |
CraftSpider
commented
Oct 1, 2021
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 |
GuillaumeGomez
commented
Oct 1, 2021
Great idea! I prefer this alternative much more! I'll update it then. |
1690887 to
3792be6CompareGuillaumeGomez
commented
Oct 1, 2021
Done! |
CraftSpider
commented
Oct 1, 2021
Awesome, looks good to me |
bors
commented
Oct 1, 2021
📌 Commit 3792be6 has been approved by |
GuillaumeGomez
commented
Oct 1, 2021
@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