about summary refs log tree commit diff
path: root/compiler/rustc_errors/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-10-24 22:26:41 +0000
committerbors <bors@rust-lang.org>2021-10-24 22:26:41 +0000
commit41d8c94d454f23239715a6433df79e46df8bce04 (patch)
tree1274a285d543abc005b1a19db06c0ed01e5083ff /compiler/rustc_errors/src
parent00d5e42e776da900049fe19087bc9b0057ec70cd (diff)
parent881a50c0b7c089831aaf403e9238f77deefe04c3 (diff)
downloadrust-41d8c94d454f23239715a6433df79e46df8bce04.tar.gz
rust-41d8c94d454f23239715a6433df79e46df8bce04.zip
Auto merge of #89427 - estebank:collect-overlapping-impls, r=jackh726
Point at overlapping impls when type annotations are needed

Address https://github.com/rust-lang/rust/issues/89254.
Diffstat (limited to 'compiler/rustc_errors/src')
-rw-r--r--compiler/rustc_errors/src/diagnostic.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs
index 41a73268f46..f2381d75c56 100644
--- a/compiler/rustc_errors/src/diagnostic.rs
+++ b/compiler/rustc_errors/src/diagnostic.rs
@@ -465,10 +465,14 @@ impl Diagnostic {
         suggestions: impl Iterator<Item = String>,
         applicability: Applicability,
     ) -> &mut Self {
+        let mut suggestions: Vec<_> = suggestions.collect();
+        suggestions.sort();
+        let substitutions = suggestions
+            .into_iter()
+            .map(|snippet| Substitution { parts: vec![SubstitutionPart { snippet, span: sp }] })
+            .collect();
         self.suggestions.push(CodeSuggestion {
-            substitutions: suggestions
-                .map(|snippet| Substitution { parts: vec![SubstitutionPart { snippet, span: sp }] })
-                .collect(),
+            substitutions,
             msg: msg.to_owned(),
             style: SuggestionStyle::ShowCode,
             applicability,