@@ -169,41 +169,7 @@ impl EmissionGuarantee for ErrorGuaranteed {
169
169
handler : & Handler ,
170
170
msg : impl Into < DiagnosticMessage > ,
171
171
) -> DiagnosticBuilder < ' _ , Self > {
172
- DiagnosticBuilder {
173
- inner : DiagnosticBuilderInner {
174
- state : DiagnosticBuilderState :: Emittable ( handler) ,
175
- diagnostic : Box :: new ( Diagnostic :: new ( Level :: Error { lint : false } , msg) ) ,
176
- } ,
177
- _marker : PhantomData ,
178
- }
179
- }
180
- }
181
-
182
- impl < ' a > DiagnosticBuilder < ' a , ( ) > {
183
- /// Convenience function for internal use, clients should use one of the
184
- /// `struct_*` methods on [`Handler`].
185
- #[ track_caller]
186
- pub ( crate ) fn new < M : Into < DiagnosticMessage > > (
187
- handler : & ' a Handler ,
188
- level : Level ,
189
- message : M ,
190
- ) -> Self {
191
- let diagnostic = Diagnostic :: new ( level, message) ;
192
- Self :: new_diagnostic ( handler, diagnostic)
193
- }
194
-
195
- /// Creates a new `DiagnosticBuilder` with an already constructed
196
- /// diagnostic.
197
- #[ track_caller]
198
- pub ( crate ) fn new_diagnostic ( handler : & ' a Handler , diagnostic : Diagnostic ) -> Self {
199
- debug ! ( "Created new diagnostic" ) ;
200
- Self {
201
- inner : DiagnosticBuilderInner {
202
- state : DiagnosticBuilderState :: Emittable ( handler) ,
203
- diagnostic : Box :: new ( diagnostic) ,
204
- } ,
205
- _marker : PhantomData ,
206
- }
172
+ DiagnosticBuilder :: new ( handler, Level :: Error { lint : false } , msg)
207
173
}
208
174
}
209
175
@@ -254,13 +220,7 @@ impl EmissionGuarantee for Noted {
254
220
handler : & Handler ,
255
221
msg : impl Into < DiagnosticMessage > ,
256
222
) -> DiagnosticBuilder < ' _ , Self > {
257
- DiagnosticBuilder {
258
- inner : DiagnosticBuilderInner {
259
- state : DiagnosticBuilderState :: Emittable ( handler) ,
260
- diagnostic : Box :: new ( Diagnostic :: new ( Level :: Note , msg) ) ,
261
- } ,
262
- _marker : PhantomData ,
263
- }
223
+ DiagnosticBuilder :: new ( handler, Level :: Note , msg)
264
224
}
265
225
}
266
226
@@ -289,13 +249,7 @@ impl EmissionGuarantee for Bug {
289
249
handler : & Handler ,
290
250
msg : impl Into < DiagnosticMessage > ,
291
251
) -> DiagnosticBuilder < ' _ , Self > {
292
- DiagnosticBuilder {
293
- inner : DiagnosticBuilderInner {
294
- state : DiagnosticBuilderState :: Emittable ( handler) ,
295
- diagnostic : Box :: new ( Diagnostic :: new ( Level :: Bug , msg) ) ,
296
- } ,
297
- _marker : PhantomData ,
298
- }
252
+ DiagnosticBuilder :: new ( handler, Level :: Bug , msg)
299
253
}
300
254
}
301
255
@@ -319,13 +273,7 @@ impl EmissionGuarantee for ! {
319
273
handler : & Handler ,
320
274
msg : impl Into < DiagnosticMessage > ,
321
275
) -> DiagnosticBuilder < ' _ , Self > {
322
- DiagnosticBuilder {
323
- inner : DiagnosticBuilderInner {
324
- state : DiagnosticBuilderState :: Emittable ( handler) ,
325
- diagnostic : Box :: new ( Diagnostic :: new ( Level :: Fatal , msg) ) ,
326
- } ,
327
- _marker : PhantomData ,
328
- }
276
+ DiagnosticBuilder :: new ( handler, Level :: Fatal , msg)
329
277
}
330
278
}
331
279
@@ -349,13 +297,7 @@ impl EmissionGuarantee for rustc_span::fatal_error::FatalError {
349
297
handler : & Handler ,
350
298
msg : impl Into < DiagnosticMessage > ,
351
299
) -> DiagnosticBuilder < ' _ , Self > {
352
- DiagnosticBuilder {
353
- inner : DiagnosticBuilderInner {
354
- state : DiagnosticBuilderState :: Emittable ( handler) ,
355
- diagnostic : Box :: new ( Diagnostic :: new ( Level :: Fatal , msg) ) ,
356
- } ,
357
- _marker : PhantomData ,
358
- }
300
+ DiagnosticBuilder :: new ( handler, Level :: Fatal , msg)
359
301
}
360
302
}
361
303
@@ -397,6 +339,32 @@ impl<G: EmissionGuarantee> DerefMut for DiagnosticBuilder<'_, G> {
397
339
}
398
340
399
341
impl < ' a , G : EmissionGuarantee > DiagnosticBuilder < ' a , G > {
342
+ /// Convenience function for internal use, clients should use one of the
343
+ /// `struct_*` methods on [`Handler`].
344
+ #[ track_caller]
345
+ pub ( crate ) fn new < M : Into < DiagnosticMessage > > (
346
+ handler : & ' a Handler ,
347
+ level : Level ,
348
+ message : M ,
349
+ ) -> Self {
350
+ let diagnostic = Diagnostic :: new ( level, message) ;
351
+ Self :: new_diagnostic ( handler, diagnostic)
352
+ }
353
+
354
+ /// Creates a new `DiagnosticBuilder` with an already constructed
355
+ /// diagnostic.
356
+ #[ track_caller]
357
+ pub ( crate ) fn new_diagnostic ( handler : & ' a Handler , diagnostic : Diagnostic ) -> Self {
358
+ debug ! ( "Created new diagnostic" ) ;
359
+ Self {
360
+ inner : DiagnosticBuilderInner {
361
+ state : DiagnosticBuilderState :: Emittable ( handler) ,
362
+ diagnostic : Box :: new ( diagnostic) ,
363
+ } ,
364
+ _marker : PhantomData ,
365
+ }
366
+ }
367
+
400
368
/// Emit the diagnostic.
401
369
#[ track_caller]
402
370
pub fn emit ( & mut self ) -> G {
0 commit comments