Skip to content

Commit 2448c76

Browse files
committed
More minor fixes suggested by @jackh726
1 parent 3c0c387 commit 2448c76

File tree

4 files changed

+9
-15
lines changed

4 files changed

+9
-15
lines changed

compiler/rustc_errors/src/diagnostic.rs

+5-13
Original file line numberDiff line numberDiff line change
@@ -283,20 +283,12 @@ impl Diagnostic {
283283
suggestion: Vec<(Span, String)>,
284284
applicability: Applicability,
285285
) -> &mut Self {
286-
assert!(!suggestion.is_empty());
287-
self.suggestions.push(CodeSuggestion {
288-
substitutions: vec![Substitution {
289-
parts: suggestion
290-
.into_iter()
291-
.map(|(span, snippet)| SubstitutionPart { snippet, span })
292-
.collect(),
293-
}],
294-
msg: msg.to_owned(),
295-
style: SuggestionStyle::ShowCode,
286+
self.multipart_suggestion_with_style(
287+
msg,
288+
suggestion,
296289
applicability,
297-
tool_metadata: Default::default(),
298-
});
299-
self
290+
SuggestionStyle::ShowCode,
291+
)
300292
}
301293

302294
/// [`Diagnostic::multipart_suggestion()`] but you can set the [`SuggestionStyle`].

compiler/rustc_resolve/src/late/diagnostics.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1905,9 +1905,11 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
19051905

19061906
let spans_suggs: Vec<_> = formatters
19071907
.into_iter()
1908-
.filter_map(|fmt| fmt)
19091908
.zip(spans_with_counts.iter())
1910-
.map(|(formatter, (span, _))| (*span, formatter(name)))
1909+
.filter_map(|(fmt, (span, _))| {
1910+
if let Some(formatter) = fmt { Some((formatter, span)) } else { None }
1911+
})
1912+
.map(|(formatter, span)| (*span, formatter(name)))
19111913
.collect();
19121914
err.multipart_suggestion_with_style(
19131915
&format!(

0 commit comments

Comments
 (0)