@@ -116,26 +116,6 @@ pub trait EmissionGuarantee: Sized {
116116}
117117
118118impl < ' 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-
139119 /// Discard the guarantee `.emit()` would return, in favor of having the
140120 /// type `DiagnosticBuilder<'a, ()>`. This may be necessary whenever there
141121 /// is a common codepath handling both errors and warnings.
@@ -189,7 +169,13 @@ impl EmissionGuarantee for ErrorGuaranteed {
189169 handler : & Handler ,
190170 msg : impl Into < DiagnosticMessage > ,
191171 ) -> 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+ }
193179 }
194180}
195181
@@ -249,21 +235,6 @@ impl EmissionGuarantee for () {
249235#[ derive( Copy , Clone ) ]
250236pub struct Noted ;
251237
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-
267238impl EmissionGuarantee for Noted {
268239 fn diagnostic_builder_emit_producing_guarantee ( db : & mut DiagnosticBuilder < ' _ , Self > ) -> Self {
269240 match db. inner . state {
@@ -283,31 +254,21 @@ impl EmissionGuarantee for Noted {
283254 handler : & Handler ,
284255 msg : impl Into < DiagnosticMessage > ,
285256 ) -> 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 {
302258 inner : DiagnosticBuilderInner {
303259 state : DiagnosticBuilderState :: Emittable ( handler) ,
304- diagnostic : Box :: new ( diagnostic ) ,
260+ diagnostic : Box :: new ( Diagnostic :: new_with_code ( Level :: Note , None , msg ) ) ,
305261 } ,
306262 _marker : PhantomData ,
307263 }
308264 }
309265}
310266
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+
311272impl EmissionGuarantee for Bug {
312273 fn diagnostic_builder_emit_producing_guarantee ( db : & mut DiagnosticBuilder < ' _ , Self > ) -> Self {
313274 match db. inner . state {
@@ -328,19 +289,10 @@ impl EmissionGuarantee for Bug {
328289 handler : & Handler ,
329290 msg : impl Into < DiagnosticMessage > ,
330291 ) -> 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 {
341293 inner : DiagnosticBuilderInner {
342294 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 ) ) ,
344296 } ,
345297 _marker : PhantomData ,
346298 }
@@ -367,23 +319,10 @@ impl EmissionGuarantee for ! {
367319 handler : & Handler ,
368320 msg : impl Into < DiagnosticMessage > ,
369321 ) -> 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 {
384323 inner : DiagnosticBuilderInner {
385324 state : DiagnosticBuilderState :: Emittable ( handler) ,
386- diagnostic : Box :: new ( diagnostic ) ,
325+ diagnostic : Box :: new ( Diagnostic :: new_with_code ( Level :: Fatal , None , msg ) ) ,
387326 } ,
388327 _marker : PhantomData ,
389328 }
@@ -410,7 +349,13 @@ impl EmissionGuarantee for rustc_span::fatal_error::FatalError {
410349 handler : & Handler ,
411350 msg : impl Into < DiagnosticMessage > ,
412351 ) -> 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+ }
414359 }
415360}
416361
0 commit comments