@@ -930,20 +930,19 @@ impl DiagCtxt {
930
930
// Functions beginning with `struct_`/`create_` create a diagnostic. Other
931
931
// functions create and emit a diagnostic all in one go.
932
932
impl DiagCtxt {
933
- /// Construct a builder at the `Bug` level with the `msg`.
934
- #[ rustc_lint_diagnostics]
933
+ // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
935
934
#[ track_caller]
936
935
pub fn struct_bug ( & self , msg : impl Into < DiagnosticMessage > ) -> DiagnosticBuilder < ' _ , BugAbort > {
937
936
DiagnosticBuilder :: new ( self , Bug , msg)
938
937
}
939
938
940
- #[ rustc_lint_diagnostics]
939
+ // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
940
+ #[ track_caller]
941
941
pub fn bug ( & self , msg : impl Into < DiagnosticMessage > ) -> ! {
942
942
self . struct_bug ( msg) . emit ( )
943
943
}
944
944
945
- /// Construct a builder at the `Bug` level at the given `span` with the `msg`.
946
- #[ rustc_lint_diagnostics]
945
+ // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
947
946
#[ track_caller]
948
947
pub fn struct_span_bug (
949
948
& self ,
@@ -953,6 +952,8 @@ impl DiagCtxt {
953
952
self . struct_bug ( msg) . with_span ( span)
954
953
}
955
954
955
+ // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
956
+ #[ track_caller]
956
957
pub fn span_bug ( & self , span : impl Into < MultiSpan > , msg : impl Into < DiagnosticMessage > ) -> ! {
957
958
self . struct_span_bug ( span, msg) . emit ( )
958
959
}
@@ -966,11 +967,10 @@ impl DiagCtxt {
966
967
}
967
968
968
969
#[ track_caller]
969
- pub fn emit_bug < ' a > ( & ' a self , bug : impl IntoDiagnostic < ' a , diagnostic_builder :: BugAbort > ) -> ! {
970
+ pub fn emit_bug < ' a > ( & ' a self , bug : impl IntoDiagnostic < ' a , BugAbort > ) -> ! {
970
971
self . create_bug ( bug) . emit ( )
971
972
}
972
973
973
- /// Construct a builder at the `Fatal` level with the `msg`.
974
974
#[ rustc_lint_diagnostics]
975
975
#[ track_caller]
976
976
pub fn struct_fatal (
@@ -981,11 +981,11 @@ impl DiagCtxt {
981
981
}
982
982
983
983
#[ rustc_lint_diagnostics]
984
+ #[ track_caller]
984
985
pub fn fatal ( & self , msg : impl Into < DiagnosticMessage > ) -> ! {
985
986
self . struct_fatal ( msg) . emit ( )
986
987
}
987
988
988
- /// Construct a builder at the `Fatal` level at the given `span` and with the `msg`.
989
989
#[ rustc_lint_diagnostics]
990
990
#[ track_caller]
991
991
pub fn struct_span_fatal (
@@ -1031,7 +1031,6 @@ impl DiagCtxt {
1031
1031
self . create_almost_fatal ( fatal) . emit ( )
1032
1032
}
1033
1033
1034
- /// Construct a builder at the `Error` level with the `msg`.
1035
1034
// FIXME: This method should be removed (every error should have an associated error code).
1036
1035
#[ rustc_lint_diagnostics]
1037
1036
#[ track_caller]
@@ -1040,11 +1039,11 @@ impl DiagCtxt {
1040
1039
}
1041
1040
1042
1041
#[ rustc_lint_diagnostics]
1042
+ #[ track_caller]
1043
1043
pub fn err ( & self , msg : impl Into < DiagnosticMessage > ) -> ErrorGuaranteed {
1044
1044
self . struct_err ( msg) . emit ( )
1045
1045
}
1046
1046
1047
- /// Construct a builder at the `Error` level at the given `span` and with the `msg`.
1048
1047
#[ rustc_lint_diagnostics]
1049
1048
#[ track_caller]
1050
1049
pub fn struct_span_err (
@@ -1075,24 +1074,18 @@ impl DiagCtxt {
1075
1074
self . create_err ( err) . emit ( )
1076
1075
}
1077
1076
1078
- /// Ensures that compilation cannot succeed.
1079
- ///
1080
- /// If this function has been called but no errors have been emitted and
1081
- /// compilation succeeds, it will cause an internal compiler error (ICE).
1082
- ///
1083
- /// This can be used in code paths that should never run on successful compilations.
1084
- /// For example, it can be used to create an [`ErrorGuaranteed`]
1085
- /// (but you should prefer threading through the [`ErrorGuaranteed`] from an error emission
1086
- /// directly).
1077
+ /// Ensures that an error is printed. See `Level::DelayedBug`.
1078
+ // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
1087
1079
#[ track_caller]
1088
1080
pub fn delayed_bug ( & self , msg : impl Into < DiagnosticMessage > ) -> ErrorGuaranteed {
1089
1081
DiagnosticBuilder :: < ErrorGuaranteed > :: new ( self , DelayedBug , msg) . emit ( )
1090
1082
}
1091
1083
1092
- /// Like `delayed_bug`, but takes an additional span .
1084
+ /// Ensures that an error is printed. See `Level::DelayedBug` .
1093
1085
///
1094
1086
/// Note: this function used to be called `delay_span_bug`. It was renamed
1095
1087
/// to match similar functions like `span_err`, `span_warn`, etc.
1088
+ // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
1096
1089
#[ track_caller]
1097
1090
pub fn span_delayed_bug (
1098
1091
& self ,
@@ -1103,27 +1096,24 @@ impl DiagCtxt {
1103
1096
}
1104
1097
1105
1098
/// Ensures that a diagnostic is printed. See `Level::GoodPathDelayedBug`.
1099
+ // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
1100
+ #[ track_caller]
1106
1101
pub fn good_path_delayed_bug ( & self , msg : impl Into < DiagnosticMessage > ) {
1107
1102
DiagnosticBuilder :: < ( ) > :: new ( self , GoodPathDelayedBug , msg) . emit ( )
1108
1103
}
1109
1104
1110
- /// Construct a builder at the `Warning` level with the `msg`.
1111
- ///
1112
- /// An `emit` call on the builder will only emit if `can_emit_warnings` is `true`.
1113
1105
#[ rustc_lint_diagnostics]
1114
1106
#[ track_caller]
1115
1107
pub fn struct_warn ( & self , msg : impl Into < DiagnosticMessage > ) -> DiagnosticBuilder < ' _ , ( ) > {
1116
1108
DiagnosticBuilder :: new ( self , Warning , msg)
1117
1109
}
1118
1110
1119
1111
#[ rustc_lint_diagnostics]
1112
+ #[ track_caller]
1120
1113
pub fn warn ( & self , msg : impl Into < DiagnosticMessage > ) {
1121
1114
self . struct_warn ( msg) . emit ( )
1122
1115
}
1123
1116
1124
- /// Construct a builder at the `Warning` level at the given `span` and with the `msg`.
1125
- ///
1126
- /// An `emit` call on the builder will only emit if `can_emit_warnings` is `true`.
1127
1117
#[ rustc_lint_diagnostics]
1128
1118
#[ track_caller]
1129
1119
pub fn struct_span_warn (
@@ -1153,20 +1143,20 @@ impl DiagCtxt {
1153
1143
self . create_warn ( warning) . emit ( )
1154
1144
}
1155
1145
1156
- /// Construct a builder at the `Note` level with the `msg`.
1157
1146
#[ rustc_lint_diagnostics]
1158
1147
#[ track_caller]
1159
1148
pub fn struct_note ( & self , msg : impl Into < DiagnosticMessage > ) -> DiagnosticBuilder < ' _ , ( ) > {
1160
1149
DiagnosticBuilder :: new ( self , Note , msg)
1161
1150
}
1162
1151
1163
1152
#[ rustc_lint_diagnostics]
1153
+ #[ track_caller]
1164
1154
pub fn note ( & self , msg : impl Into < DiagnosticMessage > ) {
1165
1155
self . struct_note ( msg) . emit ( )
1166
1156
}
1167
1157
1168
- #[ track_caller]
1169
1158
#[ rustc_lint_diagnostics]
1159
+ #[ track_caller]
1170
1160
pub fn struct_span_note (
1171
1161
& self ,
1172
1162
span : impl Into < MultiSpan > ,
@@ -1175,8 +1165,8 @@ impl DiagCtxt {
1175
1165
DiagnosticBuilder :: new ( self , Note , msg) . with_span ( span)
1176
1166
}
1177
1167
1178
- #[ track_caller]
1179
1168
#[ rustc_lint_diagnostics]
1169
+ #[ track_caller]
1180
1170
pub fn span_note ( & self , span : impl Into < MultiSpan > , msg : impl Into < DiagnosticMessage > ) {
1181
1171
self . struct_span_note ( span, msg) . emit ( )
1182
1172
}
@@ -1194,20 +1184,18 @@ impl DiagCtxt {
1194
1184
self . create_note ( note) . emit ( )
1195
1185
}
1196
1186
1197
- /// Construct a builder at the `Help` level with the `msg`.
1198
1187
#[ rustc_lint_diagnostics]
1188
+ #[ track_caller]
1199
1189
pub fn struct_help ( & self , msg : impl Into < DiagnosticMessage > ) -> DiagnosticBuilder < ' _ , ( ) > {
1200
1190
DiagnosticBuilder :: new ( self , Help , msg)
1201
1191
}
1202
1192
1203
- /// Construct a builder at the `Allow` level with the `msg`.
1204
1193
#[ rustc_lint_diagnostics]
1205
1194
#[ track_caller]
1206
1195
pub fn struct_allow ( & self , msg : impl Into < DiagnosticMessage > ) -> DiagnosticBuilder < ' _ , ( ) > {
1207
1196
DiagnosticBuilder :: new ( self , Allow , msg)
1208
1197
}
1209
1198
1210
- /// Construct a builder at the `Expect` level with the `msg`.
1211
1199
#[ rustc_lint_diagnostics]
1212
1200
#[ track_caller]
1213
1201
pub fn struct_expect (
@@ -1576,6 +1564,7 @@ pub enum Level {
1576
1564
ForceWarning ( Option < LintExpectationId > ) ,
1577
1565
1578
1566
/// A warning about the code being compiled. Does not prevent compilation from finishing.
1567
+ /// Will be skipped if `can_emit_warnings` is false.
1579
1568
Warning ,
1580
1569
1581
1570
/// A message giving additional context.
0 commit comments