@@ -987,32 +987,36 @@ impl DiagCtxt {
987987// Functions beginning with `struct_`/`create_` create a diagnostic. Other
988988// functions create and emit a diagnostic all in one go.
989989impl DiagCtxt {
990- // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
990+ // No `#[rustc_lint_diagnostics]` and no `impl Into<DiagnosticMessage>` because bug messages
991+ // aren't user-facing.
991992 #[ track_caller]
992- pub fn struct_bug ( & self , msg : impl Into < DiagnosticMessage > ) -> DiagnosticBuilder < ' _ , BugAbort > {
993- DiagnosticBuilder :: new ( self , Bug , msg)
993+ pub fn struct_bug ( & self , msg : impl Into < Cow < ' static , str > > ) -> DiagnosticBuilder < ' _ , BugAbort > {
994+ DiagnosticBuilder :: new ( self , Bug , msg. into ( ) )
994995 }
995996
996- // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
997+ // No `#[rustc_lint_diagnostics]` and no `impl Into<DiagnosticMessage>` because bug messages
998+ // aren't user-facing.
997999 #[ track_caller]
998- pub fn bug ( & self , msg : impl Into < DiagnosticMessage > ) -> ! {
1000+ pub fn bug ( & self , msg : impl Into < Cow < ' static , str > > ) -> ! {
9991001 self . struct_bug ( msg) . emit ( )
10001002 }
10011003
1002- // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
1004+ // No `#[rustc_lint_diagnostics]` and no `impl Into<DiagnosticMessage>` because bug messages
1005+ // aren't user-facing.
10031006 #[ track_caller]
10041007 pub fn struct_span_bug (
10051008 & self ,
10061009 span : impl Into < MultiSpan > ,
1007- msg : impl Into < DiagnosticMessage > ,
1010+ msg : impl Into < Cow < ' static , str > > ,
10081011 ) -> DiagnosticBuilder < ' _ , BugAbort > {
10091012 self . struct_bug ( msg) . with_span ( span)
10101013 }
10111014
1012- // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
1015+ // No `#[rustc_lint_diagnostics]` and no `impl Into<DiagnosticMessage>` because bug messages
1016+ // aren't user-facing.
10131017 #[ track_caller]
1014- pub fn span_bug ( & self , span : impl Into < MultiSpan > , msg : impl Into < DiagnosticMessage > ) -> ! {
1015- self . struct_span_bug ( span, msg) . emit ( )
1018+ pub fn span_bug ( & self , span : impl Into < MultiSpan > , msg : impl Into < Cow < ' static , str > > ) -> ! {
1019+ self . struct_span_bug ( span, msg. into ( ) ) . emit ( )
10161020 }
10171021
10181022 #[ track_caller]
@@ -1132,24 +1136,28 @@ impl DiagCtxt {
11321136 }
11331137
11341138 /// Ensures that an error is printed. See `Level::DelayedBug`.
1135- // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
1139+ //
1140+ // No `#[rustc_lint_diagnostics]` and no `impl Into<DiagnosticMessage>` because bug messages
1141+ // aren't user-facing.
11361142 #[ track_caller]
1137- pub fn delayed_bug ( & self , msg : impl Into < DiagnosticMessage > ) -> ErrorGuaranteed {
1138- DiagnosticBuilder :: < ErrorGuaranteed > :: new ( self , DelayedBug , msg) . emit ( )
1143+ pub fn delayed_bug ( & self , msg : impl Into < Cow < ' static , str > > ) -> ErrorGuaranteed {
1144+ DiagnosticBuilder :: < ErrorGuaranteed > :: new ( self , DelayedBug , msg. into ( ) ) . emit ( )
11391145 }
11401146
11411147 /// Ensures that an error is printed. See `Level::DelayedBug`.
11421148 ///
11431149 /// Note: this function used to be called `delay_span_bug`. It was renamed
11441150 /// to match similar functions like `span_err`, `span_warn`, etc.
1145- // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
1151+ //
1152+ // No `#[rustc_lint_diagnostics]` and no `impl Into<DiagnosticMessage>` because bug messages
1153+ // aren't user-facing.
11461154 #[ track_caller]
11471155 pub fn span_delayed_bug (
11481156 & self ,
11491157 sp : impl Into < MultiSpan > ,
1150- msg : impl Into < DiagnosticMessage > ,
1158+ msg : impl Into < Cow < ' static , str > > ,
11511159 ) -> ErrorGuaranteed {
1152- DiagnosticBuilder :: < ErrorGuaranteed > :: new ( self , DelayedBug , msg) . with_span ( sp) . emit ( )
1160+ DiagnosticBuilder :: < ErrorGuaranteed > :: new ( self , DelayedBug , msg. into ( ) ) . with_span ( sp) . emit ( )
11531161 }
11541162
11551163 #[ rustc_lint_diagnostics]
0 commit comments