Skip to content

Commit cb843a0

Browse files
committed
Code deduplication in tool_only_multipart_suggestion
1 parent 4a24f08 commit cb843a0

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

compiler/rustc_errors/src/diagnostic.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -672,19 +672,12 @@ impl Diagnostic {
672672
suggestion: Vec<(Span, String)>,
673673
applicability: Applicability,
674674
) -> &mut Self {
675-
assert!(!suggestion.is_empty());
676-
self.push_suggestion(CodeSuggestion {
677-
substitutions: vec![Substitution {
678-
parts: suggestion
679-
.into_iter()
680-
.map(|(span, snippet)| SubstitutionPart { snippet, span })
681-
.collect(),
682-
}],
683-
msg: self.subdiagnostic_message_to_diagnostic_message(msg),
684-
style: SuggestionStyle::CompletelyHidden,
675+
self.multipart_suggestion_with_style(
676+
msg,
677+
suggestion,
685678
applicability,
686-
});
687-
self
679+
SuggestionStyle::CompletelyHidden,
680+
)
688681
}
689682

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

0 commit comments

Comments
 (0)