@@ -1076,32 +1076,36 @@ impl DiagCtxt {
10761076// Functions beginning with `struct_`/`create_` create a diagnostic. Other
10771077// functions create and emit a diagnostic all in one go.
10781078impl DiagCtxt {
1079- // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
1079+ // No `#[rustc_lint_diagnostics]` and no `impl Into<DiagMessage>` because bug messages aren't
1080+ // user-facing.
10801081 #[ track_caller]
1081- pub fn struct_bug ( & self , msg : impl Into < DiagMessage > ) -> Diag < ' _ , BugAbort > {
1082- Diag :: new ( self , Bug , msg)
1082+ pub fn struct_bug ( & self , msg : impl Into < Cow < ' static , str > > ) -> Diag < ' _ , BugAbort > {
1083+ Diag :: new ( self , Bug , msg. into ( ) )
10831084 }
10841085
1085- // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
1086+ // No `#[rustc_lint_diagnostics]` and no `impl Into<DiagMessage>` because bug messages aren't
1087+ // user-facing.
10861088 #[ track_caller]
1087- pub fn bug ( & self , msg : impl Into < DiagMessage > ) -> ! {
1089+ pub fn bug ( & self , msg : impl Into < Cow < ' static , str > > ) -> ! {
10881090 self . struct_bug ( msg) . emit ( )
10891091 }
10901092
1091- // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
1093+ // No `#[rustc_lint_diagnostics]` and no `impl Into<DiagMessage>` because bug messages aren't
1094+ // user-facing.
10921095 #[ track_caller]
10931096 pub fn struct_span_bug (
10941097 & self ,
10951098 span : impl Into < MultiSpan > ,
1096- msg : impl Into < DiagMessage > ,
1099+ msg : impl Into < Cow < ' static , str > > ,
10971100 ) -> Diag < ' _ , BugAbort > {
10981101 self . struct_bug ( msg) . with_span ( span)
10991102 }
11001103
1101- // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
1104+ // No `#[rustc_lint_diagnostics]` and no `impl Into<DiagMessage>` because bug messages aren't
1105+ // user-facing.
11021106 #[ track_caller]
1103- pub fn span_bug ( & self , span : impl Into < MultiSpan > , msg : impl Into < DiagMessage > ) -> ! {
1104- self . struct_span_bug ( span, msg) . emit ( )
1107+ pub fn span_bug ( & self , span : impl Into < MultiSpan > , msg : impl Into < Cow < ' static , str > > ) -> ! {
1108+ self . struct_span_bug ( span, msg. into ( ) ) . emit ( )
11051109 }
11061110
11071111 #[ track_caller]
@@ -1215,24 +1219,28 @@ impl DiagCtxt {
12151219 }
12161220
12171221 /// Ensures that an error is printed. See `Level::DelayedBug`.
1218- // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
1222+ //
1223+ // No `#[rustc_lint_diagnostics]` and no `impl Into<DiagMessage>` because bug messages aren't
1224+ // user-facing.
12191225 #[ track_caller]
1220- pub fn delayed_bug ( & self , msg : impl Into < DiagMessage > ) -> ErrorGuaranteed {
1221- Diag :: < ErrorGuaranteed > :: new ( self , DelayedBug , msg) . emit ( )
1226+ pub fn delayed_bug ( & self , msg : impl Into < Cow < ' static , str > > ) -> ErrorGuaranteed {
1227+ Diag :: < ErrorGuaranteed > :: new ( self , DelayedBug , msg. into ( ) ) . emit ( )
12221228 }
12231229
12241230 /// Ensures that an error is printed. See `Level::DelayedBug`.
12251231 ///
12261232 /// Note: this function used to be called `delay_span_bug`. It was renamed
12271233 /// to match similar functions like `span_err`, `span_warn`, etc.
1228- // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
1234+ //
1235+ // No `#[rustc_lint_diagnostics]` and no `impl Into<DiagMessage>` because bug messages aren't
1236+ // user-facing.
12291237 #[ track_caller]
12301238 pub fn span_delayed_bug (
12311239 & self ,
12321240 sp : impl Into < MultiSpan > ,
1233- msg : impl Into < DiagMessage > ,
1241+ msg : impl Into < Cow < ' static , str > > ,
12341242 ) -> ErrorGuaranteed {
1235- Diag :: < ErrorGuaranteed > :: new ( self , DelayedBug , msg) . with_span ( sp) . emit ( )
1243+ Diag :: < ErrorGuaranteed > :: new ( self , DelayedBug , msg. into ( ) ) . with_span ( sp) . emit ( )
12361244 }
12371245
12381246 #[ rustc_lint_diagnostics]
0 commit comments