Skip to content

Commit 94d7b82

Browse files
committed
simplify the code
1 parent 3883841 commit 94d7b82

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

clippy_lints/src/loops.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -973,10 +973,7 @@ fn get_details_from_idx<'tcx>(
973973
ast::LitKind::Int(x, _ty) => Some(Sugg::NonParen(x.to_string().into())),
974974
_ => None,
975975
},
976-
ExprKind::Path(..) if get_start(cx, e, starts).is_none() => {
977-
// `e` is always non paren as it's a `Path`
978-
Some(Sugg::NonParen(snippet(cx, e.span, "???")))
979-
},
976+
ExprKind::Path(..) if get_start(cx, e, starts).is_none() => Some(Sugg::hir(cx, e, "???")),
980977
_ => None,
981978
}
982979
}
@@ -1010,8 +1007,7 @@ fn get_assignment<'tcx>(e: &'tcx Expr<'tcx>) -> Option<(&'tcx Expr<'tcx>, &'tcx
10101007

10111008
fn get_assignments<'a: 'c, 'tcx: 'c, 'c>(
10121009
cx: &'a LateContext<'tcx>,
1013-
stmts: &'tcx [Stmt<'tcx>],
1014-
expr: Option<&'tcx Expr<'tcx>>,
1010+
Block { stmts, expr, .. }: &'tcx Block<'tcx>,
10151011
loop_counters: &'c [Start<'tcx>],
10161012
) -> impl Iterator<Item = Option<(&'tcx Expr<'tcx>, &'tcx Expr<'tcx>)>> + 'c {
10171013
stmts
@@ -1025,7 +1021,7 @@ fn get_assignments<'a: 'c, 'tcx: 'c, 'c>(
10251021
then { None } else { Some(e) }
10261022
},
10271023
})
1028-
.chain(expr.into_iter())
1024+
.chain((*expr).into_iter())
10291025
.map(get_assignment)
10301026
}
10311027

@@ -1184,7 +1180,7 @@ fn detect_manual_memcpy<'tcx>(
11841180
if let Some(loop_counters) = get_loop_counters(cx, block, expr) {
11851181
starts.extend(loop_counters);
11861182
}
1187-
iter_a = Some(get_assignments(cx, block.stmts, block.expr, &starts));
1183+
iter_a = Some(get_assignments(cx, block, &starts));
11881184
} else {
11891185
iter_b = Some(get_assignment(body));
11901186
}

0 commit comments

Comments
 (0)