Take &mut Diagnostic in emit_diagnostic.
Taking a Diagnostic by move would break the usual pattern `diag.label(..).emit()`.
This commit is contained in:
parent
4767ccec93
commit
056951d628
13 changed files with 43 additions and 41 deletions
|
@ -128,7 +128,7 @@ impl EmissionGuarantee for ErrorGuaranteed {
|
|||
DiagnosticBuilderState::Emittable(handler) => {
|
||||
db.inner.state = DiagnosticBuilderState::AlreadyEmittedOrDuringCancellation;
|
||||
|
||||
let guar = handler.emit_diagnostic(&db.inner.diagnostic);
|
||||
let guar = handler.emit_diagnostic(&mut 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`
|
||||
|
@ -190,7 +190,7 @@ impl EmissionGuarantee for () {
|
|||
DiagnosticBuilderState::Emittable(handler) => {
|
||||
db.inner.state = DiagnosticBuilderState::AlreadyEmittedOrDuringCancellation;
|
||||
|
||||
handler.emit_diagnostic(&db.inner.diagnostic);
|
||||
handler.emit_diagnostic(&mut db.inner.diagnostic);
|
||||
}
|
||||
// `.emit()` was previously called, disallowed from repeating it.
|
||||
DiagnosticBuilderState::AlreadyEmittedOrDuringCancellation => {}
|
||||
|
@ -500,11 +500,11 @@ impl Drop for DiagnosticBuilderInner<'_> {
|
|||
// No `.emit()` or `.cancel()` calls.
|
||||
DiagnosticBuilderState::Emittable(handler) => {
|
||||
if !panicking() {
|
||||
handler.emit_diagnostic(&Diagnostic::new(
|
||||
handler.emit_diagnostic(&mut Diagnostic::new(
|
||||
Level::Bug,
|
||||
"the following error was constructed but not emitted",
|
||||
));
|
||||
handler.emit_diagnostic(&self.diagnostic);
|
||||
handler.emit_diagnostic(&mut self.diagnostic);
|
||||
panic!();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue