diff options
| author | bors <bors@rust-lang.org> | 2023-11-19 20:58:16 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-11-19 20:58:16 +0000 |
| commit | 9a66e4471f71283fd54d80ef8147630d34756332 (patch) | |
| tree | 5dc489c7f92efe10824608139e0588be6dc29ea3 /compiler/rustc_errors | |
| parent | d19980e1ce9cde530240ed9d42ab54bb79ce8b40 (diff) | |
| parent | ac56b06b44c3aeb2d64c7ea6caf08973e4892637 (diff) | |
| download | rust-9a66e4471f71283fd54d80ef8147630d34756332.tar.gz rust-9a66e4471f71283fd54d80ef8147630d34756332.zip | |
Auto merge of #117683 - estebank:priv-builder-sugg, r=cjgillot
When encountering struct fn call literal with private fields, suggest all builders When encountering code like `Box(42)`, suggest `Box::new(42)` and *all* other associated functions that return `-> Box<T>`. Add a way to give pre-sorted suggestions.
Diffstat (limited to 'compiler/rustc_errors')
| -rw-r--r-- | compiler/rustc_errors/src/diagnostic.rs | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index 470f318eb33..0aaa8ae69e1 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -777,17 +777,15 @@ impl Diagnostic { applicability: Applicability, style: SuggestionStyle, ) -> &mut Self { - let mut suggestions: Vec<_> = suggestions.into_iter().collect(); - suggestions.sort(); - - debug_assert!( - !(sp.is_empty() && suggestions.iter().any(|suggestion| suggestion.is_empty())), - "Span must not be empty and have no suggestion" - ); - let substitutions = suggestions .into_iter() - .map(|snippet| Substitution { parts: vec![SubstitutionPart { snippet, span: sp }] }) + .map(|snippet| { + debug_assert!( + !(sp.is_empty() && snippet.is_empty()), + "Span must not be empty and have no suggestion" + ); + Substitution { parts: vec![SubstitutionPart { snippet, span: sp }] } + }) .collect(); self.push_suggestion(CodeSuggestion { substitutions, |
