@@ -95,12 +95,12 @@ pub trait EmissionGuarantee: Sized {
95
95
/// `impl` of `EmissionGuarantee`, to make it impossible to create a value
96
96
/// of `Self::EmitResult` without actually performing the emission.
97
97
#[ track_caller]
98
- fn emit_producing_guarantee ( db : & mut DiagnosticBuilder < ' _ , Self > ) -> Self :: EmitResult ;
98
+ fn emit_producing_guarantee ( db : DiagnosticBuilder < ' _ , Self > ) -> Self :: EmitResult ;
99
99
}
100
100
101
101
impl < ' a , G : EmissionGuarantee > DiagnosticBuilder < ' a , G > {
102
102
/// 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 ) {
104
104
match self . state {
105
105
// First `.emit()` call, the `&DiagCtxt` is still available.
106
106
DiagnosticBuilderState :: Emittable ( dcx) => {
@@ -115,7 +115,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
115
115
116
116
// FIXME(eddyb) make `ErrorGuaranteed` impossible to create outside `.emit()`.
117
117
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 {
119
119
// Contrast this with `emit_producing_nothing`.
120
120
match db. state {
121
121
// First `.emit()` call, the `&DiagCtxt` is still available.
@@ -156,7 +156,7 @@ impl EmissionGuarantee for ErrorGuaranteed {
156
156
157
157
// FIXME(eddyb) should there be a `Option<ErrorGuaranteed>` impl as well?
158
158
impl EmissionGuarantee for ( ) {
159
- fn emit_producing_guarantee ( db : & mut DiagnosticBuilder < ' _ , Self > ) -> Self :: EmitResult {
159
+ fn emit_producing_guarantee ( db : DiagnosticBuilder < ' _ , Self > ) -> Self :: EmitResult {
160
160
db. emit_producing_nothing ( ) ;
161
161
}
162
162
}
@@ -169,7 +169,7 @@ pub struct BugAbort;
169
169
impl EmissionGuarantee for BugAbort {
170
170
type EmitResult = !;
171
171
172
- fn emit_producing_guarantee ( db : & mut DiagnosticBuilder < ' _ , Self > ) -> Self :: EmitResult {
172
+ fn emit_producing_guarantee ( db : DiagnosticBuilder < ' _ , Self > ) -> Self :: EmitResult {
173
173
db. emit_producing_nothing ( ) ;
174
174
panic:: panic_any ( ExplicitBug ) ;
175
175
}
@@ -183,14 +183,14 @@ pub struct FatalAbort;
183
183
impl EmissionGuarantee for FatalAbort {
184
184
type EmitResult = !;
185
185
186
- fn emit_producing_guarantee ( db : & mut DiagnosticBuilder < ' _ , Self > ) -> Self :: EmitResult {
186
+ fn emit_producing_guarantee ( db : DiagnosticBuilder < ' _ , Self > ) -> Self :: EmitResult {
187
187
db. emit_producing_nothing ( ) ;
188
188
crate :: FatalError . raise ( )
189
189
}
190
190
}
191
191
192
192
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 {
194
194
db. emit_producing_nothing ( ) ;
195
195
rustc_span:: fatal_error:: FatalError
196
196
}
@@ -273,8 +273,8 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
273
273
274
274
/// Emit and consume the diagnostic.
275
275
#[ 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 )
278
278
}
279
279
280
280
/// Emit the diagnostic unless `delay` is true,
0 commit comments