More minor fixes suggested by @jackh726
This commit is contained in:
parent
3c0c3874fc
commit
2448c7698e
4 changed files with 9 additions and 15 deletions
|
@ -283,20 +283,12 @@ impl Diagnostic {
|
||||||
suggestion: Vec<(Span, String)>,
|
suggestion: Vec<(Span, String)>,
|
||||||
applicability: Applicability,
|
applicability: Applicability,
|
||||||
) -> &mut Self {
|
) -> &mut Self {
|
||||||
assert!(!suggestion.is_empty());
|
self.multipart_suggestion_with_style(
|
||||||
self.suggestions.push(CodeSuggestion {
|
msg,
|
||||||
substitutions: vec![Substitution {
|
suggestion,
|
||||||
parts: suggestion
|
|
||||||
.into_iter()
|
|
||||||
.map(|(span, snippet)| SubstitutionPart { snippet, span })
|
|
||||||
.collect(),
|
|
||||||
}],
|
|
||||||
msg: msg.to_owned(),
|
|
||||||
style: SuggestionStyle::ShowCode,
|
|
||||||
applicability,
|
applicability,
|
||||||
tool_metadata: Default::default(),
|
SuggestionStyle::ShowCode,
|
||||||
});
|
)
|
||||||
self
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// [`Diagnostic::multipart_suggestion()`] but you can set the [`SuggestionStyle`].
|
/// [`Diagnostic::multipart_suggestion()`] but you can set the [`SuggestionStyle`].
|
||||||
|
|
|
@ -1905,9 +1905,11 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
|
||||||
|
|
||||||
let spans_suggs: Vec<_> = formatters
|
let spans_suggs: Vec<_> = formatters
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|fmt| fmt)
|
|
||||||
.zip(spans_with_counts.iter())
|
.zip(spans_with_counts.iter())
|
||||||
.map(|(formatter, (span, _))| (*span, formatter(name)))
|
.filter_map(|(fmt, (span, _))| {
|
||||||
|
if let Some(formatter) = fmt { Some((formatter, span)) } else { None }
|
||||||
|
})
|
||||||
|
.map(|(formatter, span)| (*span, formatter(name)))
|
||||||
.collect();
|
.collect();
|
||||||
err.multipart_suggestion_with_style(
|
err.multipart_suggestion_with_style(
|
||||||
&format!(
|
&format!(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue