Skip to content

Commit eef383f

Browse files
committed
doctest: Reset errors before dropping the parse session
The first parse is to collect whether the code contains macros, has `main`, and uses other crates. In that pass we ignore errors as those will be reported when the test file is actually built. For that we need to reset errors in the `Diagnostic` otherwise when dropping it unhandled errors will be reported as compiler bugs. Fixes rust-lang#80992
1 parent 6c869d3 commit eef383f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Diff for: src/librustdoc/doctest.rs

+6
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,12 @@ crate fn make_test(
500500
}
501501
}
502502

503+
// Reset errors so that they won't be reported as compiler bugs when dropping the
504+
// handler. Any errors in the tests will be reported when the test file is compiled,
505+
// Note that we still need to cancel the errors above otherwise `DiagnosticBuilder`
506+
// will panic on drop.
507+
sess.span_diagnostic.reset_err_count();
508+
503509
(found_main, found_extern_crate, found_macro)
504510
})
505511
});

0 commit comments

Comments
 (0)