@@ -998,32 +998,36 @@ impl DiagCtxt {
998
998
// Functions beginning with `struct_`/`create_` create a diagnostic. Other
999
999
// functions create and emit a diagnostic all in one go.
1000
1000
impl DiagCtxt {
1001
- // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
1001
+ // No `#[rustc_lint_diagnostics]` and no `impl Into<DiagnosticMessage>` because bug messages
1002
+ // aren't user-facing.
1002
1003
#[ track_caller]
1003
- pub fn struct_bug ( & self , msg : impl Into < DiagnosticMessage > ) -> DiagnosticBuilder < ' _ , BugAbort > {
1004
- DiagnosticBuilder :: new ( self , Bug , msg)
1004
+ pub fn struct_bug ( & self , msg : impl Into < Cow < ' static , str > > ) -> DiagnosticBuilder < ' _ , BugAbort > {
1005
+ DiagnosticBuilder :: new ( self , Bug , msg. into ( ) )
1005
1006
}
1006
1007
1007
- // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
1008
+ // No `#[rustc_lint_diagnostics]` and no `impl Into<DiagnosticMessage>` because bug messages
1009
+ // aren't user-facing.
1008
1010
#[ track_caller]
1009
- pub fn bug ( & self , msg : impl Into < DiagnosticMessage > ) -> ! {
1011
+ pub fn bug ( & self , msg : impl Into < Cow < ' static , str > > ) -> ! {
1010
1012
self . struct_bug ( msg) . emit ( )
1011
1013
}
1012
1014
1013
- // 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.
1014
1017
#[ track_caller]
1015
1018
pub fn struct_span_bug (
1016
1019
& self ,
1017
1020
span : impl Into < MultiSpan > ,
1018
- msg : impl Into < DiagnosticMessage > ,
1021
+ msg : impl Into < Cow < ' static , str > > ,
1019
1022
) -> DiagnosticBuilder < ' _ , BugAbort > {
1020
1023
self . struct_bug ( msg) . with_span ( span)
1021
1024
}
1022
1025
1023
- // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
1026
+ // No `#[rustc_lint_diagnostics]` and no `impl Into<DiagnosticMessage>` because bug messages
1027
+ // aren't user-facing.
1024
1028
#[ track_caller]
1025
- pub fn span_bug ( & self , span : impl Into < MultiSpan > , msg : impl Into < DiagnosticMessage > ) -> ! {
1026
- self . struct_span_bug ( span, msg) . emit ( )
1029
+ pub fn span_bug ( & self , span : impl Into < MultiSpan > , msg : impl Into < Cow < ' static , str > > ) -> ! {
1030
+ self . struct_span_bug ( span, msg. into ( ) ) . emit ( )
1027
1031
}
1028
1032
1029
1033
#[ track_caller]
@@ -1143,24 +1147,28 @@ impl DiagCtxt {
1143
1147
}
1144
1148
1145
1149
/// Ensures that an error is printed. See `Level::DelayedBug`.
1146
- // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
1150
+ //
1151
+ // No `#[rustc_lint_diagnostics]` and no `impl Into<DiagnosticMessage>` because bug messages
1152
+ // aren't user-facing.
1147
1153
#[ track_caller]
1148
- pub fn delayed_bug ( & self , msg : impl Into < DiagnosticMessage > ) -> ErrorGuaranteed {
1149
- DiagnosticBuilder :: < ErrorGuaranteed > :: new ( self , DelayedBug , msg) . emit ( )
1154
+ pub fn delayed_bug ( & self , msg : impl Into < Cow < ' static , str > > ) -> ErrorGuaranteed {
1155
+ DiagnosticBuilder :: < ErrorGuaranteed > :: new ( self , DelayedBug , msg. into ( ) ) . emit ( )
1150
1156
}
1151
1157
1152
1158
/// Ensures that an error is printed. See `Level::DelayedBug`.
1153
1159
///
1154
1160
/// Note: this function used to be called `delay_span_bug`. It was renamed
1155
1161
/// to match similar functions like `span_err`, `span_warn`, etc.
1156
- // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
1162
+ //
1163
+ // No `#[rustc_lint_diagnostics]` and no `impl Into<DiagnosticMessage>` because bug messages
1164
+ // aren't user-facing.
1157
1165
#[ track_caller]
1158
1166
pub fn span_delayed_bug (
1159
1167
& self ,
1160
1168
sp : impl Into < MultiSpan > ,
1161
- msg : impl Into < DiagnosticMessage > ,
1169
+ msg : impl Into < Cow < ' static , str > > ,
1162
1170
) -> ErrorGuaranteed {
1163
- DiagnosticBuilder :: < ErrorGuaranteed > :: new ( self , DelayedBug , msg) . with_span ( sp) . emit ( )
1171
+ DiagnosticBuilder :: < ErrorGuaranteed > :: new ( self , DelayedBug , msg. into ( ) ) . with_span ( sp) . emit ( )
1164
1172
}
1165
1173
1166
1174
#[ rustc_lint_diagnostics]
0 commit comments