1
1
use crate :: snippet:: Style ;
2
2
use crate :: {
3
3
CodeSuggestion , DiagCtxt , DiagMessage , ErrCode , ErrorGuaranteed , ExplicitBug , Level , MultiSpan ,
4
- StashKey , SubdiagnosticMessage , Substitution , SubstitutionPart , SuggestionStyle ,
4
+ StashKey , SubdiagMessage , Substitution , SubstitutionPart , SuggestionStyle ,
5
5
} ;
6
6
use rustc_data_structures:: fx:: FxIndexMap ;
7
7
use rustc_error_messages:: fluent_value_from_str_list_sep_by_and;
@@ -189,8 +189,7 @@ where
189
189
) ;
190
190
}
191
191
192
- pub trait SubdiagnosticMessageOp < G > =
193
- Fn ( & mut Diag <' _, G >, SubdiagnosticMessage ) -> SubdiagnosticMessage ;
192
+ pub trait SubdiagnosticMessageOp < G > = Fn ( & mut Diag <' _, G >, SubdiagMessage ) -> SubdiagMessage ;
194
193
195
194
/// Trait implemented by lint types. This should not be implemented manually. Instead, use
196
195
/// `#[derive(LintDiagnostic)]` -- see [rustc_macros::LintDiagnostic].
@@ -396,7 +395,7 @@ impl DiagInner {
396
395
// See comment on `Diag::subdiagnostic_message_to_diagnostic_message`.
397
396
pub ( crate ) fn subdiagnostic_message_to_diagnostic_message (
398
397
& self ,
399
- attr : impl Into < SubdiagnosticMessage > ,
398
+ attr : impl Into < SubdiagMessage > ,
400
399
) -> DiagMessage {
401
400
let msg =
402
401
self . messages . iter ( ) . map ( |( msg, _) | msg) . next ( ) . expect ( "diagnostic with no messages" ) ;
@@ -406,7 +405,7 @@ impl DiagInner {
406
405
pub ( crate ) fn sub (
407
406
& mut self ,
408
407
level : Level ,
409
- message : impl Into < SubdiagnosticMessage > ,
408
+ message : impl Into < SubdiagMessage > ,
410
409
span : MultiSpan ,
411
410
) {
412
411
let sub = Subdiag {
@@ -623,7 +622,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
623
622
/// ["primary span"][`MultiSpan`]; only the `Span` supplied when creating the diagnostic is
624
623
/// primary.
625
624
#[ rustc_lint_diagnostics]
626
- pub fn span_label( & mut self , span: Span , label: impl Into <SubdiagnosticMessage >) -> & mut Self {
625
+ pub fn span_label( & mut self , span: Span , label: impl Into <SubdiagMessage >) -> & mut Self {
627
626
let msg = self . subdiagnostic_message_to_diagnostic_message( label) ;
628
627
self . span. push_span_label( span, msg) ;
629
628
self
@@ -718,7 +717,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
718
717
with_fn ! { with_note,
719
718
/// Add a note attached to this diagnostic.
720
719
#[ rustc_lint_diagnostics]
721
- pub fn note( & mut self , msg: impl Into <SubdiagnosticMessage >) -> & mut Self {
720
+ pub fn note( & mut self , msg: impl Into <SubdiagMessage >) -> & mut Self {
722
721
self . sub( Level :: Note , msg, MultiSpan :: new( ) ) ;
723
722
self
724
723
} }
@@ -729,7 +728,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
729
728
}
730
729
731
730
/// This is like [`Diag::note()`], but it's only printed once.
732
- pub fn note_once ( & mut self , msg : impl Into < SubdiagnosticMessage > ) -> & mut Self {
731
+ pub fn note_once ( & mut self , msg : impl Into < SubdiagMessage > ) -> & mut Self {
733
732
self . sub ( Level :: OnceNote , msg, MultiSpan :: new ( ) ) ;
734
733
self
735
734
}
@@ -741,7 +740,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
741
740
pub fn span_note(
742
741
& mut self ,
743
742
sp: impl Into <MultiSpan >,
744
- msg: impl Into <SubdiagnosticMessage >,
743
+ msg: impl Into <SubdiagMessage >,
745
744
) -> & mut Self {
746
745
self . sub( Level :: Note , msg, sp. into( ) ) ;
747
746
self
@@ -752,7 +751,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
752
751
pub fn span_note_once < S : Into < MultiSpan > > (
753
752
& mut self ,
754
753
sp : S ,
755
- msg : impl Into < SubdiagnosticMessage > ,
754
+ msg : impl Into < SubdiagMessage > ,
756
755
) -> & mut Self {
757
756
self . sub ( Level :: OnceNote , msg, sp. into ( ) ) ;
758
757
self
@@ -761,7 +760,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
761
760
with_fn ! { with_warn,
762
761
/// Add a warning attached to this diagnostic.
763
762
#[ rustc_lint_diagnostics]
764
- pub fn warn( & mut self , msg: impl Into <SubdiagnosticMessage >) -> & mut Self {
763
+ pub fn warn( & mut self , msg: impl Into <SubdiagMessage >) -> & mut Self {
765
764
self . sub( Level :: Warning , msg, MultiSpan :: new( ) ) ;
766
765
self
767
766
} }
@@ -772,7 +771,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
772
771
pub fn span_warn < S : Into < MultiSpan > > (
773
772
& mut self ,
774
773
sp : S ,
775
- msg : impl Into < SubdiagnosticMessage > ,
774
+ msg : impl Into < SubdiagMessage > ,
776
775
) -> & mut Self {
777
776
self . sub ( Level :: Warning , msg, sp. into ( ) ) ;
778
777
self
@@ -781,13 +780,13 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
781
780
with_fn ! { with_help,
782
781
/// Add a help message attached to this diagnostic.
783
782
#[ rustc_lint_diagnostics]
784
- pub fn help( & mut self , msg: impl Into <SubdiagnosticMessage >) -> & mut Self {
783
+ pub fn help( & mut self , msg: impl Into <SubdiagMessage >) -> & mut Self {
785
784
self . sub( Level :: Help , msg, MultiSpan :: new( ) ) ;
786
785
self
787
786
} }
788
787
789
788
/// This is like [`Diag::help()`], but it's only printed once.
790
- pub fn help_once ( & mut self , msg : impl Into < SubdiagnosticMessage > ) -> & mut Self {
789
+ pub fn help_once ( & mut self , msg : impl Into < SubdiagMessage > ) -> & mut Self {
791
790
self . sub ( Level :: OnceHelp , msg, MultiSpan :: new ( ) ) ;
792
791
self
793
792
}
@@ -804,7 +803,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
804
803
pub fn span_help < S : Into < MultiSpan > > (
805
804
& mut self ,
806
805
sp : S ,
807
- msg : impl Into < SubdiagnosticMessage > ,
806
+ msg : impl Into < SubdiagMessage > ,
808
807
) -> & mut Self {
809
808
self . sub ( Level :: Help , msg, sp. into ( ) ) ;
810
809
self
@@ -841,7 +840,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
841
840
/// In other words, multiple changes need to be applied as part of this suggestion.
842
841
pub fn multipart_suggestion(
843
842
& mut self ,
844
- msg: impl Into <SubdiagnosticMessage >,
843
+ msg: impl Into <SubdiagMessage >,
845
844
suggestion: Vec <( Span , String ) >,
846
845
applicability: Applicability ,
847
846
) -> & mut Self {
@@ -857,7 +856,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
857
856
/// In other words, multiple changes need to be applied as part of this suggestion.
858
857
pub fn multipart_suggestion_verbose (
859
858
& mut self ,
860
- msg : impl Into < SubdiagnosticMessage > ,
859
+ msg : impl Into < SubdiagMessage > ,
861
860
suggestion : Vec < ( Span , String ) > ,
862
861
applicability : Applicability ,
863
862
) -> & mut Self {
@@ -872,7 +871,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
872
871
/// [`Diag::multipart_suggestion()`] but you can set the [`SuggestionStyle`].
873
872
pub fn multipart_suggestion_with_style (
874
873
& mut self ,
875
- msg : impl Into < SubdiagnosticMessage > ,
874
+ msg : impl Into < SubdiagMessage > ,
876
875
mut suggestion : Vec < ( Span , String ) > ,
877
876
applicability : Applicability ,
878
877
style : SuggestionStyle ,
@@ -914,7 +913,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
914
913
/// improve understandability.
915
914
pub fn tool_only_multipart_suggestion (
916
915
& mut self ,
917
- msg : impl Into < SubdiagnosticMessage > ,
916
+ msg : impl Into < SubdiagMessage > ,
918
917
suggestion : Vec < ( Span , String ) > ,
919
918
applicability : Applicability ,
920
919
) -> & mut Self {
@@ -947,7 +946,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
947
946
pub fn span_suggestion(
948
947
& mut self ,
949
948
sp: Span ,
950
- msg: impl Into <SubdiagnosticMessage >,
949
+ msg: impl Into <SubdiagMessage >,
951
950
suggestion: impl ToString ,
952
951
applicability: Applicability ,
953
952
) -> & mut Self {
@@ -965,7 +964,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
965
964
pub fn span_suggestion_with_style (
966
965
& mut self ,
967
966
sp : Span ,
968
- msg : impl Into < SubdiagnosticMessage > ,
967
+ msg : impl Into < SubdiagMessage > ,
969
968
suggestion : impl ToString ,
970
969
applicability : Applicability ,
971
970
style : SuggestionStyle ,
@@ -990,7 +989,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
990
989
pub fn span_suggestion_verbose(
991
990
& mut self ,
992
991
sp: Span ,
993
- msg: impl Into <SubdiagnosticMessage >,
992
+ msg: impl Into <SubdiagMessage >,
994
993
suggestion: impl ToString ,
995
994
applicability: Applicability ,
996
995
) -> & mut Self {
@@ -1010,7 +1009,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
1010
1009
pub fn span_suggestions(
1011
1010
& mut self ,
1012
1011
sp: Span ,
1013
- msg: impl Into <SubdiagnosticMessage >,
1012
+ msg: impl Into <SubdiagMessage >,
1014
1013
suggestions: impl IntoIterator <Item = String >,
1015
1014
applicability: Applicability ,
1016
1015
) -> & mut Self {
@@ -1026,7 +1025,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
1026
1025
pub fn span_suggestions_with_style (
1027
1026
& mut self ,
1028
1027
sp : Span ,
1029
- msg : impl Into < SubdiagnosticMessage > ,
1028
+ msg : impl Into < SubdiagMessage > ,
1030
1029
suggestions : impl IntoIterator < Item = String > ,
1031
1030
applicability : Applicability ,
1032
1031
style : SuggestionStyle ,
@@ -1055,7 +1054,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
1055
1054
/// See also [`Diag::multipart_suggestion()`].
1056
1055
pub fn multipart_suggestions (
1057
1056
& mut self ,
1058
- msg : impl Into < SubdiagnosticMessage > ,
1057
+ msg : impl Into < SubdiagMessage > ,
1059
1058
suggestions : impl IntoIterator < Item = Vec < ( Span , String ) > > ,
1060
1059
applicability : Applicability ,
1061
1060
) -> & mut Self {
@@ -1102,7 +1101,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
1102
1101
pub fn span_suggestion_short(
1103
1102
& mut self ,
1104
1103
sp: Span ,
1105
- msg: impl Into <SubdiagnosticMessage >,
1104
+ msg: impl Into <SubdiagMessage >,
1106
1105
suggestion: impl ToString ,
1107
1106
applicability: Applicability ,
1108
1107
) -> & mut Self {
@@ -1125,7 +1124,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
1125
1124
pub fn span_suggestion_hidden (
1126
1125
& mut self ,
1127
1126
sp : Span ,
1128
- msg : impl Into < SubdiagnosticMessage > ,
1127
+ msg : impl Into < SubdiagMessage > ,
1129
1128
suggestion : impl ToString ,
1130
1129
applicability : Applicability ,
1131
1130
) -> & mut Self {
@@ -1148,7 +1147,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
1148
1147
pub fn tool_only_span_suggestion(
1149
1148
& mut self ,
1150
1149
sp: Span ,
1151
- msg: impl Into <SubdiagnosticMessage >,
1150
+ msg: impl Into <SubdiagMessage >,
1152
1151
suggestion: impl ToString ,
1153
1152
applicability: Applicability ,
1154
1153
) -> & mut Self {
@@ -1219,12 +1218,12 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
1219
1218
self
1220
1219
} }
1221
1220
1222
- /// Helper function that takes a `SubdiagnosticMessage ` and returns a `DiagMessage` by
1221
+ /// Helper function that takes a `SubdiagMessage ` and returns a `DiagMessage` by
1223
1222
/// combining it with the primary message of the diagnostic (if translatable, otherwise it just
1224
1223
/// passes the user's string along).
1225
1224
pub ( crate ) fn subdiagnostic_message_to_diagnostic_message (
1226
1225
& self ,
1227
- attr : impl Into < SubdiagnosticMessage > ,
1226
+ attr : impl Into < SubdiagMessage > ,
1228
1227
) -> DiagMessage {
1229
1228
self . deref ( ) . subdiagnostic_message_to_diagnostic_message ( attr)
1230
1229
}
@@ -1233,7 +1232,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
1233
1232
/// public methods above.
1234
1233
///
1235
1234
/// Used by `proc_macro_server` for implementing `server::Diagnostic`.
1236
- pub fn sub ( & mut self , level : Level , message : impl Into < SubdiagnosticMessage > , span : MultiSpan ) {
1235
+ pub fn sub ( & mut self , level : Level , message : impl Into < SubdiagMessage > , span : MultiSpan ) {
1237
1236
self . deref_mut ( ) . sub ( level, message, span) ;
1238
1237
}
1239
1238
0 commit comments