@@ -580,6 +580,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
580
580
///
581
581
/// In the meantime, though, callsites are required to deal with the "bug"
582
582
/// locally in whichever way makes the most sense.
583
+ #[ rustc_lint_diagnostics]
583
584
#[ track_caller]
584
585
pub fn downgrade_to_delayed_bug ( & mut self ) {
585
586
assert ! (
@@ -613,13 +614,15 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
613
614
with_fn ! { with_span_labels,
614
615
/// Labels all the given spans with the provided label.
615
616
/// See [`Self::span_label()`] for more information.
617
+ #[ rustc_lint_diagnostics]
616
618
pub fn span_labels( & mut self , spans: impl IntoIterator <Item = Span >, label: & str ) -> & mut Self {
617
619
for span in spans {
618
620
self . span_label( span, label. to_string( ) ) ;
619
621
}
620
622
self
621
623
} }
622
624
625
+ #[ rustc_lint_diagnostics]
623
626
pub fn replace_span_with ( & mut self , after : Span , keep_label : bool ) -> & mut Self {
624
627
let before = self . span . clone ( ) ;
625
628
self . span ( after) ;
@@ -635,6 +638,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
635
638
self
636
639
}
637
640
641
+ #[ rustc_lint_diagnostics]
638
642
pub fn note_expected_found (
639
643
& mut self ,
640
644
expected_label : & dyn fmt:: Display ,
@@ -645,6 +649,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
645
649
self . note_expected_found_extra ( expected_label, expected, found_label, found, & "" , & "" )
646
650
}
647
651
652
+ #[ rustc_lint_diagnostics]
648
653
pub fn note_expected_found_extra (
649
654
& mut self ,
650
655
expected_label : & dyn fmt:: Display ,
@@ -687,6 +692,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
687
692
self
688
693
}
689
694
695
+ #[ rustc_lint_diagnostics]
690
696
pub fn note_trait_signature ( & mut self , name : Symbol , signature : String ) -> & mut Self {
691
697
self . highlighted_note ( vec ! [
692
698
StringPart :: normal( format!( "`{name}` from trait: `" ) ) ,
@@ -704,12 +710,14 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
704
710
self
705
711
} }
706
712
713
+ #[ rustc_lint_diagnostics]
707
714
fn highlighted_note ( & mut self , msg : Vec < StringPart > ) -> & mut Self {
708
715
self . sub_with_highlights ( Level :: Note , msg, MultiSpan :: new ( ) ) ;
709
716
self
710
717
}
711
718
712
719
/// This is like [`Diag::note()`], but it's only printed once.
720
+ #[ rustc_lint_diagnostics]
713
721
pub fn note_once ( & mut self , msg : impl Into < SubdiagnosticMessage > ) -> & mut Self {
714
722
self . sub ( Level :: OnceNote , msg, MultiSpan :: new ( ) ) ;
715
723
self
@@ -730,6 +738,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
730
738
731
739
/// Prints the span with a note above it.
732
740
/// This is like [`Diag::note_once()`], but it gets its own span.
741
+ #[ rustc_lint_diagnostics]
733
742
pub fn span_note_once < S : Into < MultiSpan > > (
734
743
& mut self ,
735
744
sp : S ,
@@ -768,12 +777,14 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
768
777
} }
769
778
770
779
/// This is like [`Diag::help()`], but it's only printed once.
780
+ #[ rustc_lint_diagnostics]
771
781
pub fn help_once ( & mut self , msg : impl Into < SubdiagnosticMessage > ) -> & mut Self {
772
782
self . sub ( Level :: OnceHelp , msg, MultiSpan :: new ( ) ) ;
773
783
self
774
784
}
775
785
776
786
/// Add a help message attached to this diagnostic with a customizable highlighted message.
787
+ #[ rustc_lint_diagnostics]
777
788
pub fn highlighted_help ( & mut self , msg : Vec < StringPart > ) -> & mut Self {
778
789
self . sub_with_highlights ( Level :: Help , msg, MultiSpan :: new ( ) ) ;
779
790
self
@@ -794,12 +805,14 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
794
805
/// Disallow attaching suggestions this diagnostic.
795
806
/// Any suggestions attached e.g. with the `span_suggestion_*` methods
796
807
/// (before and after the call to `disable_suggestions`) will be ignored.
808
+ #[ rustc_lint_diagnostics]
797
809
pub fn disable_suggestions ( & mut self ) -> & mut Self {
798
810
self . suggestions = Err ( SuggestionsDisabled ) ;
799
811
self
800
812
}
801
813
802
814
/// Helper for pushing to `self.suggestions`, if available (not disable).
815
+ #[ rustc_lint_diagnostics]
803
816
fn push_suggestion ( & mut self , suggestion : CodeSuggestion ) {
804
817
for subst in & suggestion. substitutions {
805
818
for part in & subst. parts {
@@ -820,6 +833,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
820
833
with_fn ! { with_multipart_suggestion,
821
834
/// Show a suggestion that has multiple parts to it.
822
835
/// In other words, multiple changes need to be applied as part of this suggestion.
836
+ #[ rustc_lint_diagnostics]
823
837
pub fn multipart_suggestion(
824
838
& mut self ,
825
839
msg: impl Into <SubdiagnosticMessage >,
@@ -836,6 +850,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
836
850
837
851
/// Show a suggestion that has multiple parts to it, always as it's own subdiagnostic.
838
852
/// In other words, multiple changes need to be applied as part of this suggestion.
853
+ #[ rustc_lint_diagnostics]
839
854
pub fn multipart_suggestion_verbose (
840
855
& mut self ,
841
856
msg : impl Into < SubdiagnosticMessage > ,
@@ -851,6 +866,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
851
866
}
852
867
853
868
/// [`Diag::multipart_suggestion()`] but you can set the [`SuggestionStyle`].
869
+ #[ rustc_lint_diagnostics]
854
870
pub fn multipart_suggestion_with_style (
855
871
& mut self ,
856
872
msg : impl Into < SubdiagnosticMessage > ,
@@ -893,6 +909,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
893
909
/// be from the message, showing the span label inline would be visually unpleasant
894
910
/// (marginally overlapping spans or multiline spans) and showing the snippet window wouldn't
895
911
/// improve understandability.
912
+ #[ rustc_lint_diagnostics]
896
913
pub fn tool_only_multipart_suggestion (
897
914
& mut self ,
898
915
msg : impl Into < SubdiagnosticMessage > ,
@@ -925,6 +942,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
925
942
/// * may contain a name of a function, variable, or type, but not whole expressions
926
943
///
927
944
/// See `CodeSuggestion` for more information.
945
+ #[ rustc_lint_diagnostics]
928
946
pub fn span_suggestion(
929
947
& mut self ,
930
948
sp: Span ,
@@ -943,6 +961,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
943
961
} }
944
962
945
963
/// [`Diag::span_suggestion()`] but you can set the [`SuggestionStyle`].
964
+ #[ rustc_lint_diagnostics]
946
965
pub fn span_suggestion_with_style (
947
966
& mut self ,
948
967
sp : Span ,
@@ -968,6 +987,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
968
987
969
988
with_fn ! { with_span_suggestion_verbose,
970
989
/// Always show the suggested change.
990
+ #[ rustc_lint_diagnostics]
971
991
pub fn span_suggestion_verbose(
972
992
& mut self ,
973
993
sp: Span ,
@@ -988,6 +1008,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
988
1008
with_fn ! { with_span_suggestions,
989
1009
/// Prints out a message with multiple suggested edits of the code.
990
1010
/// See also [`Diag::span_suggestion()`].
1011
+ #[ rustc_lint_diagnostics]
991
1012
pub fn span_suggestions(
992
1013
& mut self ,
993
1014
sp: Span ,
@@ -1004,6 +1025,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
1004
1025
)
1005
1026
} }
1006
1027
1028
+ #[ rustc_lint_diagnostics]
1007
1029
pub fn span_suggestions_with_style (
1008
1030
& mut self ,
1009
1031
sp : Span ,
@@ -1034,6 +1056,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
1034
1056
/// Prints out a message with multiple suggested edits of the code, where each edit consists of
1035
1057
/// multiple parts.
1036
1058
/// See also [`Diag::multipart_suggestion()`].
1059
+ #[ rustc_lint_diagnostics]
1037
1060
pub fn multipart_suggestions (
1038
1061
& mut self ,
1039
1062
msg : impl Into < SubdiagnosticMessage > ,
@@ -1080,6 +1103,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
1080
1103
/// inline, it will only show the message and not the suggestion.
1081
1104
///
1082
1105
/// See `CodeSuggestion` for more information.
1106
+ #[ rustc_lint_diagnostics]
1083
1107
pub fn span_suggestion_short(
1084
1108
& mut self ,
1085
1109
sp: Span ,
@@ -1103,6 +1127,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
1103
1127
/// be from the message, showing the span label inline would be visually unpleasant
1104
1128
/// (marginally overlapping spans or multiline spans) and showing the snippet window wouldn't
1105
1129
/// improve understandability.
1130
+ #[ rustc_lint_diagnostics]
1106
1131
pub fn span_suggestion_hidden (
1107
1132
& mut self ,
1108
1133
sp : Span ,
@@ -1147,6 +1172,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
1147
1172
/// [rustc_macros::Subdiagnostic]). Performs eager translation of any translatable messages
1148
1173
/// used in the subdiagnostic, so suitable for use with repeated messages (i.e. re-use of
1149
1174
/// interpolated variables).
1175
+ #[ rustc_lint_diagnostics]
1150
1176
pub fn subdiagnostic (
1151
1177
& mut self ,
1152
1178
dcx : & crate :: DiagCtxt ,
@@ -1162,6 +1188,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
1162
1188
1163
1189
with_fn ! { with_span,
1164
1190
/// Add a span.
1191
+ #[ cfg_attr( not( bootstrap) , rustc_lint_diagnostics) ]
1165
1192
pub fn span( & mut self , sp: impl Into <MultiSpan >) -> & mut Self {
1166
1193
self . span = sp. into( ) ;
1167
1194
if let Some ( span) = self . span. primary_span( ) {
@@ -1170,27 +1197,31 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
1170
1197
self
1171
1198
} }
1172
1199
1200
+ #[ rustc_lint_diagnostics]
1173
1201
pub fn is_lint ( & mut self , name : String , has_future_breakage : bool ) -> & mut Self {
1174
1202
self . is_lint = Some ( IsLint { name, has_future_breakage } ) ;
1175
1203
self
1176
1204
}
1177
1205
1178
1206
with_fn ! { with_code,
1179
1207
/// Add an error code.
1208
+ #[ rustc_lint_diagnostics]
1180
1209
pub fn code( & mut self , code: ErrCode ) -> & mut Self {
1181
1210
self . code = Some ( code) ;
1182
1211
self
1183
1212
} }
1184
1213
1185
1214
with_fn ! { with_primary_message,
1186
1215
/// Add a primary message.
1216
+ #[ rustc_lint_diagnostics]
1187
1217
pub fn primary_message( & mut self , msg: impl Into <DiagnosticMessage >) -> & mut Self {
1188
1218
self . messages[ 0 ] = ( msg. into( ) , Style :: NoStyle ) ;
1189
1219
self
1190
1220
} }
1191
1221
1192
1222
with_fn ! { with_arg,
1193
1223
/// Add an argument.
1224
+ #[ rustc_lint_diagnostics]
1194
1225
pub fn arg(
1195
1226
& mut self ,
1196
1227
name: impl Into <DiagArgName >,
0 commit comments