@@ -84,6 +84,13 @@ pub trait EmissionGuarantee: Sized {
8484 /// of `Self` without actually performing the emission.
8585 #[ track_caller]
8686 fn diagnostic_builder_emit_producing_guarantee ( db : & mut DiagnosticBuilder < ' _ , Self > ) -> Self ;
87+
88+ /// Creates a new `DiagnosticBuilder` that will return this type of guarantee.
89+ #[ track_caller]
90+ fn make_diagnostic_builder (
91+ handler : & Handler ,
92+ msg : impl Into < DiagnosticMessage > ,
93+ ) -> DiagnosticBuilder < ' _ , Self > ;
8794}
8895
8996/// Private module for sealing the `IsError` helper trait.
@@ -166,6 +173,15 @@ impl EmissionGuarantee for ErrorGuaranteed {
166173 }
167174 }
168175 }
176+
177+ fn make_diagnostic_builder (
178+ handler : & Handler ,
179+ msg : impl Into < DiagnosticMessage > ,
180+ ) -> DiagnosticBuilder < ' _ , Self > {
181+ DiagnosticBuilder :: new_guaranteeing_error :: < _ , { Level :: Error { lint : false } } > (
182+ handler, msg,
183+ )
184+ }
169185}
170186
171187impl < ' a > DiagnosticBuilder < ' a , ( ) > {
@@ -208,6 +224,13 @@ impl EmissionGuarantee for () {
208224 DiagnosticBuilderState :: AlreadyEmittedOrDuringCancellation => { }
209225 }
210226 }
227+
228+ fn make_diagnostic_builder (
229+ handler : & Handler ,
230+ msg : impl Into < DiagnosticMessage > ,
231+ ) -> DiagnosticBuilder < ' _ , Self > {
232+ DiagnosticBuilder :: new ( handler, Level :: Warning ( None ) , msg)
233+ }
211234}
212235
213236impl < ' a > DiagnosticBuilder < ' a , !> {
@@ -247,6 +270,13 @@ impl EmissionGuarantee for ! {
247270 // Then fatally error, returning `!`
248271 crate :: FatalError . raise ( )
249272 }
273+
274+ fn make_diagnostic_builder (
275+ handler : & Handler ,
276+ msg : impl Into < DiagnosticMessage > ,
277+ ) -> DiagnosticBuilder < ' _ , Self > {
278+ DiagnosticBuilder :: new_fatal ( handler, msg)
279+ }
250280}
251281
252282/// In general, the `DiagnosticBuilder` uses deref to allow access to
0 commit comments