-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Fix O(tests) stack usage in edition 2024 mergeable doctests #138281
Conversation
rustbot has assigned @GuillaumeGomez. Use |
This comment has been minimized.
This comment has been minimized.
90fecc7
to
76ab62e
Compare
76ab62e
to
1ccb982
Compare
Took me a while to figure out what was going on; I broke the test runner and somehow that made rustdoc fall back to not merging doctests. Should be good now, and I had to redesign the approach a bit to get it to compile 🤦 |
src/librustdoc/doctest/runner.rs
Outdated
@@ -136,19 +133,23 @@ mod __doctest_mod {{ | |||
|
|||
#[rustc_main] | |||
fn main() -> std::process::ExitCode {{ | |||
const TESTS: [test::TestDescAndFn; {nb_tests}] = [{ids}]; | |||
let tests = {{ | |||
let mut tests = Vec::new(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you at least use with_capacity
since we already have nb_tests
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah!
1ccb982
to
295c70e
Compare
Thanks! @bors r+ |
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#137931 (Add remark for missing `llvm-tools` component re. `rustc_private` linker failures related to not finding LLVM libraries) - rust-lang#138138 (Pass `InferCtxt` to `InlineAsmCtxt` to properly taint on error) - rust-lang#138223 (Fix post-merge workflow) - rust-lang#138268 (Handle empty test suites in GitHub job summary report) - rust-lang#138278 (Delegation: fix ICE with invalid `MethodCall` generation) - rust-lang#138281 (Fix O(tests) stack usage in edition 2024 mergeable doctests) - rust-lang#138305 (Subtree update of `rust-analyzer`) - rust-lang#138306 (Revert "Use workspace lints for crates in `compiler/` rust-lang#138084") r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#138281 - saethlin:mergeable-doctests-stacksize, r=GuillaumeGomez Fix O(tests) stack usage in edition 2024 mergeable doctests Fixes rust-lang#138248 The important change here is that we are not passing a potentially-large array by value. Between the fact that `TestFn` cannot be `Clone` and `test_main` takes a `Vec<TestDescAndFn>`, the only way to call `test::test_main` without O(tests) stack use is to call `Vec::push` many times. The normal test harness does not have this problem because it calls `test_main_static` or `test_main_static_abort`, which take `&[TestDescAndFn]`. Changing `test::test_main` to take a slice is not a simple change, so I'm avoiding doing it here.
Fixes #138248
The important change here is that we are not passing a potentially-large array by value. Between the fact that
TestFn
cannot beClone
andtest_main
takes aVec<TestDescAndFn>
, the only way to calltest::test_main
without O(tests) stack use is to callVec::push
many times.The normal test harness does not have this problem because it calls
test_main_static
ortest_main_static_abort
, which take&[TestDescAndFn]
. Changingtest::test_main
to take a slice is not a simple change, so I'm avoiding doing it here.