Skip to content

Commit b37c73d

Browse files
committed
Make emit_producing_{guarantee,nothing} consuming.
1 parent 71a73bd commit b37c73d

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

compiler/rustc_errors/src/diagnostic_builder.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,12 @@ pub trait EmissionGuarantee: Sized {
9595
/// `impl` of `EmissionGuarantee`, to make it impossible to create a value
9696
/// of `Self::EmitResult` without actually performing the emission.
9797
#[track_caller]
98-
fn emit_producing_guarantee(db: &mut DiagnosticBuilder<'_, Self>) -> Self::EmitResult;
98+
fn emit_producing_guarantee(db: DiagnosticBuilder<'_, Self>) -> Self::EmitResult;
9999
}
100100

101101
impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
102102
/// Most `emit_producing_guarantee` functions use this as a starting point.
103-
fn emit_producing_nothing(&mut self) {
103+
fn emit_producing_nothing(mut self) {
104104
match self.state {
105105
// First `.emit()` call, the `&DiagCtxt` is still available.
106106
DiagnosticBuilderState::Emittable(dcx) => {
@@ -115,7 +115,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
115115

116116
// FIXME(eddyb) make `ErrorGuaranteed` impossible to create outside `.emit()`.
117117
impl EmissionGuarantee for ErrorGuaranteed {
118-
fn emit_producing_guarantee(db: &mut DiagnosticBuilder<'_, Self>) -> Self::EmitResult {
118+
fn emit_producing_guarantee(mut db: DiagnosticBuilder<'_, Self>) -> Self::EmitResult {
119119
// Contrast this with `emit_producing_nothing`.
120120
match db.state {
121121
// First `.emit()` call, the `&DiagCtxt` is still available.
@@ -156,7 +156,7 @@ impl EmissionGuarantee for ErrorGuaranteed {
156156

157157
// FIXME(eddyb) should there be a `Option<ErrorGuaranteed>` impl as well?
158158
impl EmissionGuarantee for () {
159-
fn emit_producing_guarantee(db: &mut DiagnosticBuilder<'_, Self>) -> Self::EmitResult {
159+
fn emit_producing_guarantee(db: DiagnosticBuilder<'_, Self>) -> Self::EmitResult {
160160
db.emit_producing_nothing();
161161
}
162162
}
@@ -169,7 +169,7 @@ pub struct BugAbort;
169169
impl EmissionGuarantee for BugAbort {
170170
type EmitResult = !;
171171

172-
fn emit_producing_guarantee(db: &mut DiagnosticBuilder<'_, Self>) -> Self::EmitResult {
172+
fn emit_producing_guarantee(db: DiagnosticBuilder<'_, Self>) -> Self::EmitResult {
173173
db.emit_producing_nothing();
174174
panic::panic_any(ExplicitBug);
175175
}
@@ -183,14 +183,14 @@ pub struct FatalAbort;
183183
impl EmissionGuarantee for FatalAbort {
184184
type EmitResult = !;
185185

186-
fn emit_producing_guarantee(db: &mut DiagnosticBuilder<'_, Self>) -> Self::EmitResult {
186+
fn emit_producing_guarantee(db: DiagnosticBuilder<'_, Self>) -> Self::EmitResult {
187187
db.emit_producing_nothing();
188188
crate::FatalError.raise()
189189
}
190190
}
191191

192192
impl EmissionGuarantee for rustc_span::fatal_error::FatalError {
193-
fn emit_producing_guarantee(db: &mut DiagnosticBuilder<'_, Self>) -> Self::EmitResult {
193+
fn emit_producing_guarantee(db: DiagnosticBuilder<'_, Self>) -> Self::EmitResult {
194194
db.emit_producing_nothing();
195195
rustc_span::fatal_error::FatalError
196196
}
@@ -273,8 +273,8 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
273273

274274
/// Emit and consume the diagnostic.
275275
#[track_caller]
276-
pub fn emit(mut self) -> G::EmitResult {
277-
G::emit_producing_guarantee(&mut self)
276+
pub fn emit(self) -> G::EmitResult {
277+
G::emit_producing_guarantee(self)
278278
}
279279

280280
/// Emit the diagnostic unless `delay` is true,

0 commit comments

Comments
 (0)