diff options
| author | Oliver Schneider <github35764891676564198441@oli-obk.de> | 2018-05-21 18:06:28 +0200 |
|---|---|---|
| committer | Oliver Schneider <github35764891676564198441@oli-obk.de> | 2018-05-21 18:06:28 +0200 |
| commit | af75ebdc3a4d01c62ae1af96931f6fa1b188b698 (patch) | |
| tree | 8766abb9fab6b5a44bde3e6323fc66cb64cde1b1 /src/librustc_errors | |
| parent | 00842d10cd703263833132867d59c85b343eb202 (diff) | |
| download | rust-af75ebdc3a4d01c62ae1af96931f6fa1b188b698.tar.gz rust-af75ebdc3a4d01c62ae1af96931f6fa1b188b698.zip | |
Improve the diagnostic around impl Trait <-> generic param mismatch
Diffstat (limited to 'src/librustc_errors')
| -rw-r--r-- | src/librustc_errors/diagnostic.rs | 19 | ||||
| -rw-r--r-- | src/librustc_errors/diagnostic_builder.rs | 5 |
2 files changed, 24 insertions, 0 deletions
diff --git a/src/librustc_errors/diagnostic.rs b/src/librustc_errors/diagnostic.rs index 75401f21862..81b32f436c8 100644 --- a/src/librustc_errors/diagnostic.rs +++ b/src/librustc_errors/diagnostic.rs @@ -259,6 +259,25 @@ impl Diagnostic { self } + pub fn multipart_suggestion( + &mut self, + msg: &str, + suggestion: Vec<(Span, String)>, + ) -> &mut Self { + self.suggestions.push(CodeSuggestion { + substitutions: vec![Substitution { + parts: suggestion + .into_iter() + .map(|(span, snippet)| SubstitutionPart { snippet, span }) + .collect(), + }], + msg: msg.to_owned(), + show_code_when_inline: true, + applicability: Applicability::Unspecified, + }); + self + } + /// Prints out a message with multiple suggested edits of the code. pub fn span_suggestions(&mut self, sp: Span, msg: &str, suggestions: Vec<String>) -> &mut Self { self.suggestions.push(CodeSuggestion { diff --git a/src/librustc_errors/diagnostic_builder.rs b/src/librustc_errors/diagnostic_builder.rs index 7e9ca8633a5..b813edadc57 100644 --- a/src/librustc_errors/diagnostic_builder.rs +++ b/src/librustc_errors/diagnostic_builder.rs @@ -178,6 +178,11 @@ impl<'a> DiagnosticBuilder<'a> { msg: &str, suggestion: String) -> &mut Self); + forward!(pub fn multipart_suggestion( + &mut self, + msg: &str, + suggestion: Vec<(Span, String)> + ) -> &mut Self); forward!(pub fn span_suggestion(&mut self, sp: Span, msg: &str, |
