Skip to content

Commit

Permalink
Rollup merge of rust-lang#100970 - Xiretza:derive-multipart-suggestio…
Browse files Browse the repository at this point in the history
…n, r=davidtwco

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 authored Aug 31, 2022
2 parents c4e96aa + 31b939b commit 8852f98
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 8852f98

Please sign in to comment.