11use crate :: snippet:: Style ;
22use crate :: {
33 CodeSuggestion , DiagCtxt , DiagMessage , ErrCode , ErrorGuaranteed , ExplicitBug , Level , MultiSpan ,
4- StashKey , SubdiagnosticMessage , Substitution , SubstitutionPart , SuggestionStyle ,
4+ StashKey , SubdiagMessage , Substitution , SubstitutionPart , SuggestionStyle ,
55} ;
66use rustc_data_structures:: fx:: FxIndexMap ;
77use rustc_error_messages:: fluent_value_from_str_list_sep_by_and;
@@ -189,8 +189,7 @@ where
189189 ) ;
190190}
191191
192- pub trait SubdiagnosticMessageOp < G > =
193- Fn ( & mut Diag <' _, G >, SubdiagnosticMessage ) -> SubdiagnosticMessage ;
192+ pub trait SubdiagnosticMessageOp < G > = Fn ( & mut Diag <' _, G >, SubdiagMessage ) -> SubdiagMessage ;
194193
195194/// Trait implemented by lint types. This should not be implemented manually. Instead, use
196195/// `#[derive(LintDiagnostic)]` -- see [rustc_macros::LintDiagnostic].
@@ -396,7 +395,7 @@ impl DiagInner {
396395 // See comment on `Diag::subdiagnostic_message_to_diagnostic_message`.
397396 pub ( crate ) fn subdiagnostic_message_to_diagnostic_message (
398397 & self ,
399- attr : impl Into < SubdiagnosticMessage > ,
398+ attr : impl Into < SubdiagMessage > ,
400399 ) -> DiagMessage {
401400 let msg =
402401 self . messages . iter ( ) . map ( |( msg, _) | msg) . next ( ) . expect ( "diagnostic with no messages" ) ;
@@ -406,7 +405,7 @@ impl DiagInner {
406405 pub ( crate ) fn sub (
407406 & mut self ,
408407 level : Level ,
409- message : impl Into < SubdiagnosticMessage > ,
408+ message : impl Into < SubdiagMessage > ,
410409 span : MultiSpan ,
411410 ) {
412411 let sub = Subdiag {
@@ -623,7 +622,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
623622 /// ["primary span"][`MultiSpan`]; only the `Span` supplied when creating the diagnostic is
624623 /// primary.
625624 #[ 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 {
627626 let msg = self . subdiagnostic_message_to_diagnostic_message( label) ;
628627 self . span. push_span_label( span, msg) ;
629628 self
@@ -718,7 +717,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
718717 with_fn ! { with_note,
719718 /// Add a note attached to this diagnostic.
720719 #[ 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 {
722721 self . sub( Level :: Note , msg, MultiSpan :: new( ) ) ;
723722 self
724723 } }
@@ -729,7 +728,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
729728 }
730729
731730 /// 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 {
733732 self . sub ( Level :: OnceNote , msg, MultiSpan :: new ( ) ) ;
734733 self
735734 }
@@ -741,7 +740,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
741740 pub fn span_note(
742741 & mut self ,
743742 sp: impl Into <MultiSpan >,
744- msg: impl Into <SubdiagnosticMessage >,
743+ msg: impl Into <SubdiagMessage >,
745744 ) -> & mut Self {
746745 self . sub( Level :: Note , msg, sp. into( ) ) ;
747746 self
@@ -752,7 +751,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
752751 pub fn span_note_once < S : Into < MultiSpan > > (
753752 & mut self ,
754753 sp : S ,
755- msg : impl Into < SubdiagnosticMessage > ,
754+ msg : impl Into < SubdiagMessage > ,
756755 ) -> & mut Self {
757756 self . sub ( Level :: OnceNote , msg, sp. into ( ) ) ;
758757 self
@@ -761,7 +760,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
761760 with_fn ! { with_warn,
762761 /// Add a warning attached to this diagnostic.
763762 #[ 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 {
765764 self . sub( Level :: Warning , msg, MultiSpan :: new( ) ) ;
766765 self
767766 } }
@@ -772,7 +771,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
772771 pub fn span_warn < S : Into < MultiSpan > > (
773772 & mut self ,
774773 sp : S ,
775- msg : impl Into < SubdiagnosticMessage > ,
774+ msg : impl Into < SubdiagMessage > ,
776775 ) -> & mut Self {
777776 self . sub ( Level :: Warning , msg, sp. into ( ) ) ;
778777 self
@@ -781,13 +780,13 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
781780 with_fn ! { with_help,
782781 /// Add a help message attached to this diagnostic.
783782 #[ 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 {
785784 self . sub( Level :: Help , msg, MultiSpan :: new( ) ) ;
786785 self
787786 } }
788787
789788 /// 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 {
791790 self . sub ( Level :: OnceHelp , msg, MultiSpan :: new ( ) ) ;
792791 self
793792 }
@@ -804,7 +803,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
804803 pub fn span_help < S : Into < MultiSpan > > (
805804 & mut self ,
806805 sp : S ,
807- msg : impl Into < SubdiagnosticMessage > ,
806+ msg : impl Into < SubdiagMessage > ,
808807 ) -> & mut Self {
809808 self . sub ( Level :: Help , msg, sp. into ( ) ) ;
810809 self
@@ -841,7 +840,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
841840 /// In other words, multiple changes need to be applied as part of this suggestion.
842841 pub fn multipart_suggestion(
843842 & mut self ,
844- msg: impl Into <SubdiagnosticMessage >,
843+ msg: impl Into <SubdiagMessage >,
845844 suggestion: Vec <( Span , String ) >,
846845 applicability: Applicability ,
847846 ) -> & mut Self {
@@ -857,7 +856,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
857856 /// In other words, multiple changes need to be applied as part of this suggestion.
858857 pub fn multipart_suggestion_verbose (
859858 & mut self ,
860- msg : impl Into < SubdiagnosticMessage > ,
859+ msg : impl Into < SubdiagMessage > ,
861860 suggestion : Vec < ( Span , String ) > ,
862861 applicability : Applicability ,
863862 ) -> & mut Self {
@@ -872,7 +871,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
872871 /// [`Diag::multipart_suggestion()`] but you can set the [`SuggestionStyle`].
873872 pub fn multipart_suggestion_with_style (
874873 & mut self ,
875- msg : impl Into < SubdiagnosticMessage > ,
874+ msg : impl Into < SubdiagMessage > ,
876875 mut suggestion : Vec < ( Span , String ) > ,
877876 applicability : Applicability ,
878877 style : SuggestionStyle ,
@@ -914,7 +913,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
914913 /// improve understandability.
915914 pub fn tool_only_multipart_suggestion (
916915 & mut self ,
917- msg : impl Into < SubdiagnosticMessage > ,
916+ msg : impl Into < SubdiagMessage > ,
918917 suggestion : Vec < ( Span , String ) > ,
919918 applicability : Applicability ,
920919 ) -> & mut Self {
@@ -947,7 +946,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
947946 pub fn span_suggestion(
948947 & mut self ,
949948 sp: Span ,
950- msg: impl Into <SubdiagnosticMessage >,
949+ msg: impl Into <SubdiagMessage >,
951950 suggestion: impl ToString ,
952951 applicability: Applicability ,
953952 ) -> & mut Self {
@@ -965,7 +964,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
965964 pub fn span_suggestion_with_style (
966965 & mut self ,
967966 sp : Span ,
968- msg : impl Into < SubdiagnosticMessage > ,
967+ msg : impl Into < SubdiagMessage > ,
969968 suggestion : impl ToString ,
970969 applicability : Applicability ,
971970 style : SuggestionStyle ,
@@ -990,7 +989,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
990989 pub fn span_suggestion_verbose(
991990 & mut self ,
992991 sp: Span ,
993- msg: impl Into <SubdiagnosticMessage >,
992+ msg: impl Into <SubdiagMessage >,
994993 suggestion: impl ToString ,
995994 applicability: Applicability ,
996995 ) -> & mut Self {
@@ -1010,7 +1009,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
10101009 pub fn span_suggestions(
10111010 & mut self ,
10121011 sp: Span ,
1013- msg: impl Into <SubdiagnosticMessage >,
1012+ msg: impl Into <SubdiagMessage >,
10141013 suggestions: impl IntoIterator <Item = String >,
10151014 applicability: Applicability ,
10161015 ) -> & mut Self {
@@ -1026,7 +1025,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
10261025 pub fn span_suggestions_with_style (
10271026 & mut self ,
10281027 sp : Span ,
1029- msg : impl Into < SubdiagnosticMessage > ,
1028+ msg : impl Into < SubdiagMessage > ,
10301029 suggestions : impl IntoIterator < Item = String > ,
10311030 applicability : Applicability ,
10321031 style : SuggestionStyle ,
@@ -1055,7 +1054,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
10551054 /// See also [`Diag::multipart_suggestion()`].
10561055 pub fn multipart_suggestions (
10571056 & mut self ,
1058- msg : impl Into < SubdiagnosticMessage > ,
1057+ msg : impl Into < SubdiagMessage > ,
10591058 suggestions : impl IntoIterator < Item = Vec < ( Span , String ) > > ,
10601059 applicability : Applicability ,
10611060 ) -> & mut Self {
@@ -1102,7 +1101,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
11021101 pub fn span_suggestion_short(
11031102 & mut self ,
11041103 sp: Span ,
1105- msg: impl Into <SubdiagnosticMessage >,
1104+ msg: impl Into <SubdiagMessage >,
11061105 suggestion: impl ToString ,
11071106 applicability: Applicability ,
11081107 ) -> & mut Self {
@@ -1125,7 +1124,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
11251124 pub fn span_suggestion_hidden (
11261125 & mut self ,
11271126 sp : Span ,
1128- msg : impl Into < SubdiagnosticMessage > ,
1127+ msg : impl Into < SubdiagMessage > ,
11291128 suggestion : impl ToString ,
11301129 applicability : Applicability ,
11311130 ) -> & mut Self {
@@ -1148,7 +1147,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
11481147 pub fn tool_only_span_suggestion(
11491148 & mut self ,
11501149 sp: Span ,
1151- msg: impl Into <SubdiagnosticMessage >,
1150+ msg: impl Into <SubdiagMessage >,
11521151 suggestion: impl ToString ,
11531152 applicability: Applicability ,
11541153 ) -> & mut Self {
@@ -1219,12 +1218,12 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
12191218 self
12201219 } }
12211220
1222- /// Helper function that takes a `SubdiagnosticMessage ` and returns a `DiagMessage` by
1221+ /// Helper function that takes a `SubdiagMessage ` and returns a `DiagMessage` by
12231222 /// combining it with the primary message of the diagnostic (if translatable, otherwise it just
12241223 /// passes the user's string along).
12251224 pub ( crate ) fn subdiagnostic_message_to_diagnostic_message (
12261225 & self ,
1227- attr : impl Into < SubdiagnosticMessage > ,
1226+ attr : impl Into < SubdiagMessage > ,
12281227 ) -> DiagMessage {
12291228 self . deref ( ) . subdiagnostic_message_to_diagnostic_message ( attr)
12301229 }
@@ -1233,7 +1232,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
12331232 /// public methods above.
12341233 ///
12351234 /// 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 ) {
12371236 self . deref_mut ( ) . sub ( level, message, span) ;
12381237 }
12391238
0 commit comments