diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2022-12-31 23:13:36 -0800 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2023-02-14 20:22:09 +0000 |
| commit | f02d8ec15eb430700b8181f4733b905e8e4ccca7 (patch) | |
| tree | 267af0e22ea166bcbd9c67e0e8a44d6fcfe9d65e /compiler/rustc_errors/src | |
| parent | 9bb6e60d1f1360234aae90c97964c0fa5524f141 (diff) | |
| download | rust-f02d8ec15eb430700b8181f4733b905e8e4ccca7.tar.gz rust-f02d8ec15eb430700b8181f4733b905e8e4ccca7.zip | |
More accurate spans for arg removal suggestion
Diffstat (limited to 'compiler/rustc_errors/src')
| -rw-r--r-- | compiler/rustc_errors/src/diagnostic.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_errors/src/emitter.rs | 3 |
2 files changed, 4 insertions, 2 deletions
diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index 9ed8ab67431..5b2786fbb17 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -612,7 +612,7 @@ impl Diagnostic { pub fn multipart_suggestion_with_style( &mut self, msg: impl Into<SubdiagnosticMessage>, - suggestion: Vec<(Span, String)>, + mut suggestion: Vec<(Span, String)>, applicability: Applicability, style: SuggestionStyle, ) -> &mut Self { @@ -634,6 +634,7 @@ impl Diagnostic { None, "suggestion must not have overlapping parts", ); + suggestion.sort_by_key(|(span, _)| (span.lo(), span.hi())); self.push_suggestion(CodeSuggestion { substitutions: vec![Substitution { parts }], diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index 4f2cc8b0351..211bbf4f50e 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -1768,7 +1768,7 @@ impl EmitterWriter { // Render the replacements for each suggestion let suggestions = suggestion.splice_lines(sm); - debug!("emit_suggestion_default: suggestions={:?}", suggestions); + debug!(?suggestions); if suggestions.is_empty() { // Suggestions coming from macros can have malformed spans. This is a heavy handed @@ -1797,6 +1797,7 @@ impl EmitterWriter { for (complete, parts, highlights, only_capitalization) in suggestions.iter().take(MAX_SUGGESTIONS) { + debug!(?complete, ?parts, ?highlights); notice_capitalization |= only_capitalization; let has_deletion = parts.iter().any(|p| p.is_deletion(sm)); |
