From 73fa217bc11fbac76f730223f6766c8e03513b5e Mon Sep 17 00:00:00 2001 From: David Wood Date: Tue, 26 Apr 2022 06:17:33 +0100 Subject: errors: `span_suggestion` takes `impl ToString` Change `span_suggestion` (and variants) to take `impl ToString` rather than `String` for the suggested code, as this simplifies the requirements on the diagnostic derive. Signed-off-by: David Wood --- compiler/rustc_errors/src/diagnostic.rs | 14 +++++++------- compiler/rustc_errors/src/diagnostic_builder.rs | 10 +++++----- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'compiler/rustc_errors/src') diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index cd17726c785..39cb71848eb 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -605,7 +605,7 @@ impl Diagnostic { &mut self, sp: Span, msg: impl Into, - suggestion: String, + suggestion: impl ToString, applicability: Applicability, ) -> &mut Self { self.span_suggestion_with_style( @@ -623,13 +623,13 @@ impl Diagnostic { &mut self, sp: Span, msg: impl Into, - suggestion: String, + suggestion: impl ToString, applicability: Applicability, style: SuggestionStyle, ) -> &mut Self { self.push_suggestion(CodeSuggestion { substitutions: vec![Substitution { - parts: vec![SubstitutionPart { snippet: suggestion, span: sp }], + parts: vec![SubstitutionPart { snippet: suggestion.to_string(), span: sp }], }], msg: msg.into(), style, @@ -643,7 +643,7 @@ impl Diagnostic { &mut self, sp: Span, msg: impl Into, - suggestion: String, + suggestion: impl ToString, applicability: Applicability, ) -> &mut Self { self.span_suggestion_with_style( @@ -711,7 +711,7 @@ impl Diagnostic { &mut self, sp: Span, msg: impl Into, - suggestion: String, + suggestion: impl ToString, applicability: Applicability, ) -> &mut Self { self.span_suggestion_with_style( @@ -734,7 +734,7 @@ impl Diagnostic { &mut self, sp: Span, msg: impl Into, - suggestion: String, + suggestion: impl ToString, applicability: Applicability, ) -> &mut Self { self.span_suggestion_with_style( @@ -755,7 +755,7 @@ impl Diagnostic { &mut self, sp: Span, msg: impl Into, - suggestion: String, + suggestion: impl ToString, applicability: Applicability, ) -> &mut Self { self.span_suggestion_with_style( diff --git a/compiler/rustc_errors/src/diagnostic_builder.rs b/compiler/rustc_errors/src/diagnostic_builder.rs index d2180408477..efc7693459f 100644 --- a/compiler/rustc_errors/src/diagnostic_builder.rs +++ b/compiler/rustc_errors/src/diagnostic_builder.rs @@ -477,7 +477,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> { &mut self, sp: Span, msg: impl Into, - suggestion: String, + suggestion: impl ToString, applicability: Applicability, ) -> &mut Self); forward!(pub fn span_suggestions( @@ -497,28 +497,28 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> { &mut self, sp: Span, msg: impl Into, - suggestion: String, + suggestion: impl ToString, applicability: Applicability, ) -> &mut Self); forward!(pub fn span_suggestion_verbose( &mut self, sp: Span, msg: impl Into, - suggestion: String, + suggestion: impl ToString, applicability: Applicability, ) -> &mut Self); forward!(pub fn span_suggestion_hidden( &mut self, sp: Span, msg: impl Into, - suggestion: String, + suggestion: impl ToString, applicability: Applicability, ) -> &mut Self); forward!(pub fn tool_only_span_suggestion( &mut self, sp: Span, msg: impl Into, - suggestion: String, + suggestion: impl ToString, applicability: Applicability, ) -> &mut Self); -- cgit 1.4.1-3-g733a5