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;
@@ -170,8 +170,7 @@ where
170170 ) ;
171171}
172172
173- pub trait SubdiagnosticMessageOp < G > =
174- Fn ( & mut Diag <' _, G >, SubdiagnosticMessage ) -> SubdiagnosticMessage ;
173+ pub trait SubdiagnosticMessageOp < G > = Fn ( & mut Diag <' _, G >, SubdiagMessage ) -> SubdiagMessage ;
175174
176175/// Trait implemented by lint types. This should not be implemented manually. Instead, use
177176/// `#[derive(LintDiagnostic)]` -- see [rustc_macros::LintDiagnostic].
@@ -377,7 +376,7 @@ impl DiagInner {
377376 // See comment on `Diag::subdiagnostic_message_to_diagnostic_message`.
378377 pub ( crate ) fn subdiagnostic_message_to_diagnostic_message (
379378 & self ,
380- attr : impl Into < SubdiagnosticMessage > ,
379+ attr : impl Into < SubdiagMessage > ,
381380 ) -> DiagMessage {
382381 let msg =
383382 self . messages . iter ( ) . map ( |( msg, _) | msg) . next ( ) . expect ( "diagnostic with no messages" ) ;
@@ -387,7 +386,7 @@ impl DiagInner {
387386 pub ( crate ) fn sub (
388387 & mut self ,
389388 level : Level ,
390- message : impl Into < SubdiagnosticMessage > ,
389+ message : impl Into < SubdiagMessage > ,
391390 span : MultiSpan ,
392391 ) {
393392 let sub = Subdiag {
@@ -604,7 +603,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
604603 /// ["primary span"][`MultiSpan`]; only the `Span` supplied when creating the diagnostic is
605604 /// primary.
606605 #[ 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 {
608607 let msg = self . subdiagnostic_message_to_diagnostic_message( label) ;
609608 self . span. push_span_label( span, msg) ;
610609 self
@@ -699,7 +698,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
699698 with_fn ! { with_note,
700699 /// Add a note attached to this diagnostic.
701700 #[ 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 {
703702 self . sub( Level :: Note , msg, MultiSpan :: new( ) ) ;
704703 self
705704 } }
@@ -710,7 +709,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
710709 }
711710
712711 /// 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 {
714713 self . sub ( Level :: OnceNote , msg, MultiSpan :: new ( ) ) ;
715714 self
716715 }
@@ -722,7 +721,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
722721 pub fn span_note(
723722 & mut self ,
724723 sp: impl Into <MultiSpan >,
725- msg: impl Into <SubdiagnosticMessage >,
724+ msg: impl Into <SubdiagMessage >,
726725 ) -> & mut Self {
727726 self . sub( Level :: Note , msg, sp. into( ) ) ;
728727 self
@@ -733,7 +732,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
733732 pub fn span_note_once < S : Into < MultiSpan > > (
734733 & mut self ,
735734 sp : S ,
736- msg : impl Into < SubdiagnosticMessage > ,
735+ msg : impl Into < SubdiagMessage > ,
737736 ) -> & mut Self {
738737 self . sub ( Level :: OnceNote , msg, sp. into ( ) ) ;
739738 self
@@ -742,7 +741,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
742741 with_fn ! { with_warn,
743742 /// Add a warning attached to this diagnostic.
744743 #[ 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 {
746745 self . sub( Level :: Warning , msg, MultiSpan :: new( ) ) ;
747746 self
748747 } }
@@ -753,7 +752,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
753752 pub fn span_warn < S : Into < MultiSpan > > (
754753 & mut self ,
755754 sp : S ,
756- msg : impl Into < SubdiagnosticMessage > ,
755+ msg : impl Into < SubdiagMessage > ,
757756 ) -> & mut Self {
758757 self . sub ( Level :: Warning , msg, sp. into ( ) ) ;
759758 self
@@ -762,13 +761,13 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
762761 with_fn ! { with_help,
763762 /// Add a help message attached to this diagnostic.
764763 #[ 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 {
766765 self . sub( Level :: Help , msg, MultiSpan :: new( ) ) ;
767766 self
768767 } }
769768
770769 /// 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 {
772771 self . sub ( Level :: OnceHelp , msg, MultiSpan :: new ( ) ) ;
773772 self
774773 }
@@ -785,7 +784,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
785784 pub fn span_help < S : Into < MultiSpan > > (
786785 & mut self ,
787786 sp : S ,
788- msg : impl Into < SubdiagnosticMessage > ,
787+ msg : impl Into < SubdiagMessage > ,
789788 ) -> & mut Self {
790789 self . sub ( Level :: Help , msg, sp. into ( ) ) ;
791790 self
@@ -822,7 +821,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
822821 /// In other words, multiple changes need to be applied as part of this suggestion.
823822 pub fn multipart_suggestion(
824823 & mut self ,
825- msg: impl Into <SubdiagnosticMessage >,
824+ msg: impl Into <SubdiagMessage >,
826825 suggestion: Vec <( Span , String ) >,
827826 applicability: Applicability ,
828827 ) -> & mut Self {
@@ -838,7 +837,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
838837 /// In other words, multiple changes need to be applied as part of this suggestion.
839838 pub fn multipart_suggestion_verbose (
840839 & mut self ,
841- msg : impl Into < SubdiagnosticMessage > ,
840+ msg : impl Into < SubdiagMessage > ,
842841 suggestion : Vec < ( Span , String ) > ,
843842 applicability : Applicability ,
844843 ) -> & mut Self {
@@ -853,7 +852,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
853852 /// [`Diag::multipart_suggestion()`] but you can set the [`SuggestionStyle`].
854853 pub fn multipart_suggestion_with_style (
855854 & mut self ,
856- msg : impl Into < SubdiagnosticMessage > ,
855+ msg : impl Into < SubdiagMessage > ,
857856 mut suggestion : Vec < ( Span , String ) > ,
858857 applicability : Applicability ,
859858 style : SuggestionStyle ,
@@ -895,7 +894,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
895894 /// improve understandability.
896895 pub fn tool_only_multipart_suggestion (
897896 & mut self ,
898- msg : impl Into < SubdiagnosticMessage > ,
897+ msg : impl Into < SubdiagMessage > ,
899898 suggestion : Vec < ( Span , String ) > ,
900899 applicability : Applicability ,
901900 ) -> & mut Self {
@@ -928,7 +927,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
928927 pub fn span_suggestion(
929928 & mut self ,
930929 sp: Span ,
931- msg: impl Into <SubdiagnosticMessage >,
930+ msg: impl Into <SubdiagMessage >,
932931 suggestion: impl ToString ,
933932 applicability: Applicability ,
934933 ) -> & mut Self {
@@ -946,7 +945,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
946945 pub fn span_suggestion_with_style (
947946 & mut self ,
948947 sp : Span ,
949- msg : impl Into < SubdiagnosticMessage > ,
948+ msg : impl Into < SubdiagMessage > ,
950949 suggestion : impl ToString ,
951950 applicability : Applicability ,
952951 style : SuggestionStyle ,
@@ -971,7 +970,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
971970 pub fn span_suggestion_verbose(
972971 & mut self ,
973972 sp: Span ,
974- msg: impl Into <SubdiagnosticMessage >,
973+ msg: impl Into <SubdiagMessage >,
975974 suggestion: impl ToString ,
976975 applicability: Applicability ,
977976 ) -> & mut Self {
@@ -991,7 +990,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
991990 pub fn span_suggestions(
992991 & mut self ,
993992 sp: Span ,
994- msg: impl Into <SubdiagnosticMessage >,
993+ msg: impl Into <SubdiagMessage >,
995994 suggestions: impl IntoIterator <Item = String >,
996995 applicability: Applicability ,
997996 ) -> & mut Self {
@@ -1007,7 +1006,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
10071006 pub fn span_suggestions_with_style (
10081007 & mut self ,
10091008 sp : Span ,
1010- msg : impl Into < SubdiagnosticMessage > ,
1009+ msg : impl Into < SubdiagMessage > ,
10111010 suggestions : impl IntoIterator < Item = String > ,
10121011 applicability : Applicability ,
10131012 style : SuggestionStyle ,
@@ -1036,7 +1035,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
10361035 /// See also [`Diag::multipart_suggestion()`].
10371036 pub fn multipart_suggestions (
10381037 & mut self ,
1039- msg : impl Into < SubdiagnosticMessage > ,
1038+ msg : impl Into < SubdiagMessage > ,
10401039 suggestions : impl IntoIterator < Item = Vec < ( Span , String ) > > ,
10411040 applicability : Applicability ,
10421041 ) -> & mut Self {
@@ -1083,7 +1082,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
10831082 pub fn span_suggestion_short(
10841083 & mut self ,
10851084 sp: Span ,
1086- msg: impl Into <SubdiagnosticMessage >,
1085+ msg: impl Into <SubdiagMessage >,
10871086 suggestion: impl ToString ,
10881087 applicability: Applicability ,
10891088 ) -> & mut Self {
@@ -1106,7 +1105,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
11061105 pub fn span_suggestion_hidden (
11071106 & mut self ,
11081107 sp : Span ,
1109- msg : impl Into < SubdiagnosticMessage > ,
1108+ msg : impl Into < SubdiagMessage > ,
11101109 suggestion : impl ToString ,
11111110 applicability : Applicability ,
11121111 ) -> & mut Self {
@@ -1129,7 +1128,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
11291128 pub fn tool_only_span_suggestion(
11301129 & mut self ,
11311130 sp: Span ,
1132- msg: impl Into <SubdiagnosticMessage >,
1131+ msg: impl Into <SubdiagMessage >,
11331132 suggestion: impl ToString ,
11341133 applicability: Applicability ,
11351134 ) -> & mut Self {
@@ -1200,12 +1199,12 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
12001199 self
12011200 } }
12021201
1203- /// Helper function that takes a `SubdiagnosticMessage ` and returns a `DiagMessage` by
1202+ /// Helper function that takes a `SubdiagMessage ` and returns a `DiagMessage` by
12041203 /// combining it with the primary message of the diagnostic (if translatable, otherwise it just
12051204 /// passes the user's string along).
12061205 pub ( crate ) fn subdiagnostic_message_to_diagnostic_message (
12071206 & self ,
1208- attr : impl Into < SubdiagnosticMessage > ,
1207+ attr : impl Into < SubdiagMessage > ,
12091208 ) -> DiagMessage {
12101209 self . deref ( ) . subdiagnostic_message_to_diagnostic_message ( attr)
12111210 }
@@ -1214,7 +1213,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
12141213 /// public methods above.
12151214 ///
12161215 /// 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 ) {
12181217 self . deref_mut ( ) . sub ( level, message, span) ;
12191218 }
12201219
0 commit comments