Tighten span when suggesting lifetime on path

This commit is contained in:
Michael Goulet 2021-12-27 14:10:59 -08:00
parent 51e8031e14
commit e37d012a06
5 changed files with 89 additions and 7 deletions

View file

@ -2115,10 +2115,13 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
let spans_suggs: Vec<_> = formatters
.into_iter()
.zip(spans_with_counts.iter())
.filter_map(|(fmt, (span, _))| {
if let Some(formatter) = fmt { Some((formatter, span)) } else { None }
.filter_map(|(formatter, (span, _))| {
if let Some(formatter) = formatter {
Some((*span, formatter(name)))
} else {
None
}
})
.map(|(formatter, span)| (*span, formatter(name)))
.collect();
if spans_suggs.is_empty() {
// If all the spans come from macros, we cannot extract snippets and then