Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit dcc77b4

Browse files
Fix weird memory allocation failure in merged doctests by storing doctest list into a const
1 parent b6831bb commit dcc77b4

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/librustdoc/doctest/runner.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ impl DocTestRunner {
4545
self.crate_attrs.insert(line.to_string());
4646
}
4747
}
48-
// if !self.ids.is_empty() {
49-
// self.ids.push(',');
50-
// }
48+
if !self.ids.is_empty() {
49+
self.ids.push(',');
50+
}
5151
self.ids.push_str(&format!(
52-
"tests.push({}::TEST);\n",
52+
"{}::TEST",
5353
generate_mergeable_doctest(
5454
doctest,
5555
scraped_test,
@@ -107,14 +107,14 @@ impl DocTestRunner {
107107
#[rustc_main]
108108
#[coverage(off)]
109109
fn main() {{
110-
let mut tests = Vec::new();
111-
{ids}
110+
const TESTS: [test::TestDescAndFn; {nb_tests}] = [{ids}];
112111
test::test_main(
113112
&[{test_args}],
114-
tests,
113+
Vec::from(TESTS),
115114
None,
116115
);
117116
}}",
117+
nb_tests = self.nb_tests,
118118
output = self.output,
119119
ids = self.ids,
120120
)
@@ -192,7 +192,7 @@ pub const TEST: test::TestDescAndFn = test::TestDescAndFn {{
192192
compile_fail: false,
193193
no_run: {no_run},
194194
should_panic: test::ShouldPanic::{should_panic},
195-
test_type: test::TestType::UnitTest,
195+
test_type: test::TestType::DocTest,
196196
}},
197197
testfn: test::StaticTestFn(
198198
#[coverage(off)]

0 commit comments

Comments
 (0)