@@ -987,32 +987,36 @@ impl DiagCtxt {
987
987
// Functions beginning with `struct_`/`create_` create a diagnostic. Other
988
988
// functions create and emit a diagnostic all in one go.
989
989
impl 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.
991
992
#[ 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 ( ) )
994
995
}
995
996
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.
997
999
#[ track_caller]
998
- pub fn bug ( & self , msg : impl Into < DiagnosticMessage > ) -> ! {
1000
+ pub fn bug ( & self , msg : impl Into < Cow < ' static , str > > ) -> ! {
999
1001
self . struct_bug ( msg) . emit ( )
1000
1002
}
1001
1003
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.
1003
1006
#[ track_caller]
1004
1007
pub fn struct_span_bug (
1005
1008
& self ,
1006
1009
span : impl Into < MultiSpan > ,
1007
- msg : impl Into < DiagnosticMessage > ,
1010
+ msg : impl Into < Cow < ' static , str > > ,
1008
1011
) -> DiagnosticBuilder < ' _ , BugAbort > {
1009
1012
self . struct_bug ( msg) . with_span ( span)
1010
1013
}
1011
1014
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.
1013
1017
#[ 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 ( )
1016
1020
}
1017
1021
1018
1022
#[ track_caller]
@@ -1132,24 +1136,28 @@ impl DiagCtxt {
1132
1136
}
1133
1137
1134
1138
/// 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.
1136
1142
#[ 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 ( )
1139
1145
}
1140
1146
1141
1147
/// Ensures that an error is printed. See `Level::DelayedBug`.
1142
1148
///
1143
1149
/// Note: this function used to be called `delay_span_bug`. It was renamed
1144
1150
/// 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.
1146
1154
#[ track_caller]
1147
1155
pub fn span_delayed_bug (
1148
1156
& self ,
1149
1157
sp : impl Into < MultiSpan > ,
1150
- msg : impl Into < DiagnosticMessage > ,
1158
+ msg : impl Into < Cow < ' static , str > > ,
1151
1159
) -> ErrorGuaranteed {
1152
- DiagnosticBuilder :: < ErrorGuaranteed > :: new ( self , DelayedBug , msg) . with_span ( sp) . emit ( )
1160
+ DiagnosticBuilder :: < ErrorGuaranteed > :: new ( self , DelayedBug , msg. into ( ) ) . with_span ( sp) . emit ( )
1153
1161
}
1154
1162
1155
1163
#[ rustc_lint_diagnostics]
0 commit comments