Skip to content

Commit

Permalink
Rollup merge of #100970 - Xiretza:derive-multipart-suggestion, r=davi…
Browse files Browse the repository at this point in the history
…dtwco

Allow deriving multipart suggestions

This turned into a bit more of a rewrite than I was initially hoping for... Still, I think the `SessionSubdiagnostic` derive is a little cleaner overall now, and closer to the `SessionDiagnostic` derive to make future code sharing easier.

r? ``@davidtwco``
  • Loading branch information
matthiaskrgr committed Aug 31, 2022
2 parents 7f442f8 + 31b939b commit ea9c370
Show file tree
Hide file tree
Showing 5 changed files with 748 additions and 366 deletions.
17 changes: 5 additions & 12 deletions compiler/rustc_errors/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -686,19 +686,12 @@ impl Diagnostic {
suggestion: Vec<(Span, String)>,
applicability: Applicability,
) -> &mut Self {
assert!(!suggestion.is_empty());
self.push_suggestion(CodeSuggestion {
substitutions: vec![Substitution {
parts: suggestion
.into_iter()
.map(|(span, snippet)| SubstitutionPart { snippet, span })
.collect(),
}],
msg: self.subdiagnostic_message_to_diagnostic_message(msg),
style: SuggestionStyle::CompletelyHidden,
self.multipart_suggestion_with_style(
msg,
suggestion,
applicability,
});
self
SuggestionStyle::CompletelyHidden,
)
}

/// Prints out a message with a suggested edit of the code.
Expand Down
Loading

0 comments on commit ea9c370

Please sign in to comment.