Skip to content

Commit 2f50d33

Browse files
Rollup merge of rust-lang#100970 - Xiretza:derive-multipart-suggestion, 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`
2 parents 2fd242c + 72541dd commit 2f50d33

File tree

5 files changed

+748
-366
lines changed

5 files changed

+748
-366
lines changed

compiler/rustc_errors/src/diagnostic.rs

+5-12
Original file line numberDiff line numberDiff line change
@@ -686,19 +686,12 @@ impl Diagnostic {
686686
suggestion: Vec<(Span, String)>,
687687
applicability: Applicability,
688688
) -> &mut Self {
689-
assert!(!suggestion.is_empty());
690-
self.push_suggestion(CodeSuggestion {
691-
substitutions: vec![Substitution {
692-
parts: suggestion
693-
.into_iter()
694-
.map(|(span, snippet)| SubstitutionPart { snippet, span })
695-
.collect(),
696-
}],
697-
msg: self.subdiagnostic_message_to_diagnostic_message(msg),
698-
style: SuggestionStyle::CompletelyHidden,
689+
self.multipart_suggestion_with_style(
690+
msg,
691+
suggestion,
699692
applicability,
700-
});
701-
self
693+
SuggestionStyle::CompletelyHidden,
694+
)
702695
}
703696

704697
/// Prints out a message with a suggested edit of the code.

0 commit comments

Comments
 (0)