@@ -945,20 +945,19 @@ impl DiagCtxt {
945
945
// Functions beginning with `struct_`/`create_` create a diagnostic. Other
946
946
// functions create and emit a diagnostic all in one go.
947
947
impl DiagCtxt {
948
- /// Construct a builder at the `Bug` level with the `msg`.
949
- #[ rustc_lint_diagnostics]
948
+ // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
950
949
#[ track_caller]
951
950
pub fn struct_bug ( & self , msg : impl Into < DiagnosticMessage > ) -> DiagnosticBuilder < ' _ , BugAbort > {
952
951
DiagnosticBuilder :: new ( self , Bug , msg)
953
952
}
954
953
955
- #[ rustc_lint_diagnostics]
954
+ // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
955
+ #[ track_caller]
956
956
pub fn bug ( & self , msg : impl Into < DiagnosticMessage > ) -> ! {
957
957
self . struct_bug ( msg) . emit ( )
958
958
}
959
959
960
- /// Construct a builder at the `Bug` level at the given `span` with the `msg`.
961
- #[ rustc_lint_diagnostics]
960
+ // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
962
961
#[ track_caller]
963
962
pub fn struct_span_bug (
964
963
& self ,
@@ -968,6 +967,8 @@ impl DiagCtxt {
968
967
self . struct_bug ( msg) . with_span ( span)
969
968
}
970
969
970
+ // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
971
+ #[ track_caller]
971
972
pub fn span_bug ( & self , span : impl Into < MultiSpan > , msg : impl Into < DiagnosticMessage > ) -> ! {
972
973
self . struct_span_bug ( span, msg) . emit ( )
973
974
}
@@ -981,11 +982,10 @@ impl DiagCtxt {
981
982
}
982
983
983
984
#[ track_caller]
984
- pub fn emit_bug < ' a > ( & ' a self , bug : impl IntoDiagnostic < ' a , diagnostic_builder :: BugAbort > ) -> ! {
985
+ pub fn emit_bug < ' a > ( & ' a self , bug : impl IntoDiagnostic < ' a , BugAbort > ) -> ! {
985
986
self . create_bug ( bug) . emit ( )
986
987
}
987
988
988
- /// Construct a builder at the `Fatal` level with the `msg`.
989
989
#[ rustc_lint_diagnostics]
990
990
#[ track_caller]
991
991
pub fn struct_fatal (
@@ -996,11 +996,11 @@ impl DiagCtxt {
996
996
}
997
997
998
998
#[ rustc_lint_diagnostics]
999
+ #[ track_caller]
999
1000
pub fn fatal ( & self , msg : impl Into < DiagnosticMessage > ) -> ! {
1000
1001
self . struct_fatal ( msg) . emit ( )
1001
1002
}
1002
1003
1003
- /// Construct a builder at the `Fatal` level at the given `span` and with the `msg`.
1004
1004
#[ rustc_lint_diagnostics]
1005
1005
#[ track_caller]
1006
1006
pub fn struct_span_fatal (
@@ -1046,7 +1046,6 @@ impl DiagCtxt {
1046
1046
self . create_almost_fatal ( fatal) . emit ( )
1047
1047
}
1048
1048
1049
- /// Construct a builder at the `Error` level with the `msg`.
1050
1049
// FIXME: This method should be removed (every error should have an associated error code).
1051
1050
#[ rustc_lint_diagnostics]
1052
1051
#[ track_caller]
@@ -1055,11 +1054,11 @@ impl DiagCtxt {
1055
1054
}
1056
1055
1057
1056
#[ rustc_lint_diagnostics]
1057
+ #[ track_caller]
1058
1058
pub fn err ( & self , msg : impl Into < DiagnosticMessage > ) -> ErrorGuaranteed {
1059
1059
self . struct_err ( msg) . emit ( )
1060
1060
}
1061
1061
1062
- /// Construct a builder at the `Error` level at the given `span` and with the `msg`.
1063
1062
#[ rustc_lint_diagnostics]
1064
1063
#[ track_caller]
1065
1064
pub fn struct_span_err (
@@ -1090,24 +1089,18 @@ impl DiagCtxt {
1090
1089
self . create_err ( err) . emit ( )
1091
1090
}
1092
1091
1093
- /// Ensures that compilation cannot succeed.
1094
- ///
1095
- /// If this function has been called but no errors have been emitted and
1096
- /// compilation succeeds, it will cause an internal compiler error (ICE).
1097
- ///
1098
- /// This can be used in code paths that should never run on successful compilations.
1099
- /// For example, it can be used to create an [`ErrorGuaranteed`]
1100
- /// (but you should prefer threading through the [`ErrorGuaranteed`] from an error emission
1101
- /// directly).
1092
+ /// Ensures that an error is printed. See `Level::DelayedBug`.
1093
+ // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
1102
1094
#[ track_caller]
1103
1095
pub fn delayed_bug ( & self , msg : impl Into < DiagnosticMessage > ) -> ErrorGuaranteed {
1104
1096
DiagnosticBuilder :: < ErrorGuaranteed > :: new ( self , DelayedBug , msg) . emit ( )
1105
1097
}
1106
1098
1107
- /// Like `delayed_bug`, but takes an additional span .
1099
+ /// Ensures that an error is printed. See `Level::DelayedBug` .
1108
1100
///
1109
1101
/// Note: this function used to be called `delay_span_bug`. It was renamed
1110
1102
/// to match similar functions like `span_err`, `span_warn`, etc.
1103
+ // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
1111
1104
#[ track_caller]
1112
1105
pub fn span_delayed_bug (
1113
1106
& self ,
@@ -1118,27 +1111,24 @@ impl DiagCtxt {
1118
1111
}
1119
1112
1120
1113
/// Ensures that a diagnostic is printed. See `Level::GoodPathDelayedBug`.
1114
+ // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
1115
+ #[ track_caller]
1121
1116
pub fn good_path_delayed_bug ( & self , msg : impl Into < DiagnosticMessage > ) {
1122
1117
DiagnosticBuilder :: < ( ) > :: new ( self , GoodPathDelayedBug , msg) . emit ( )
1123
1118
}
1124
1119
1125
- /// Construct a builder at the `Warning` level with the `msg`.
1126
- ///
1127
- /// An `emit` call on the builder will only emit if `can_emit_warnings` is `true`.
1128
1120
#[ rustc_lint_diagnostics]
1129
1121
#[ track_caller]
1130
1122
pub fn struct_warn ( & self , msg : impl Into < DiagnosticMessage > ) -> DiagnosticBuilder < ' _ , ( ) > {
1131
1123
DiagnosticBuilder :: new ( self , Warning , msg)
1132
1124
}
1133
1125
1134
1126
#[ rustc_lint_diagnostics]
1127
+ #[ track_caller]
1135
1128
pub fn warn ( & self , msg : impl Into < DiagnosticMessage > ) {
1136
1129
self . struct_warn ( msg) . emit ( )
1137
1130
}
1138
1131
1139
- /// Construct a builder at the `Warning` level at the given `span` and with the `msg`.
1140
- ///
1141
- /// An `emit` call on the builder will only emit if `can_emit_warnings` is `true`.
1142
1132
#[ rustc_lint_diagnostics]
1143
1133
#[ track_caller]
1144
1134
pub fn struct_span_warn (
@@ -1168,20 +1158,20 @@ impl DiagCtxt {
1168
1158
self . create_warn ( warning) . emit ( )
1169
1159
}
1170
1160
1171
- /// Construct a builder at the `Note` level with the `msg`.
1172
1161
#[ rustc_lint_diagnostics]
1173
1162
#[ track_caller]
1174
1163
pub fn struct_note ( & self , msg : impl Into < DiagnosticMessage > ) -> DiagnosticBuilder < ' _ , ( ) > {
1175
1164
DiagnosticBuilder :: new ( self , Note , msg)
1176
1165
}
1177
1166
1178
1167
#[ rustc_lint_diagnostics]
1168
+ #[ track_caller]
1179
1169
pub fn note ( & self , msg : impl Into < DiagnosticMessage > ) {
1180
1170
self . struct_note ( msg) . emit ( )
1181
1171
}
1182
1172
1183
- #[ track_caller]
1184
1173
#[ rustc_lint_diagnostics]
1174
+ #[ track_caller]
1185
1175
pub fn struct_span_note (
1186
1176
& self ,
1187
1177
span : impl Into < MultiSpan > ,
@@ -1190,8 +1180,8 @@ impl DiagCtxt {
1190
1180
DiagnosticBuilder :: new ( self , Note , msg) . with_span ( span)
1191
1181
}
1192
1182
1193
- #[ track_caller]
1194
1183
#[ rustc_lint_diagnostics]
1184
+ #[ track_caller]
1195
1185
pub fn span_note ( & self , span : impl Into < MultiSpan > , msg : impl Into < DiagnosticMessage > ) {
1196
1186
self . struct_span_note ( span, msg) . emit ( )
1197
1187
}
@@ -1209,20 +1199,18 @@ impl DiagCtxt {
1209
1199
self . create_note ( note) . emit ( )
1210
1200
}
1211
1201
1212
- /// Construct a builder at the `Help` level with the `msg`.
1213
1202
#[ rustc_lint_diagnostics]
1203
+ #[ track_caller]
1214
1204
pub fn struct_help ( & self , msg : impl Into < DiagnosticMessage > ) -> DiagnosticBuilder < ' _ , ( ) > {
1215
1205
DiagnosticBuilder :: new ( self , Help , msg)
1216
1206
}
1217
1207
1218
- /// Construct a builder at the `Allow` level with the `msg`.
1219
1208
#[ rustc_lint_diagnostics]
1220
1209
#[ track_caller]
1221
1210
pub fn struct_allow ( & self , msg : impl Into < DiagnosticMessage > ) -> DiagnosticBuilder < ' _ , ( ) > {
1222
1211
DiagnosticBuilder :: new ( self , Allow , msg)
1223
1212
}
1224
1213
1225
- /// Construct a builder at the `Expect` level with the `msg`.
1226
1214
#[ rustc_lint_diagnostics]
1227
1215
#[ track_caller]
1228
1216
pub fn struct_expect (
@@ -1589,6 +1577,7 @@ pub enum Level {
1589
1577
ForceWarning ( Option < LintExpectationId > ) ,
1590
1578
1591
1579
/// A warning about the code being compiled. Does not prevent compilation from finishing.
1580
+ /// Will be skipped if `can_emit_warnings` is false.
1592
1581
Warning ,
1593
1582
1594
1583
/// A message giving additional context.
0 commit comments