@@ -997,32 +997,36 @@ impl DiagCtxt {
997997// Functions beginning with `struct_`/`create_` create a diagnostic. Other
998998// functions create and emit a diagnostic all in one go.
999999impl DiagCtxt {
1000- // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
1000+ // No `#[rustc_lint_diagnostics]` and no `impl Into<DiagnosticMessage>` because bug messages
1001+ // aren't user-facing.
10011002 #[ track_caller]
1002- pub fn struct_bug ( & self , msg : impl Into < DiagnosticMessage > ) -> Diag < ' _ , BugAbort > {
1003- Diag :: new ( self , Bug , msg)
1003+ pub fn struct_bug ( & self , msg : impl Into < Cow < ' static , str > > ) -> Diag < ' _ , BugAbort > {
1004+ Diag :: new ( self , Bug , msg. into ( ) )
10041005 }
10051006
1006- // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
1007+ // No `#[rustc_lint_diagnostics]` and no `impl Into<DiagnosticMessage>` because bug messages
1008+ // aren't user-facing.
10071009 #[ track_caller]
1008- pub fn bug ( & self , msg : impl Into < DiagnosticMessage > ) -> ! {
1010+ pub fn bug ( & self , msg : impl Into < Cow < ' static , str > > ) -> ! {
10091011 self . struct_bug ( msg) . emit ( )
10101012 }
10111013
1012- // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
1014+ // No `#[rustc_lint_diagnostics]` and no `impl Into<DiagnosticMessage>` because bug messages
1015+ // aren't user-facing.
10131016 #[ track_caller]
10141017 pub fn struct_span_bug (
10151018 & self ,
10161019 span : impl Into < MultiSpan > ,
1017- msg : impl Into < DiagnosticMessage > ,
1020+ msg : impl Into < Cow < ' static , str > > ,
10181021 ) -> Diag < ' _ , BugAbort > {
10191022 self . struct_bug ( msg) . with_span ( span)
10201023 }
10211024
1022- // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
1025+ // No `#[rustc_lint_diagnostics]` and no `impl Into<DiagnosticMessage>` because bug messages
1026+ // aren't user-facing.
10231027 #[ track_caller]
1024- pub fn span_bug ( & self , span : impl Into < MultiSpan > , msg : impl Into < DiagnosticMessage > ) -> ! {
1025- self . struct_span_bug ( span, msg) . emit ( )
1028+ pub fn span_bug ( & self , span : impl Into < MultiSpan > , msg : impl Into < Cow < ' static , str > > ) -> ! {
1029+ self . struct_span_bug ( span, msg. into ( ) ) . emit ( )
10261030 }
10271031
10281032 #[ track_caller]
@@ -1136,24 +1140,28 @@ impl DiagCtxt {
11361140 }
11371141
11381142 /// Ensures that an error is printed. See `Level::DelayedBug`.
1139- // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
1143+ //
1144+ // No `#[rustc_lint_diagnostics]` and no `impl Into<DiagnosticMessage>` because bug messages
1145+ // aren't user-facing.
11401146 #[ track_caller]
1141- pub fn delayed_bug ( & self , msg : impl Into < DiagnosticMessage > ) -> ErrorGuaranteed {
1142- Diag :: < ErrorGuaranteed > :: new ( self , DelayedBug , msg) . emit ( )
1147+ pub fn delayed_bug ( & self , msg : impl Into < Cow < ' static , str > > ) -> ErrorGuaranteed {
1148+ Diag :: < ErrorGuaranteed > :: new ( self , DelayedBug , msg. into ( ) ) . emit ( )
11431149 }
11441150
11451151 /// Ensures that an error is printed. See `Level::DelayedBug`.
11461152 ///
11471153 /// Note: this function used to be called `delay_span_bug`. It was renamed
11481154 /// to match similar functions like `span_err`, `span_warn`, etc.
1149- // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
1155+ //
1156+ // No `#[rustc_lint_diagnostics]` and no `impl Into<DiagnosticMessage>` because bug messages
1157+ // aren't user-facing.
11501158 #[ track_caller]
11511159 pub fn span_delayed_bug (
11521160 & self ,
11531161 sp : impl Into < MultiSpan > ,
1154- msg : impl Into < DiagnosticMessage > ,
1162+ msg : impl Into < Cow < ' static , str > > ,
11551163 ) -> ErrorGuaranteed {
1156- Diag :: < ErrorGuaranteed > :: new ( self , DelayedBug , msg) . with_span ( sp) . emit ( )
1164+ Diag :: < ErrorGuaranteed > :: new ( self , DelayedBug , msg. into ( ) ) . with_span ( sp) . emit ( )
11571165 }
11581166
11591167 #[ rustc_lint_diagnostics]
0 commit comments