diff options
| author | David Wood <david.wood@huawei.com> | 2022-04-26 06:17:33 +0100 |
|---|---|---|
| committer | David Wood <david.wood@huawei.com> | 2022-04-29 02:05:20 +0100 |
| commit | 73fa217bc11fbac76f730223f6766c8e03513b5e (patch) | |
| tree | f3ea6722ec56cb9ae2188d69088c378b717544d7 /compiler/rustc_errors | |
| parent | baaa3b682986879c7784b5733ecea942e9ae7de3 (diff) | |
| download | rust-73fa217bc11fbac76f730223f6766c8e03513b5e.tar.gz rust-73fa217bc11fbac76f730223f6766c8e03513b5e.zip | |
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 <david.wood@huawei.com>
Diffstat (limited to 'compiler/rustc_errors')
| -rw-r--r-- | compiler/rustc_errors/src/diagnostic.rs | 14 | ||||
| -rw-r--r-- | compiler/rustc_errors/src/diagnostic_builder.rs | 10 |
2 files changed, 12 insertions, 12 deletions
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<DiagnosticMessage>, - 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<DiagnosticMessage>, - 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<DiagnosticMessage>, - 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<DiagnosticMessage>, - 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<DiagnosticMessage>, - 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<DiagnosticMessage>, - 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<DiagnosticMessage>, - 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<DiagnosticMessage>, - suggestion: String, + suggestion: impl ToString, applicability: Applicability, ) -> &mut Self); forward!(pub fn span_suggestion_verbose( &mut self, sp: Span, msg: impl Into<DiagnosticMessage>, - suggestion: String, + suggestion: impl ToString, applicability: Applicability, ) -> &mut Self); forward!(pub fn span_suggestion_hidden( &mut self, sp: Span, msg: impl Into<DiagnosticMessage>, - suggestion: String, + suggestion: impl ToString, applicability: Applicability, ) -> &mut Self); forward!(pub fn tool_only_span_suggestion( &mut self, sp: Span, msg: impl Into<DiagnosticMessage>, - suggestion: String, + suggestion: impl ToString, applicability: Applicability, ) -> &mut Self); |
