1
Fork 0

Use as_closure helper method

Co-authored-by: lcnr <rust@lcnr.de>
This commit is contained in:
Oli Scherer 2022-11-21 16:52:01 +01:00 committed by Oli Scherer
parent 7658e0fccf
commit 24cdb72445

View file

@ -124,7 +124,7 @@ impl<'tcx> LateLintPass<'tcx> for EtaReduction {
span_lint_and_then(cx, REDUNDANT_CLOSURE, expr.span, "redundant closure", |diag| {
if let Some(mut snippet) = snippet_opt(cx, callee.span) {
if let Some(fn_mut_id) = cx.tcx.lang_items().fn_mut_trait()
&& let args = cx.tcx.erase_late_bound_regions(ty::ClosureSubsts { substs }.sig()).inputs()
&& let args = cx.tcx.erase_late_bound_regions(substs.as_closure().sig()).inputs()
&& implements_trait(cx, callee_ty.peel_refs(), fn_mut_id, &args.iter().copied().map(Into::into).collect::<Vec<_>>())
&& path_to_local(callee).map_or(false, |l| local_used_after_expr(cx, l, expr))
{