@@ -586,6 +586,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
586
586
///
587
587
/// In the meantime, though, callsites are required to deal with the "bug"
588
588
/// locally in whichever way makes the most sense.
589
+ #[ rustc_lint_diagnostics]
589
590
#[ track_caller]
590
591
pub fn downgrade_to_delayed_bug ( & mut self ) {
591
592
assert ! (
@@ -619,13 +620,15 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
619
620
with_fn ! { with_span_labels,
620
621
/// Labels all the given spans with the provided label.
621
622
/// See [`Self::span_label()`] for more information.
623
+ #[ rustc_lint_diagnostics]
622
624
pub fn span_labels( & mut self , spans: impl IntoIterator <Item = Span >, label: & str ) -> & mut Self {
623
625
for span in spans {
624
626
self . span_label( span, label. to_string( ) ) ;
625
627
}
626
628
self
627
629
} }
628
630
631
+ #[ rustc_lint_diagnostics]
629
632
pub fn replace_span_with ( & mut self , after : Span , keep_label : bool ) -> & mut Self {
630
633
let before = self . span . clone ( ) ;
631
634
self . span ( after) ;
@@ -641,6 +644,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
641
644
self
642
645
}
643
646
647
+ #[ rustc_lint_diagnostics]
644
648
pub fn note_expected_found (
645
649
& mut self ,
646
650
expected_label : & dyn fmt:: Display ,
@@ -651,6 +655,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
651
655
self . note_expected_found_extra ( expected_label, expected, found_label, found, & "" , & "" )
652
656
}
653
657
658
+ #[ rustc_lint_diagnostics]
654
659
pub fn note_expected_found_extra (
655
660
& mut self ,
656
661
expected_label : & dyn fmt:: Display ,
@@ -693,6 +698,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
693
698
self
694
699
}
695
700
701
+ #[ rustc_lint_diagnostics]
696
702
pub fn note_trait_signature ( & mut self , name : Symbol , signature : String ) -> & mut Self {
697
703
self . highlighted_note ( vec ! [
698
704
StringPart :: normal( format!( "`{name}` from trait: `" ) ) ,
@@ -710,12 +716,14 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
710
716
self
711
717
} }
712
718
719
+ #[ rustc_lint_diagnostics]
713
720
fn highlighted_note ( & mut self , msg : Vec < StringPart > ) -> & mut Self {
714
721
self . sub_with_highlights ( Level :: Note , msg, MultiSpan :: new ( ) ) ;
715
722
self
716
723
}
717
724
718
725
/// This is like [`DiagnosticBuilder::note()`], but it's only printed once.
726
+ #[ rustc_lint_diagnostics]
719
727
pub fn note_once ( & mut self , msg : impl Into < SubdiagnosticMessage > ) -> & mut Self {
720
728
self . sub ( Level :: OnceNote , msg, MultiSpan :: new ( ) ) ;
721
729
self
@@ -736,6 +744,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
736
744
737
745
/// Prints the span with a note above it.
738
746
/// This is like [`DiagnosticBuilder::note_once()`], but it gets its own span.
747
+ #[ rustc_lint_diagnostics]
739
748
pub fn span_note_once < S : Into < MultiSpan > > (
740
749
& mut self ,
741
750
sp : S ,
@@ -774,12 +783,14 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
774
783
} }
775
784
776
785
/// This is like [`DiagnosticBuilder::help()`], but it's only printed once.
786
+ #[ rustc_lint_diagnostics]
777
787
pub fn help_once ( & mut self , msg : impl Into < SubdiagnosticMessage > ) -> & mut Self {
778
788
self . sub ( Level :: OnceHelp , msg, MultiSpan :: new ( ) ) ;
779
789
self
780
790
}
781
791
782
792
/// Add a help message attached to this diagnostic with a customizable highlighted message.
793
+ #[ rustc_lint_diagnostics]
783
794
pub fn highlighted_help ( & mut self , msg : Vec < StringPart > ) -> & mut Self {
784
795
self . sub_with_highlights ( Level :: Help , msg, MultiSpan :: new ( ) ) ;
785
796
self
@@ -800,12 +811,14 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
800
811
/// Disallow attaching suggestions this diagnostic.
801
812
/// Any suggestions attached e.g. with the `span_suggestion_*` methods
802
813
/// (before and after the call to `disable_suggestions`) will be ignored.
814
+ #[ rustc_lint_diagnostics]
803
815
pub fn disable_suggestions ( & mut self ) -> & mut Self {
804
816
self . suggestions = Err ( SuggestionsDisabled ) ;
805
817
self
806
818
}
807
819
808
820
/// Helper for pushing to `self.suggestions`, if available (not disable).
821
+ #[ rustc_lint_diagnostics]
809
822
fn push_suggestion ( & mut self , suggestion : CodeSuggestion ) {
810
823
for subst in & suggestion. substitutions {
811
824
for part in & subst. parts {
@@ -826,6 +839,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
826
839
with_fn ! { with_multipart_suggestion,
827
840
/// Show a suggestion that has multiple parts to it.
828
841
/// In other words, multiple changes need to be applied as part of this suggestion.
842
+ #[ rustc_lint_diagnostics]
829
843
pub fn multipart_suggestion(
830
844
& mut self ,
831
845
msg: impl Into <SubdiagnosticMessage >,
@@ -842,6 +856,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
842
856
843
857
/// Show a suggestion that has multiple parts to it, always as it's own subdiagnostic.
844
858
/// In other words, multiple changes need to be applied as part of this suggestion.
859
+ #[ rustc_lint_diagnostics]
845
860
pub fn multipart_suggestion_verbose (
846
861
& mut self ,
847
862
msg : impl Into < SubdiagnosticMessage > ,
@@ -857,6 +872,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
857
872
}
858
873
859
874
/// [`DiagnosticBuilder::multipart_suggestion()`] but you can set the [`SuggestionStyle`].
875
+ #[ rustc_lint_diagnostics]
860
876
pub fn multipart_suggestion_with_style (
861
877
& mut self ,
862
878
msg : impl Into < SubdiagnosticMessage > ,
@@ -899,6 +915,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
899
915
/// be from the message, showing the span label inline would be visually unpleasant
900
916
/// (marginally overlapping spans or multiline spans) and showing the snippet window wouldn't
901
917
/// improve understandability.
918
+ #[ rustc_lint_diagnostics]
902
919
pub fn tool_only_multipart_suggestion (
903
920
& mut self ,
904
921
msg : impl Into < SubdiagnosticMessage > ,
@@ -931,6 +948,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
931
948
/// * may contain a name of a function, variable, or type, but not whole expressions
932
949
///
933
950
/// See `CodeSuggestion` for more information.
951
+ #[ rustc_lint_diagnostics]
934
952
pub fn span_suggestion(
935
953
& mut self ,
936
954
sp: Span ,
@@ -949,6 +967,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
949
967
} }
950
968
951
969
/// [`DiagnosticBuilder::span_suggestion()`] but you can set the [`SuggestionStyle`].
970
+ #[ rustc_lint_diagnostics]
952
971
pub fn span_suggestion_with_style (
953
972
& mut self ,
954
973
sp : Span ,
@@ -974,6 +993,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
974
993
975
994
with_fn ! { with_span_suggestion_verbose,
976
995
/// Always show the suggested change.
996
+ #[ rustc_lint_diagnostics]
977
997
pub fn span_suggestion_verbose(
978
998
& mut self ,
979
999
sp: Span ,
@@ -994,6 +1014,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
994
1014
with_fn ! { with_span_suggestions,
995
1015
/// Prints out a message with multiple suggested edits of the code.
996
1016
/// See also [`DiagnosticBuilder::span_suggestion()`].
1017
+ #[ rustc_lint_diagnostics]
997
1018
pub fn span_suggestions(
998
1019
& mut self ,
999
1020
sp: Span ,
@@ -1010,6 +1031,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
1010
1031
)
1011
1032
} }
1012
1033
1034
+ #[ rustc_lint_diagnostics]
1013
1035
pub fn span_suggestions_with_style (
1014
1036
& mut self ,
1015
1037
sp : Span ,
@@ -1040,6 +1062,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
1040
1062
/// Prints out a message with multiple suggested edits of the code, where each edit consists of
1041
1063
/// multiple parts.
1042
1064
/// See also [`DiagnosticBuilder::multipart_suggestion()`].
1065
+ #[ rustc_lint_diagnostics]
1043
1066
pub fn multipart_suggestions (
1044
1067
& mut self ,
1045
1068
msg : impl Into < SubdiagnosticMessage > ,
@@ -1086,6 +1109,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
1086
1109
/// inline, it will only show the message and not the suggestion.
1087
1110
///
1088
1111
/// See `CodeSuggestion` for more information.
1112
+ #[ rustc_lint_diagnostics]
1089
1113
pub fn span_suggestion_short(
1090
1114
& mut self ,
1091
1115
sp: Span ,
@@ -1109,6 +1133,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
1109
1133
/// be from the message, showing the span label inline would be visually unpleasant
1110
1134
/// (marginally overlapping spans or multiline spans) and showing the snippet window wouldn't
1111
1135
/// improve understandability.
1136
+ #[ rustc_lint_diagnostics]
1112
1137
pub fn span_suggestion_hidden (
1113
1138
& mut self ,
1114
1139
sp : Span ,
@@ -1153,6 +1178,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
1153
1178
/// [rustc_macros::Subdiagnostic]). Performs eager translation of any translatable messages
1154
1179
/// used in the subdiagnostic, so suitable for use with repeated messages (i.e. re-use of
1155
1180
/// interpolated variables).
1181
+ #[ rustc_lint_diagnostics]
1156
1182
pub fn subdiagnostic (
1157
1183
& mut self ,
1158
1184
dcx : & crate :: DiagCtxt ,
@@ -1168,6 +1194,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
1168
1194
1169
1195
with_fn ! { with_span,
1170
1196
/// Add a span.
1197
+ #[ rustc_lint_diagnostics]
1171
1198
pub fn span( & mut self , sp: impl Into <MultiSpan >) -> & mut Self {
1172
1199
self . span = sp. into( ) ;
1173
1200
if let Some ( span) = self . span. primary_span( ) {
@@ -1176,27 +1203,31 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
1176
1203
self
1177
1204
} }
1178
1205
1206
+ #[ rustc_lint_diagnostics]
1179
1207
pub fn is_lint ( & mut self , name : String , has_future_breakage : bool ) -> & mut Self {
1180
1208
self . is_lint = Some ( IsLint { name, has_future_breakage } ) ;
1181
1209
self
1182
1210
}
1183
1211
1184
1212
with_fn ! { with_code,
1185
1213
/// Add an error code.
1214
+ #[ rustc_lint_diagnostics]
1186
1215
pub fn code( & mut self , code: ErrCode ) -> & mut Self {
1187
1216
self . code = Some ( code) ;
1188
1217
self
1189
1218
} }
1190
1219
1191
1220
with_fn ! { with_primary_message,
1192
1221
/// Add a primary message.
1222
+ #[ rustc_lint_diagnostics]
1193
1223
pub fn primary_message( & mut self , msg: impl Into <DiagnosticMessage >) -> & mut Self {
1194
1224
self . messages[ 0 ] = ( msg. into( ) , Style :: NoStyle ) ;
1195
1225
self
1196
1226
} }
1197
1227
1198
1228
with_fn ! { with_arg,
1199
1229
/// Add an argument.
1230
+ #[ rustc_lint_diagnostics]
1200
1231
pub fn arg(
1201
1232
& mut self ,
1202
1233
name: impl Into <DiagnosticArgName >,
0 commit comments