@@ -169,41 +169,7 @@ impl EmissionGuarantee for ErrorGuaranteed {
169169 handler : & Handler ,
170170 msg : impl Into < DiagnosticMessage > ,
171171 ) -> 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)
207173 }
208174}
209175
@@ -254,13 +220,7 @@ impl EmissionGuarantee for Noted {
254220 handler : & Handler ,
255221 msg : impl Into < DiagnosticMessage > ,
256222 ) -> 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)
264224 }
265225}
266226
@@ -289,13 +249,7 @@ impl EmissionGuarantee for Bug {
289249 handler : & Handler ,
290250 msg : impl Into < DiagnosticMessage > ,
291251 ) -> 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)
299253 }
300254}
301255
@@ -319,13 +273,7 @@ impl EmissionGuarantee for ! {
319273 handler : & Handler ,
320274 msg : impl Into < DiagnosticMessage > ,
321275 ) -> 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)
329277 }
330278}
331279
@@ -349,13 +297,7 @@ impl EmissionGuarantee for rustc_span::fatal_error::FatalError {
349297 handler : & Handler ,
350298 msg : impl Into < DiagnosticMessage > ,
351299 ) -> 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)
359301 }
360302}
361303
@@ -397,6 +339,32 @@ impl<G: EmissionGuarantee> DerefMut for DiagnosticBuilder<'_, G> {
397339}
398340
399341impl < ' 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+
400368 /// Emit the diagnostic.
401369 #[ track_caller]
402370 pub fn emit ( & mut self ) -> G {
0 commit comments