about summary refs log tree commit diff
path: root/compiler/rustc_pattern_analysis/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-08-13 22:10:35 +0000
committerbors <bors@rust-lang.org>2024-08-13 22:10:35 +0000
commite5b3e68abf170556b9d56c6f9028318e53c9f06b (patch)
treee760cc3efced2c64d55200a5f319850936baa75b /compiler/rustc_pattern_analysis/src
parent80eb5a8e910e5185d47cdefe3732d839c78a5e7e (diff)
parent05fb8ff4f5602ebf470f6c870906aef9df16d8db (diff)
downloadrust-e5b3e68abf170556b9d56c6f9028318e53c9f06b.tar.gz
rust-e5b3e68abf170556b9d56c6f9028318e53c9f06b.zip
Auto merge of #126245 - GuillaumeGomez:doctest-improvement-v2, r=t-rustdoc
Greatly speed up doctests by compiling compatible doctests in one file

Fixes #75341.

Take 2 at https://github.com/rust-lang/rust/pull/123974. It should now be much simpler to review since it's based on https://github.com/rust-lang/rust/pull/125798.

I split the changes as much as possible to make it as easy as possible to review (even though it's a huge lot of code changes...).

The following tests are not included into the combined doctests:
 * `compile_fail`
 * If there are crate attributes (`deny`/`allow`/`warn` are ok)
 * have invalid AST
 * `test_harness`
 * no capture
 * `--show-output` (because the output is nicer without the extra code surrounding it)

Everything else is merged into one file. If this one file fails to compile, we go back to the current strategy: compile each doctest separately.

Because of the `edition` codeblock attribute, I couldn't make them all into one file directly so I grouped them by edition, but it should be pretty anecdotic.

In case the users want a specific doctest to be opted-out from this doctest merge, I added the `standalone` codeblock attribute:

```rust
/// ```rust,standalone
/// // This doctest will be run in its own process!
/// ```
```

Now the interesting part, I ran it on a few crates and here are the results (with `cargo test --doc` to only include doctests):

| crate | nb doctests | before this PR | with this PR |
| - | - | - | - |
| sysinfo | 227 | 4.6s | 1.11s |
| geos | 157 | 3.95s | 0.45s |
| core | 4604 | 54.08s | 13.5s (merged: 0.9s, standalone: 12.6s) |
| std | 1147 | 12s | 3.56s (merged: 2.1s, standalone: 1.46s) |

r? `@camelid`

try-job: x86_64-msvc
try-job: aarch64-apple
Diffstat (limited to 'compiler/rustc_pattern_analysis/src')
0 files changed, 0 insertions, 0 deletions