@@ -116,26 +116,6 @@ pub trait EmissionGuarantee: Sized {
116
116
}
117
117
118
118
impl < ' a > DiagnosticBuilder < ' a , ErrorGuaranteed > {
119
- /// Convenience function for internal use, clients should use one of the
120
- /// `struct_*` methods on [`Handler`].
121
- #[ track_caller]
122
- pub ( crate ) fn new_guaranteeing_error < M : Into < DiagnosticMessage > > (
123
- handler : & ' a Handler ,
124
- message : M ,
125
- ) -> Self {
126
- Self {
127
- inner : DiagnosticBuilderInner {
128
- state : DiagnosticBuilderState :: Emittable ( handler) ,
129
- diagnostic : Box :: new ( Diagnostic :: new_with_code (
130
- Level :: Error { lint : false } ,
131
- None ,
132
- message,
133
- ) ) ,
134
- } ,
135
- _marker : PhantomData ,
136
- }
137
- }
138
-
139
119
/// Discard the guarantee `.emit()` would return, in favor of having the
140
120
/// type `DiagnosticBuilder<'a, ()>`. This may be necessary whenever there
141
121
/// is a common codepath handling both errors and warnings.
@@ -189,7 +169,13 @@ impl EmissionGuarantee for ErrorGuaranteed {
189
169
handler : & Handler ,
190
170
msg : impl Into < DiagnosticMessage > ,
191
171
) -> DiagnosticBuilder < ' _ , Self > {
192
- DiagnosticBuilder :: new_guaranteeing_error ( handler, msg)
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
+ }
193
179
}
194
180
}
195
181
@@ -249,21 +235,6 @@ impl EmissionGuarantee for () {
249
235
#[ derive( Copy , Clone ) ]
250
236
pub struct Noted ;
251
237
252
- impl < ' a > DiagnosticBuilder < ' a , Noted > {
253
- /// Convenience function for internal use, clients should use one of the
254
- /// `struct_*` methods on [`Handler`].
255
- pub ( crate ) fn new_note ( handler : & ' a Handler , message : impl Into < DiagnosticMessage > ) -> Self {
256
- let diagnostic = Diagnostic :: new_with_code ( Level :: Note , None , message) ;
257
- Self {
258
- inner : DiagnosticBuilderInner {
259
- state : DiagnosticBuilderState :: Emittable ( handler) ,
260
- diagnostic : Box :: new ( diagnostic) ,
261
- } ,
262
- _marker : PhantomData ,
263
- }
264
- }
265
- }
266
-
267
238
impl EmissionGuarantee for Noted {
268
239
fn diagnostic_builder_emit_producing_guarantee ( db : & mut DiagnosticBuilder < ' _ , Self > ) -> Self {
269
240
match db. inner . state {
@@ -283,31 +254,21 @@ impl EmissionGuarantee for Noted {
283
254
handler : & Handler ,
284
255
msg : impl Into < DiagnosticMessage > ,
285
256
) -> DiagnosticBuilder < ' _ , Self > {
286
- DiagnosticBuilder :: new_note ( handler, msg)
287
- }
288
- }
289
-
290
- /// Marker type which enables implementation of `create_bug` and `emit_bug` functions for
291
- /// bug struct diagnostics.
292
- #[ derive( Copy , Clone ) ]
293
- pub struct Bug ;
294
-
295
- impl < ' a > DiagnosticBuilder < ' a , Bug > {
296
- /// Convenience function for internal use, clients should use one of the
297
- /// `struct_*` methods on [`Handler`].
298
- #[ track_caller]
299
- pub ( crate ) fn new_bug ( handler : & ' a Handler , message : impl Into < DiagnosticMessage > ) -> Self {
300
- let diagnostic = Diagnostic :: new_with_code ( Level :: Bug , None , message) ;
301
- Self {
257
+ DiagnosticBuilder {
302
258
inner : DiagnosticBuilderInner {
303
259
state : DiagnosticBuilderState :: Emittable ( handler) ,
304
- diagnostic : Box :: new ( diagnostic ) ,
260
+ diagnostic : Box :: new ( Diagnostic :: new_with_code ( Level :: Note , None , msg ) ) ,
305
261
} ,
306
262
_marker : PhantomData ,
307
263
}
308
264
}
309
265
}
310
266
267
+ /// Marker type which enables implementation of `create_bug` and `emit_bug` functions for
268
+ /// bug struct diagnostics.
269
+ #[ derive( Copy , Clone ) ]
270
+ pub struct Bug ;
271
+
311
272
impl EmissionGuarantee for Bug {
312
273
fn diagnostic_builder_emit_producing_guarantee ( db : & mut DiagnosticBuilder < ' _ , Self > ) -> Self {
313
274
match db. inner . state {
@@ -328,19 +289,10 @@ impl EmissionGuarantee for Bug {
328
289
handler : & Handler ,
329
290
msg : impl Into < DiagnosticMessage > ,
330
291
) -> DiagnosticBuilder < ' _ , Self > {
331
- DiagnosticBuilder :: new_bug ( handler, msg)
332
- }
333
- }
334
-
335
- impl < ' a > DiagnosticBuilder < ' a , !> {
336
- /// Convenience function for internal use, clients should use one of the
337
- /// `struct_*` methods on [`Handler`].
338
- #[ track_caller]
339
- pub ( crate ) fn new_fatal ( handler : & ' a Handler , message : impl Into < DiagnosticMessage > ) -> Self {
340
- Self {
292
+ DiagnosticBuilder {
341
293
inner : DiagnosticBuilderInner {
342
294
state : DiagnosticBuilderState :: Emittable ( handler) ,
343
- diagnostic : Box :: new ( Diagnostic :: new_with_code ( Level :: Fatal , None , message ) ) ,
295
+ diagnostic : Box :: new ( Diagnostic :: new_with_code ( Level :: Bug , None , msg ) ) ,
344
296
} ,
345
297
_marker : PhantomData ,
346
298
}
@@ -367,23 +319,10 @@ impl EmissionGuarantee for ! {
367
319
handler : & Handler ,
368
320
msg : impl Into < DiagnosticMessage > ,
369
321
) -> DiagnosticBuilder < ' _ , Self > {
370
- DiagnosticBuilder :: new_fatal ( handler, msg)
371
- }
372
- }
373
-
374
- impl < ' a > DiagnosticBuilder < ' a , rustc_span:: fatal_error:: FatalError > {
375
- /// Convenience function for internal use, clients should use one of the
376
- /// `struct_*` methods on [`Handler`].
377
- #[ track_caller]
378
- pub ( crate ) fn new_almost_fatal (
379
- handler : & ' a Handler ,
380
- message : impl Into < DiagnosticMessage > ,
381
- ) -> Self {
382
- let diagnostic = Diagnostic :: new_with_code ( Level :: Fatal , None , message) ;
383
- Self {
322
+ DiagnosticBuilder {
384
323
inner : DiagnosticBuilderInner {
385
324
state : DiagnosticBuilderState :: Emittable ( handler) ,
386
- diagnostic : Box :: new ( diagnostic ) ,
325
+ diagnostic : Box :: new ( Diagnostic :: new_with_code ( Level :: Fatal , None , msg ) ) ,
387
326
} ,
388
327
_marker : PhantomData ,
389
328
}
@@ -410,7 +349,13 @@ impl EmissionGuarantee for rustc_span::fatal_error::FatalError {
410
349
handler : & Handler ,
411
350
msg : impl Into < DiagnosticMessage > ,
412
351
) -> DiagnosticBuilder < ' _ , Self > {
413
- DiagnosticBuilder :: new_almost_fatal ( handler, msg)
352
+ DiagnosticBuilder {
353
+ inner : DiagnosticBuilderInner {
354
+ state : DiagnosticBuilderState :: Emittable ( handler) ,
355
+ diagnostic : Box :: new ( Diagnostic :: new_with_code ( Level :: Fatal , None , msg) ) ,
356
+ } ,
357
+ _marker : PhantomData ,
358
+ }
414
359
}
415
360
}
416
361
0 commit comments