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