Fix style in if let
chain
Co-authored-by: Alex Macleod <alex@macleod.io>
This commit is contained in:
parent
416da1264c
commit
85b8ff7f38
@ -122,9 +122,10 @@ impl<'tcx> LateLintPass<'tcx> for EtaReduction {
|
|||||||
then {
|
then {
|
||||||
span_lint_and_then(cx, REDUNDANT_CLOSURE, expr.span, "redundant closure", |diag| {
|
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(mut snippet) = snippet_opt(cx, callee.span) {
|
||||||
if let Some(fn_mut_id) = cx.tcx.lang_items().fn_mut_trait() &&
|
if let Some(fn_mut_id) = cx.tcx.lang_items().fn_mut_trait()
|
||||||
implements_trait(cx, callee_ty.peel_refs(), fn_mut_id, &[]) &&
|
&& implements_trait(cx, callee_ty.peel_refs(), fn_mut_id, &[])
|
||||||
path_to_local(callee).map_or(false, |l| local_used_after_expr(cx, l, expr)) {
|
&& path_to_local(callee).map_or(false, |l| local_used_after_expr(cx, l, expr))
|
||||||
|
{
|
||||||
// Mutable closure is used after current expr; we cannot consume it.
|
// Mutable closure is used after current expr; we cannot consume it.
|
||||||
snippet = format!("&mut {snippet}");
|
snippet = format!("&mut {snippet}");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user