Skip to content

Commit

Permalink
More minor fixes suggested by @jackh726
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianWolff committed May 10, 2021
1 parent 3c0c387 commit 2448c76
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 deletions.
18 changes: 5 additions & 13 deletions compiler/rustc_errors/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,20 +283,12 @@ impl Diagnostic {
suggestion: Vec<(Span, String)>,
applicability: Applicability,
) -> &mut Self {
assert!(!suggestion.is_empty());
self.suggestions.push(CodeSuggestion {
substitutions: vec![Substitution {
parts: suggestion
.into_iter()
.map(|(span, snippet)| SubstitutionPart { snippet, span })
.collect(),
}],
msg: msg.to_owned(),
style: SuggestionStyle::ShowCode,
self.multipart_suggestion_with_style(
msg,
suggestion,
applicability,
tool_metadata: Default::default(),
});
self
SuggestionStyle::ShowCode,
)
}

/// [`Diagnostic::multipart_suggestion()`] but you can set the [`SuggestionStyle`].
Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_resolve/src/late/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1905,9 +1905,11 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {

let spans_suggs: Vec<_> = formatters
.into_iter()
.filter_map(|fmt| fmt)
.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();
err.multipart_suggestion_with_style(
&format!(
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 2448c76

Please sign in to comment.