Rollup merge of #118057 - bvanjoi:fix-118048, r=cjgillot
dedup for duplicate suggestions Fixes #118048 An easy fix.
This commit is contained in:
commit
0865eefcaf
3 changed files with 36 additions and 4 deletions
|
@ -591,17 +591,18 @@ 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 {
|
||||
let mut parts = suggestion
|
||||
suggestion.sort_unstable();
|
||||
suggestion.dedup();
|
||||
|
||||
let parts = suggestion
|
||||
.into_iter()
|
||||
.map(|(span, snippet)| SubstitutionPart { snippet, span })
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
parts.sort_unstable_by_key(|part| part.span);
|
||||
|
||||
assert!(!parts.is_empty());
|
||||
debug_assert_eq!(
|
||||
parts.iter().find(|part| part.span.is_empty() && part.snippet.is_empty()),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue