@@ -91,12 +91,12 @@ pub trait EmissionGuarantee: Sized {
91
91
/// `impl` of `EmissionGuarantee`, to make it impossible to create a value
92
92
/// of `Self::EmitResult` without actually performing the emission.
93
93
#[ track_caller]
94
- fn emit_producing_guarantee ( db : & mut DiagnosticBuilder < ' _ , Self > ) -> Self :: EmitResult ;
94
+ fn emit_producing_guarantee ( db : DiagnosticBuilder < ' _ , Self > ) -> Self :: EmitResult ;
95
95
}
96
96
97
97
impl < ' a , G : EmissionGuarantee > DiagnosticBuilder < ' a , G > {
98
98
/// Most `emit_producing_guarantee` functions use this as a starting point.
99
- fn emit_producing_nothing ( & mut self ) {
99
+ fn emit_producing_nothing ( mut self ) {
100
100
match self . state {
101
101
// First `.emit()` call, the `&DiagCtxt` is still available.
102
102
DiagnosticBuilderState :: Emittable ( dcx) => {
@@ -111,7 +111,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
111
111
112
112
// FIXME(eddyb) make `ErrorGuaranteed` impossible to create outside `.emit()`.
113
113
impl EmissionGuarantee for ErrorGuaranteed {
114
- fn emit_producing_guarantee ( db : & mut DiagnosticBuilder < ' _ , Self > ) -> Self :: EmitResult {
114
+ fn emit_producing_guarantee ( mut db : DiagnosticBuilder < ' _ , Self > ) -> Self :: EmitResult {
115
115
// Contrast this with `emit_producing_nothing`.
116
116
match db. state {
117
117
// First `.emit()` call, the `&DiagCtxt` is still available.
@@ -152,7 +152,7 @@ impl EmissionGuarantee for ErrorGuaranteed {
152
152
153
153
// FIXME(eddyb) should there be a `Option<ErrorGuaranteed>` impl as well?
154
154
impl EmissionGuarantee for ( ) {
155
- fn emit_producing_guarantee ( db : & mut DiagnosticBuilder < ' _ , Self > ) -> Self :: EmitResult {
155
+ fn emit_producing_guarantee ( db : DiagnosticBuilder < ' _ , Self > ) -> Self :: EmitResult {
156
156
db. emit_producing_nothing ( ) ;
157
157
}
158
158
}
@@ -165,7 +165,7 @@ pub struct BugAbort;
165
165
impl EmissionGuarantee for BugAbort {
166
166
type EmitResult = !;
167
167
168
- fn emit_producing_guarantee ( db : & mut DiagnosticBuilder < ' _ , Self > ) -> Self :: EmitResult {
168
+ fn emit_producing_guarantee ( db : DiagnosticBuilder < ' _ , Self > ) -> Self :: EmitResult {
169
169
db. emit_producing_nothing ( ) ;
170
170
panic:: panic_any ( ExplicitBug ) ;
171
171
}
@@ -179,14 +179,14 @@ pub struct FatalAbort;
179
179
impl EmissionGuarantee for FatalAbort {
180
180
type EmitResult = !;
181
181
182
- fn emit_producing_guarantee ( db : & mut DiagnosticBuilder < ' _ , Self > ) -> Self :: EmitResult {
182
+ fn emit_producing_guarantee ( db : DiagnosticBuilder < ' _ , Self > ) -> Self :: EmitResult {
183
183
db. emit_producing_nothing ( ) ;
184
184
crate :: FatalError . raise ( )
185
185
}
186
186
}
187
187
188
188
impl EmissionGuarantee for rustc_span:: fatal_error:: FatalError {
189
- fn emit_producing_guarantee ( db : & mut DiagnosticBuilder < ' _ , Self > ) -> Self :: EmitResult {
189
+ fn emit_producing_guarantee ( db : DiagnosticBuilder < ' _ , Self > ) -> Self :: EmitResult {
190
190
db. emit_producing_nothing ( ) ;
191
191
rustc_span:: fatal_error:: FatalError
192
192
}
@@ -269,8 +269,8 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
269
269
270
270
/// Emit and consume the diagnostic.
271
271
#[ track_caller]
272
- pub fn emit ( mut self ) -> G :: EmitResult {
273
- G :: emit_producing_guarantee ( & mut self )
272
+ pub fn emit ( self ) -> G :: EmitResult {
273
+ G :: emit_producing_guarantee ( self )
274
274
}
275
275
276
276
/// Emit the diagnostic unless `delay` is true,
0 commit comments