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;
@@ -170,8 +170,7 @@ where
170
170
) ;
171
171
}
172
172
173
- pub trait SubdiagnosticMessageOp < G > =
174
- Fn ( & mut Diag <' _, G >, SubdiagnosticMessage ) -> SubdiagnosticMessage ;
173
+ pub trait SubdiagnosticMessageOp < G > = Fn ( & mut Diag <' _, G >, SubdiagMessage ) -> SubdiagMessage ;
175
174
176
175
/// Trait implemented by lint types. This should not be implemented manually. Instead, use
177
176
/// `#[derive(LintDiagnostic)]` -- see [rustc_macros::LintDiagnostic].
@@ -377,7 +376,7 @@ impl DiagInner {
377
376
// See comment on `Diag::subdiagnostic_message_to_diagnostic_message`.
378
377
pub ( crate ) fn subdiagnostic_message_to_diagnostic_message (
379
378
& self ,
380
- attr : impl Into < SubdiagnosticMessage > ,
379
+ attr : impl Into < SubdiagMessage > ,
381
380
) -> DiagMessage {
382
381
let msg =
383
382
self . messages . iter ( ) . map ( |( msg, _) | msg) . next ( ) . expect ( "diagnostic with no messages" ) ;
@@ -387,7 +386,7 @@ impl DiagInner {
387
386
pub ( crate ) fn sub (
388
387
& mut self ,
389
388
level : Level ,
390
- message : impl Into < SubdiagnosticMessage > ,
389
+ message : impl Into < SubdiagMessage > ,
391
390
span : MultiSpan ,
392
391
) {
393
392
let sub = Subdiag {
@@ -604,7 +603,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
604
603
/// ["primary span"][`MultiSpan`]; only the `Span` supplied when creating the diagnostic is
605
604
/// primary.
606
605
#[ rustc_lint_diagnostics]
607
- pub fn span_label( & mut self , span: Span , label: impl Into <SubdiagnosticMessage >) -> & mut Self {
606
+ pub fn span_label( & mut self , span: Span , label: impl Into <SubdiagMessage >) -> & mut Self {
608
607
let msg = self . subdiagnostic_message_to_diagnostic_message( label) ;
609
608
self . span. push_span_label( span, msg) ;
610
609
self
@@ -699,7 +698,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
699
698
with_fn ! { with_note,
700
699
/// Add a note attached to this diagnostic.
701
700
#[ rustc_lint_diagnostics]
702
- pub fn note( & mut self , msg: impl Into <SubdiagnosticMessage >) -> & mut Self {
701
+ pub fn note( & mut self , msg: impl Into <SubdiagMessage >) -> & mut Self {
703
702
self . sub( Level :: Note , msg, MultiSpan :: new( ) ) ;
704
703
self
705
704
} }
@@ -710,7 +709,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
710
709
}
711
710
712
711
/// This is like [`Diag::note()`], but it's only printed once.
713
- pub fn note_once ( & mut self , msg : impl Into < SubdiagnosticMessage > ) -> & mut Self {
712
+ pub fn note_once ( & mut self , msg : impl Into < SubdiagMessage > ) -> & mut Self {
714
713
self . sub ( Level :: OnceNote , msg, MultiSpan :: new ( ) ) ;
715
714
self
716
715
}
@@ -722,7 +721,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
722
721
pub fn span_note(
723
722
& mut self ,
724
723
sp: impl Into <MultiSpan >,
725
- msg: impl Into <SubdiagnosticMessage >,
724
+ msg: impl Into <SubdiagMessage >,
726
725
) -> & mut Self {
727
726
self . sub( Level :: Note , msg, sp. into( ) ) ;
728
727
self
@@ -733,7 +732,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
733
732
pub fn span_note_once < S : Into < MultiSpan > > (
734
733
& mut self ,
735
734
sp : S ,
736
- msg : impl Into < SubdiagnosticMessage > ,
735
+ msg : impl Into < SubdiagMessage > ,
737
736
) -> & mut Self {
738
737
self . sub ( Level :: OnceNote , msg, sp. into ( ) ) ;
739
738
self
@@ -742,7 +741,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
742
741
with_fn ! { with_warn,
743
742
/// Add a warning attached to this diagnostic.
744
743
#[ rustc_lint_diagnostics]
745
- pub fn warn( & mut self , msg: impl Into <SubdiagnosticMessage >) -> & mut Self {
744
+ pub fn warn( & mut self , msg: impl Into <SubdiagMessage >) -> & mut Self {
746
745
self . sub( Level :: Warning , msg, MultiSpan :: new( ) ) ;
747
746
self
748
747
} }
@@ -753,7 +752,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
753
752
pub fn span_warn < S : Into < MultiSpan > > (
754
753
& mut self ,
755
754
sp : S ,
756
- msg : impl Into < SubdiagnosticMessage > ,
755
+ msg : impl Into < SubdiagMessage > ,
757
756
) -> & mut Self {
758
757
self . sub ( Level :: Warning , msg, sp. into ( ) ) ;
759
758
self
@@ -762,13 +761,13 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
762
761
with_fn ! { with_help,
763
762
/// Add a help message attached to this diagnostic.
764
763
#[ rustc_lint_diagnostics]
765
- pub fn help( & mut self , msg: impl Into <SubdiagnosticMessage >) -> & mut Self {
764
+ pub fn help( & mut self , msg: impl Into <SubdiagMessage >) -> & mut Self {
766
765
self . sub( Level :: Help , msg, MultiSpan :: new( ) ) ;
767
766
self
768
767
} }
769
768
770
769
/// This is like [`Diag::help()`], but it's only printed once.
771
- pub fn help_once ( & mut self , msg : impl Into < SubdiagnosticMessage > ) -> & mut Self {
770
+ pub fn help_once ( & mut self , msg : impl Into < SubdiagMessage > ) -> & mut Self {
772
771
self . sub ( Level :: OnceHelp , msg, MultiSpan :: new ( ) ) ;
773
772
self
774
773
}
@@ -785,7 +784,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
785
784
pub fn span_help < S : Into < MultiSpan > > (
786
785
& mut self ,
787
786
sp : S ,
788
- msg : impl Into < SubdiagnosticMessage > ,
787
+ msg : impl Into < SubdiagMessage > ,
789
788
) -> & mut Self {
790
789
self . sub ( Level :: Help , msg, sp. into ( ) ) ;
791
790
self
@@ -822,7 +821,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
822
821
/// In other words, multiple changes need to be applied as part of this suggestion.
823
822
pub fn multipart_suggestion(
824
823
& mut self ,
825
- msg: impl Into <SubdiagnosticMessage >,
824
+ msg: impl Into <SubdiagMessage >,
826
825
suggestion: Vec <( Span , String ) >,
827
826
applicability: Applicability ,
828
827
) -> & mut Self {
@@ -838,7 +837,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
838
837
/// In other words, multiple changes need to be applied as part of this suggestion.
839
838
pub fn multipart_suggestion_verbose (
840
839
& mut self ,
841
- msg : impl Into < SubdiagnosticMessage > ,
840
+ msg : impl Into < SubdiagMessage > ,
842
841
suggestion : Vec < ( Span , String ) > ,
843
842
applicability : Applicability ,
844
843
) -> & mut Self {
@@ -853,7 +852,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
853
852
/// [`Diag::multipart_suggestion()`] but you can set the [`SuggestionStyle`].
854
853
pub fn multipart_suggestion_with_style (
855
854
& mut self ,
856
- msg : impl Into < SubdiagnosticMessage > ,
855
+ msg : impl Into < SubdiagMessage > ,
857
856
mut suggestion : Vec < ( Span , String ) > ,
858
857
applicability : Applicability ,
859
858
style : SuggestionStyle ,
@@ -895,7 +894,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
895
894
/// improve understandability.
896
895
pub fn tool_only_multipart_suggestion (
897
896
& mut self ,
898
- msg : impl Into < SubdiagnosticMessage > ,
897
+ msg : impl Into < SubdiagMessage > ,
899
898
suggestion : Vec < ( Span , String ) > ,
900
899
applicability : Applicability ,
901
900
) -> & mut Self {
@@ -928,7 +927,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
928
927
pub fn span_suggestion(
929
928
& mut self ,
930
929
sp: Span ,
931
- msg: impl Into <SubdiagnosticMessage >,
930
+ msg: impl Into <SubdiagMessage >,
932
931
suggestion: impl ToString ,
933
932
applicability: Applicability ,
934
933
) -> & mut Self {
@@ -946,7 +945,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
946
945
pub fn span_suggestion_with_style (
947
946
& mut self ,
948
947
sp : Span ,
949
- msg : impl Into < SubdiagnosticMessage > ,
948
+ msg : impl Into < SubdiagMessage > ,
950
949
suggestion : impl ToString ,
951
950
applicability : Applicability ,
952
951
style : SuggestionStyle ,
@@ -971,7 +970,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
971
970
pub fn span_suggestion_verbose(
972
971
& mut self ,
973
972
sp: Span ,
974
- msg: impl Into <SubdiagnosticMessage >,
973
+ msg: impl Into <SubdiagMessage >,
975
974
suggestion: impl ToString ,
976
975
applicability: Applicability ,
977
976
) -> & mut Self {
@@ -991,7 +990,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
991
990
pub fn span_suggestions(
992
991
& mut self ,
993
992
sp: Span ,
994
- msg: impl Into <SubdiagnosticMessage >,
993
+ msg: impl Into <SubdiagMessage >,
995
994
suggestions: impl IntoIterator <Item = String >,
996
995
applicability: Applicability ,
997
996
) -> & mut Self {
@@ -1007,7 +1006,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
1007
1006
pub fn span_suggestions_with_style (
1008
1007
& mut self ,
1009
1008
sp : Span ,
1010
- msg : impl Into < SubdiagnosticMessage > ,
1009
+ msg : impl Into < SubdiagMessage > ,
1011
1010
suggestions : impl IntoIterator < Item = String > ,
1012
1011
applicability : Applicability ,
1013
1012
style : SuggestionStyle ,
@@ -1036,7 +1035,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
1036
1035
/// See also [`Diag::multipart_suggestion()`].
1037
1036
pub fn multipart_suggestions (
1038
1037
& mut self ,
1039
- msg : impl Into < SubdiagnosticMessage > ,
1038
+ msg : impl Into < SubdiagMessage > ,
1040
1039
suggestions : impl IntoIterator < Item = Vec < ( Span , String ) > > ,
1041
1040
applicability : Applicability ,
1042
1041
) -> & mut Self {
@@ -1083,7 +1082,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
1083
1082
pub fn span_suggestion_short(
1084
1083
& mut self ,
1085
1084
sp: Span ,
1086
- msg: impl Into <SubdiagnosticMessage >,
1085
+ msg: impl Into <SubdiagMessage >,
1087
1086
suggestion: impl ToString ,
1088
1087
applicability: Applicability ,
1089
1088
) -> & mut Self {
@@ -1106,7 +1105,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
1106
1105
pub fn span_suggestion_hidden (
1107
1106
& mut self ,
1108
1107
sp : Span ,
1109
- msg : impl Into < SubdiagnosticMessage > ,
1108
+ msg : impl Into < SubdiagMessage > ,
1110
1109
suggestion : impl ToString ,
1111
1110
applicability : Applicability ,
1112
1111
) -> & mut Self {
@@ -1129,7 +1128,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
1129
1128
pub fn tool_only_span_suggestion(
1130
1129
& mut self ,
1131
1130
sp: Span ,
1132
- msg: impl Into <SubdiagnosticMessage >,
1131
+ msg: impl Into <SubdiagMessage >,
1133
1132
suggestion: impl ToString ,
1134
1133
applicability: Applicability ,
1135
1134
) -> & mut Self {
@@ -1200,12 +1199,12 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
1200
1199
self
1201
1200
} }
1202
1201
1203
- /// Helper function that takes a `SubdiagnosticMessage ` and returns a `DiagMessage` by
1202
+ /// Helper function that takes a `SubdiagMessage ` and returns a `DiagMessage` by
1204
1203
/// combining it with the primary message of the diagnostic (if translatable, otherwise it just
1205
1204
/// passes the user's string along).
1206
1205
pub ( crate ) fn subdiagnostic_message_to_diagnostic_message (
1207
1206
& self ,
1208
- attr : impl Into < SubdiagnosticMessage > ,
1207
+ attr : impl Into < SubdiagMessage > ,
1209
1208
) -> DiagMessage {
1210
1209
self . deref ( ) . subdiagnostic_message_to_diagnostic_message ( attr)
1211
1210
}
@@ -1214,7 +1213,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
1214
1213
/// public methods above.
1215
1214
///
1216
1215
/// Used by `proc_macro_server` for implementing `server::Diagnostic`.
1217
- pub fn sub ( & mut self , level : Level , message : impl Into < SubdiagnosticMessage > , span : MultiSpan ) {
1216
+ pub fn sub ( & mut self , level : Level , message : impl Into < SubdiagMessage > , span : MultiSpan ) {
1218
1217
self . deref_mut ( ) . sub ( level, message, span) ;
1219
1218
}
1220
1219
0 commit comments