remove an unnecessary span_to_snippet
This commit is contained in:
parent
1c7b36d4db
commit
5188bdbccd
1 changed files with 9 additions and 12 deletions
|
@ -1598,23 +1598,20 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
let return_ty = tcx.erase_regions(return_ty);
|
let return_ty = tcx.erase_regions(return_ty);
|
||||||
|
|
||||||
// to avoid panics
|
// to avoid panics
|
||||||
if let Some(iter_trait) = tcx.get_diagnostic_item(sym::Iterator) {
|
if let Some(iter_trait) = tcx.get_diagnostic_item(sym::Iterator)
|
||||||
if self
|
&& self
|
||||||
.infcx
|
.infcx
|
||||||
.type_implements_trait(iter_trait, return_ty, ty_params, self.param_env)
|
.type_implements_trait(iter_trait, return_ty, ty_params, self.param_env)
|
||||||
.must_apply_modulo_regions()
|
.must_apply_modulo_regions()
|
||||||
{
|
{
|
||||||
if let Ok(snippet) = tcx.sess.source_map().span_to_snippet(return_span) {
|
|
||||||
err.span_suggestion_hidden(
|
err.span_suggestion_hidden(
|
||||||
return_span,
|
return_span.shrink_to_hi(),
|
||||||
"use `.collect()` to allocate the iterator",
|
"use `.collect()` to allocate the iterator",
|
||||||
format!("{snippet}.collect::<Vec<_>>()"),
|
".collect::<Vec<_>>()",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Some(err)
|
Some(err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue