Skip to content

Commit

Permalink
doctest: Reset errors before dropping the parse session
Browse files Browse the repository at this point in the history
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 #80992
  • Loading branch information
osa1 committed Jan 16, 2021
1 parent 6c869d3 commit eef383f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/librustdoc/doctest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,12 @@ crate fn make_test(
}
}

// Reset errors so that they won't be reported as compiler bugs when dropping the
// handler. Any errors in the tests will be reported when the test file is compiled,
// Note that we still need to cancel the errors above otherwise `DiagnosticBuilder`
// will panic on drop.
sess.span_diagnostic.reset_err_count();

(found_main, found_extern_crate, found_macro)
})
});
Expand Down

0 comments on commit eef383f

Please sign in to comment.