@@ -930,20 +930,19 @@ impl DiagCtxt {
930930// Functions beginning with `struct_`/`create_` create a diagnostic. Other
931931// functions create and emit a diagnostic all in one go.
932932impl 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.
935934 #[ track_caller]
936935 pub fn struct_bug ( & self , msg : impl Into < DiagnosticMessage > ) -> DiagnosticBuilder < ' _ , BugAbort > {
937936 DiagnosticBuilder :: new ( self , Bug , msg)
938937 }
939938
940- #[ rustc_lint_diagnostics]
939+ // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
940+ #[ track_caller]
941941 pub fn bug ( & self , msg : impl Into < DiagnosticMessage > ) -> ! {
942942 self . struct_bug ( msg) . emit ( )
943943 }
944944
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.
947946 #[ track_caller]
948947 pub fn struct_span_bug (
949948 & self ,
@@ -953,6 +952,8 @@ impl DiagCtxt {
953952 self . struct_bug ( msg) . with_span ( span)
954953 }
955954
955+ // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
956+ #[ track_caller]
956957 pub fn span_bug ( & self , span : impl Into < MultiSpan > , msg : impl Into < DiagnosticMessage > ) -> ! {
957958 self . struct_span_bug ( span, msg) . emit ( )
958959 }
@@ -966,11 +967,10 @@ impl DiagCtxt {
966967 }
967968
968969 #[ 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 > ) -> ! {
970971 self . create_bug ( bug) . emit ( )
971972 }
972973
973- /// Construct a builder at the `Fatal` level with the `msg`.
974974 #[ rustc_lint_diagnostics]
975975 #[ track_caller]
976976 pub fn struct_fatal (
@@ -981,11 +981,11 @@ impl DiagCtxt {
981981 }
982982
983983 #[ rustc_lint_diagnostics]
984+ #[ track_caller]
984985 pub fn fatal ( & self , msg : impl Into < DiagnosticMessage > ) -> ! {
985986 self . struct_fatal ( msg) . emit ( )
986987 }
987988
988- /// Construct a builder at the `Fatal` level at the given `span` and with the `msg`.
989989 #[ rustc_lint_diagnostics]
990990 #[ track_caller]
991991 pub fn struct_span_fatal (
@@ -1031,7 +1031,6 @@ impl DiagCtxt {
10311031 self . create_almost_fatal ( fatal) . emit ( )
10321032 }
10331033
1034- /// Construct a builder at the `Error` level with the `msg`.
10351034 // FIXME: This method should be removed (every error should have an associated error code).
10361035 #[ rustc_lint_diagnostics]
10371036 #[ track_caller]
@@ -1040,11 +1039,11 @@ impl DiagCtxt {
10401039 }
10411040
10421041 #[ rustc_lint_diagnostics]
1042+ #[ track_caller]
10431043 pub fn err ( & self , msg : impl Into < DiagnosticMessage > ) -> ErrorGuaranteed {
10441044 self . struct_err ( msg) . emit ( )
10451045 }
10461046
1047- /// Construct a builder at the `Error` level at the given `span` and with the `msg`.
10481047 #[ rustc_lint_diagnostics]
10491048 #[ track_caller]
10501049 pub fn struct_span_err (
@@ -1075,24 +1074,18 @@ impl DiagCtxt {
10751074 self . create_err ( err) . emit ( )
10761075 }
10771076
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.
10871079 #[ track_caller]
10881080 pub fn delayed_bug ( & self , msg : impl Into < DiagnosticMessage > ) -> ErrorGuaranteed {
10891081 DiagnosticBuilder :: < ErrorGuaranteed > :: new ( self , DelayedBug , msg) . emit ( )
10901082 }
10911083
1092- /// Like `delayed_bug`, but takes an additional span .
1084+ /// Ensures that an error is printed. See `Level::DelayedBug` .
10931085 ///
10941086 /// Note: this function used to be called `delay_span_bug`. It was renamed
10951087 /// to match similar functions like `span_err`, `span_warn`, etc.
1088+ // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
10961089 #[ track_caller]
10971090 pub fn span_delayed_bug (
10981091 & self ,
@@ -1103,27 +1096,24 @@ impl DiagCtxt {
11031096 }
11041097
11051098 /// Ensures that a diagnostic is printed. See `Level::GoodPathDelayedBug`.
1099+ // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
1100+ #[ track_caller]
11061101 pub fn good_path_delayed_bug ( & self , msg : impl Into < DiagnosticMessage > ) {
11071102 DiagnosticBuilder :: < ( ) > :: new ( self , GoodPathDelayedBug , msg) . emit ( )
11081103 }
11091104
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`.
11131105 #[ rustc_lint_diagnostics]
11141106 #[ track_caller]
11151107 pub fn struct_warn ( & self , msg : impl Into < DiagnosticMessage > ) -> DiagnosticBuilder < ' _ , ( ) > {
11161108 DiagnosticBuilder :: new ( self , Warning , msg)
11171109 }
11181110
11191111 #[ rustc_lint_diagnostics]
1112+ #[ track_caller]
11201113 pub fn warn ( & self , msg : impl Into < DiagnosticMessage > ) {
11211114 self . struct_warn ( msg) . emit ( )
11221115 }
11231116
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`.
11271117 #[ rustc_lint_diagnostics]
11281118 #[ track_caller]
11291119 pub fn struct_span_warn (
@@ -1153,20 +1143,20 @@ impl DiagCtxt {
11531143 self . create_warn ( warning) . emit ( )
11541144 }
11551145
1156- /// Construct a builder at the `Note` level with the `msg`.
11571146 #[ rustc_lint_diagnostics]
11581147 #[ track_caller]
11591148 pub fn struct_note ( & self , msg : impl Into < DiagnosticMessage > ) -> DiagnosticBuilder < ' _ , ( ) > {
11601149 DiagnosticBuilder :: new ( self , Note , msg)
11611150 }
11621151
11631152 #[ rustc_lint_diagnostics]
1153+ #[ track_caller]
11641154 pub fn note ( & self , msg : impl Into < DiagnosticMessage > ) {
11651155 self . struct_note ( msg) . emit ( )
11661156 }
11671157
1168- #[ track_caller]
11691158 #[ rustc_lint_diagnostics]
1159+ #[ track_caller]
11701160 pub fn struct_span_note (
11711161 & self ,
11721162 span : impl Into < MultiSpan > ,
@@ -1175,8 +1165,8 @@ impl DiagCtxt {
11751165 DiagnosticBuilder :: new ( self , Note , msg) . with_span ( span)
11761166 }
11771167
1178- #[ track_caller]
11791168 #[ rustc_lint_diagnostics]
1169+ #[ track_caller]
11801170 pub fn span_note ( & self , span : impl Into < MultiSpan > , msg : impl Into < DiagnosticMessage > ) {
11811171 self . struct_span_note ( span, msg) . emit ( )
11821172 }
@@ -1194,20 +1184,18 @@ impl DiagCtxt {
11941184 self . create_note ( note) . emit ( )
11951185 }
11961186
1197- /// Construct a builder at the `Help` level with the `msg`.
11981187 #[ rustc_lint_diagnostics]
1188+ #[ track_caller]
11991189 pub fn struct_help ( & self , msg : impl Into < DiagnosticMessage > ) -> DiagnosticBuilder < ' _ , ( ) > {
12001190 DiagnosticBuilder :: new ( self , Help , msg)
12011191 }
12021192
1203- /// Construct a builder at the `Allow` level with the `msg`.
12041193 #[ rustc_lint_diagnostics]
12051194 #[ track_caller]
12061195 pub fn struct_allow ( & self , msg : impl Into < DiagnosticMessage > ) -> DiagnosticBuilder < ' _ , ( ) > {
12071196 DiagnosticBuilder :: new ( self , Allow , msg)
12081197 }
12091198
1210- /// Construct a builder at the `Expect` level with the `msg`.
12111199 #[ rustc_lint_diagnostics]
12121200 #[ track_caller]
12131201 pub fn struct_expect (
@@ -1576,6 +1564,7 @@ pub enum Level {
15761564 ForceWarning ( Option < LintExpectationId > ) ,
15771565
15781566 /// A warning about the code being compiled. Does not prevent compilation from finishing.
1567+ /// Will be skipped if `can_emit_warnings` is false.
15791568 Warning ,
15801569
15811570 /// A message giving additional context.
0 commit comments