1
Fork 0

rustc_error: make ErrorReported impossible to construct

There are a few places were we have to construct it, though, and a few
places that are more invasive to change. To do this, we create a
constructor with a long obvious name.
This commit is contained in:
mark 2022-01-22 18:49:12 -06:00
parent 461e807801
commit bb8d4307eb
104 changed files with 705 additions and 550 deletions

View file

@ -128,7 +128,7 @@ impl EmissionGuarantee for ErrorGuaranteed {
DiagnosticBuilderState::Emittable(handler) => {
db.inner.state = DiagnosticBuilderState::AlreadyEmittedOrDuringCancellation;
handler.emit_diagnostic(&db.inner.diagnostic);
let guar = handler.emit_diagnostic(&db.inner.diagnostic);
// Only allow a guarantee if the `level` wasn't switched to a
// non-error - the field isn't `pub`, but the whole `Diagnostic`
@ -139,7 +139,7 @@ impl EmissionGuarantee for ErrorGuaranteed {
from `DiagnosticBuilder<ErrorGuaranteed>`",
db.inner.diagnostic.level,
);
ErrorGuaranteed
guar.unwrap()
}
// `.emit()` was previously called, disallowed from repeating it,
// but can take advantage of the previous `.emit()`'s guarantee
@ -154,7 +154,7 @@ impl EmissionGuarantee for ErrorGuaranteed {
became non-error ({:?}), after original `.emit()`",
db.inner.diagnostic.level,
);
ErrorGuaranteed
ErrorGuaranteed::unchecked_claim_error_was_emitted()
}
}
}