diff options
Diffstat (limited to 'compiler/rustc_errors/src')
| -rw-r--r-- | compiler/rustc_errors/src/diagnostic.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index 470f318eb33..b379d17dc22 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -759,6 +759,9 @@ impl Diagnostic { suggestions: impl IntoIterator<Item = String>, applicability: Applicability, ) -> &mut Self { + let mut suggestions: Vec<_> = suggestions.into_iter().collect(); + suggestions.sort(); + self.span_suggestions_with_style( sp, msg, @@ -768,7 +771,9 @@ impl Diagnostic { ) } - /// [`Diagnostic::span_suggestions()`] but you can set the [`SuggestionStyle`]. + /// [`Diagnostic::span_suggestions()`] but you can set the [`SuggestionStyle`]. This version + /// *doesn't* sort the suggestions, so the caller has control of the order in which they are + /// presented. pub fn span_suggestions_with_style( &mut self, sp: Span, @@ -777,9 +782,7 @@ impl Diagnostic { applicability: Applicability, style: SuggestionStyle, ) -> &mut Self { - let mut suggestions: Vec<_> = suggestions.into_iter().collect(); - suggestions.sort(); - + let suggestions: Vec<_> = suggestions.into_iter().collect(); debug_assert!( !(sp.is_empty() && suggestions.iter().any(|suggestion| suggestion.is_empty())), "Span must not be empty and have no suggestion" |
