@@ -598,6 +598,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
598
598
///
599
599
/// In the meantime, though, callsites are required to deal with the "bug"
600
600
/// locally in whichever way makes the most sense.
601
+ #[ rustc_lint_diagnostics]
601
602
#[ track_caller]
602
603
pub fn downgrade_to_delayed_bug ( & mut self ) {
603
604
assert ! (
@@ -631,13 +632,15 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
631
632
with_fn ! { with_span_labels,
632
633
/// Labels all the given spans with the provided label.
633
634
/// See [`Self::span_label()`] for more information.
635
+ #[ rustc_lint_diagnostics]
634
636
pub fn span_labels( & mut self , spans: impl IntoIterator <Item = Span >, label: & str ) -> & mut Self {
635
637
for span in spans {
636
638
self . span_label( span, label. to_string( ) ) ;
637
639
}
638
640
self
639
641
} }
640
642
643
+ #[ rustc_lint_diagnostics]
641
644
pub fn replace_span_with ( & mut self , after : Span , keep_label : bool ) -> & mut Self {
642
645
let before = self . span . clone ( ) ;
643
646
self . span ( after) ;
@@ -653,6 +656,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
653
656
self
654
657
}
655
658
659
+ #[ rustc_lint_diagnostics]
656
660
pub fn note_expected_found (
657
661
& mut self ,
658
662
expected_label : & dyn fmt:: Display ,
@@ -663,6 +667,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
663
667
self . note_expected_found_extra ( expected_label, expected, found_label, found, & "" , & "" )
664
668
}
665
669
670
+ #[ rustc_lint_diagnostics]
666
671
pub fn note_expected_found_extra (
667
672
& mut self ,
668
673
expected_label : & dyn fmt:: Display ,
@@ -705,6 +710,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
705
710
self
706
711
}
707
712
713
+ #[ rustc_lint_diagnostics]
708
714
pub fn note_trait_signature ( & mut self , name : Symbol , signature : String ) -> & mut Self {
709
715
self . highlighted_note ( vec ! [
710
716
StringPart :: normal( format!( "`{name}` from trait: `" ) ) ,
@@ -722,12 +728,14 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
722
728
self
723
729
} }
724
730
731
+ #[ rustc_lint_diagnostics]
725
732
fn highlighted_note ( & mut self , msg : Vec < StringPart > ) -> & mut Self {
726
733
self . sub_with_highlights ( Level :: Note , msg, MultiSpan :: new ( ) ) ;
727
734
self
728
735
}
729
736
730
737
/// This is like [`Diag::note()`], but it's only printed once.
738
+ #[ rustc_lint_diagnostics]
731
739
pub fn note_once ( & mut self , msg : impl Into < SubdiagMessage > ) -> & mut Self {
732
740
self . sub ( Level :: OnceNote , msg, MultiSpan :: new ( ) ) ;
733
741
self
@@ -748,6 +756,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
748
756
749
757
/// Prints the span with a note above it.
750
758
/// This is like [`Diag::note_once()`], but it gets its own span.
759
+ #[ rustc_lint_diagnostics]
751
760
pub fn span_note_once < S : Into < MultiSpan > > (
752
761
& mut self ,
753
762
sp : S ,
@@ -786,12 +795,14 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
786
795
} }
787
796
788
797
/// This is like [`Diag::help()`], but it's only printed once.
798
+ #[ rustc_lint_diagnostics]
789
799
pub fn help_once ( & mut self , msg : impl Into < SubdiagMessage > ) -> & mut Self {
790
800
self . sub ( Level :: OnceHelp , msg, MultiSpan :: new ( ) ) ;
791
801
self
792
802
}
793
803
794
804
/// Add a help message attached to this diagnostic with a customizable highlighted message.
805
+ #[ rustc_lint_diagnostics]
795
806
pub fn highlighted_help ( & mut self , msg : Vec < StringPart > ) -> & mut Self {
796
807
self . sub_with_highlights ( Level :: Help , msg, MultiSpan :: new ( ) ) ;
797
808
self
@@ -812,12 +823,14 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
812
823
/// Disallow attaching suggestions this diagnostic.
813
824
/// Any suggestions attached e.g. with the `span_suggestion_*` methods
814
825
/// (before and after the call to `disable_suggestions`) will be ignored.
826
+ #[ rustc_lint_diagnostics]
815
827
pub fn disable_suggestions ( & mut self ) -> & mut Self {
816
828
self . suggestions = Err ( SuggestionsDisabled ) ;
817
829
self
818
830
}
819
831
820
832
/// Helper for pushing to `self.suggestions`, if available (not disable).
833
+ #[ rustc_lint_diagnostics]
821
834
fn push_suggestion ( & mut self , suggestion : CodeSuggestion ) {
822
835
for subst in & suggestion. substitutions {
823
836
for part in & subst. parts {
@@ -838,6 +851,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
838
851
with_fn ! { with_multipart_suggestion,
839
852
/// Show a suggestion that has multiple parts to it.
840
853
/// In other words, multiple changes need to be applied as part of this suggestion.
854
+ #[ rustc_lint_diagnostics]
841
855
pub fn multipart_suggestion(
842
856
& mut self ,
843
857
msg: impl Into <SubdiagMessage >,
@@ -854,6 +868,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
854
868
855
869
/// Show a suggestion that has multiple parts to it, always as it's own subdiagnostic.
856
870
/// In other words, multiple changes need to be applied as part of this suggestion.
871
+ #[ rustc_lint_diagnostics]
857
872
pub fn multipart_suggestion_verbose (
858
873
& mut self ,
859
874
msg : impl Into < SubdiagMessage > ,
@@ -869,6 +884,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
869
884
}
870
885
871
886
/// [`Diag::multipart_suggestion()`] but you can set the [`SuggestionStyle`].
887
+ #[ rustc_lint_diagnostics]
872
888
pub fn multipart_suggestion_with_style (
873
889
& mut self ,
874
890
msg : impl Into < SubdiagMessage > ,
@@ -911,6 +927,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
911
927
/// be from the message, showing the span label inline would be visually unpleasant
912
928
/// (marginally overlapping spans or multiline spans) and showing the snippet window wouldn't
913
929
/// improve understandability.
930
+ #[ rustc_lint_diagnostics]
914
931
pub fn tool_only_multipart_suggestion (
915
932
& mut self ,
916
933
msg : impl Into < SubdiagMessage > ,
@@ -943,6 +960,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
943
960
/// * may contain a name of a function, variable, or type, but not whole expressions
944
961
///
945
962
/// See `CodeSuggestion` for more information.
963
+ #[ rustc_lint_diagnostics]
946
964
pub fn span_suggestion(
947
965
& mut self ,
948
966
sp: Span ,
@@ -961,6 +979,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
961
979
} }
962
980
963
981
/// [`Diag::span_suggestion()`] but you can set the [`SuggestionStyle`].
982
+ #[ rustc_lint_diagnostics]
964
983
pub fn span_suggestion_with_style (
965
984
& mut self ,
966
985
sp : Span ,
@@ -986,6 +1005,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
986
1005
987
1006
with_fn ! { with_span_suggestion_verbose,
988
1007
/// Always show the suggested change.
1008
+ #[ rustc_lint_diagnostics]
989
1009
pub fn span_suggestion_verbose(
990
1010
& mut self ,
991
1011
sp: Span ,
@@ -1006,6 +1026,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
1006
1026
with_fn ! { with_span_suggestions,
1007
1027
/// Prints out a message with multiple suggested edits of the code.
1008
1028
/// See also [`Diag::span_suggestion()`].
1029
+ #[ rustc_lint_diagnostics]
1009
1030
pub fn span_suggestions(
1010
1031
& mut self ,
1011
1032
sp: Span ,
@@ -1022,6 +1043,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
1022
1043
)
1023
1044
} }
1024
1045
1046
+ #[ rustc_lint_diagnostics]
1025
1047
pub fn span_suggestions_with_style (
1026
1048
& mut self ,
1027
1049
sp : Span ,
@@ -1052,6 +1074,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
1052
1074
/// Prints out a message with multiple suggested edits of the code, where each edit consists of
1053
1075
/// multiple parts.
1054
1076
/// See also [`Diag::multipart_suggestion()`].
1077
+ #[ rustc_lint_diagnostics]
1055
1078
pub fn multipart_suggestions (
1056
1079
& mut self ,
1057
1080
msg : impl Into < SubdiagMessage > ,
@@ -1098,6 +1121,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
1098
1121
/// inline, it will only show the message and not the suggestion.
1099
1122
///
1100
1123
/// See `CodeSuggestion` for more information.
1124
+ #[ rustc_lint_diagnostics]
1101
1125
pub fn span_suggestion_short(
1102
1126
& mut self ,
1103
1127
sp: Span ,
@@ -1121,6 +1145,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
1121
1145
/// be from the message, showing the span label inline would be visually unpleasant
1122
1146
/// (marginally overlapping spans or multiline spans) and showing the snippet window wouldn't
1123
1147
/// improve understandability.
1148
+ #[ rustc_lint_diagnostics]
1124
1149
pub fn span_suggestion_hidden (
1125
1150
& mut self ,
1126
1151
sp : Span ,
@@ -1165,6 +1190,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
1165
1190
/// [rustc_macros::Subdiagnostic]). Performs eager translation of any translatable messages
1166
1191
/// used in the subdiagnostic, so suitable for use with repeated messages (i.e. re-use of
1167
1192
/// interpolated variables).
1193
+ #[ rustc_lint_diagnostics]
1168
1194
pub fn subdiagnostic (
1169
1195
& mut self ,
1170
1196
dcx : & crate :: DiagCtxt ,
@@ -1180,6 +1206,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
1180
1206
1181
1207
with_fn ! { with_span,
1182
1208
/// Add a span.
1209
+ #[ rustc_lint_diagnostics]
1183
1210
pub fn span( & mut self , sp: impl Into <MultiSpan >) -> & mut Self {
1184
1211
self . span = sp. into( ) ;
1185
1212
if let Some ( span) = self . span. primary_span( ) {
@@ -1188,27 +1215,31 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
1188
1215
self
1189
1216
} }
1190
1217
1218
+ #[ rustc_lint_diagnostics]
1191
1219
pub fn is_lint ( & mut self , name : String , has_future_breakage : bool ) -> & mut Self {
1192
1220
self . is_lint = Some ( IsLint { name, has_future_breakage } ) ;
1193
1221
self
1194
1222
}
1195
1223
1196
1224
with_fn ! { with_code,
1197
1225
/// Add an error code.
1226
+ #[ rustc_lint_diagnostics]
1198
1227
pub fn code( & mut self , code: ErrCode ) -> & mut Self {
1199
1228
self . code = Some ( code) ;
1200
1229
self
1201
1230
} }
1202
1231
1203
1232
with_fn ! { with_primary_message,
1204
1233
/// Add a primary message.
1234
+ #[ rustc_lint_diagnostics]
1205
1235
pub fn primary_message( & mut self , msg: impl Into <DiagMessage >) -> & mut Self {
1206
1236
self . messages[ 0 ] = ( msg. into( ) , Style :: NoStyle ) ;
1207
1237
self
1208
1238
} }
1209
1239
1210
1240
with_fn ! { with_arg,
1211
1241
/// Add an argument.
1242
+ #[ rustc_lint_diagnostics]
1212
1243
pub fn arg(
1213
1244
& mut self ,
1214
1245
name: impl Into <DiagArgName >,
0 commit comments