about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorEsteban Kuber <esteban@kuber.com.ar>2021-10-01 18:09:31 +0000
committerEsteban Kuber <esteban@kuber.com.ar>2021-10-24 20:28:44 +0000
commit881a50c0b7c089831aaf403e9238f77deefe04c3 (patch)
tree04b573fdb2b107f1e8205a863e47dcccdb7faa7f /compiler
parentef212e7fb306626b4dc2c484aa3cf3b42a83e83a (diff)
downloadrust-881a50c0b7c089831aaf403e9238f77deefe04c3.tar.gz
rust-881a50c0b7c089831aaf403e9238f77deefe04c3.zip
Always sort suggestions before emitting them
Diffstat (limited to 'compiler')
-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,