[red-knot] Don't panic when primary-span is missing while panicking (#17799)

This commit is contained in:
Micha Reiser 2025-05-02 22:19:03 +02:00 committed by GitHub
parent 675a5af89a
commit f7cae4ffb5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -468,6 +468,11 @@ impl Drop for DiagnosticGuard<'_, '_> {
// once.
let diag = self.diag.take().unwrap();
if std::thread::panicking() {
// Don't submit diagnostics when panicking because they might be incomplete.
return;
}
let Some(ann) = diag.primary_annotation() else {
panic!(
"All diagnostics reported by `InferContext` must have a \