let_if_seq
: use array_windows
.
This commit is contained in:
parent
ff4e62d3ec
commit
fed75b3895
1 changed files with 3 additions and 5 deletions
|
@ -58,12 +58,10 @@ declare_lint_pass!(LetIfSeq => [USELESS_LET_IF_SEQ]);
|
||||||
|
|
||||||
impl<'tcx> LateLintPass<'tcx> for LetIfSeq {
|
impl<'tcx> LateLintPass<'tcx> for LetIfSeq {
|
||||||
fn check_block(&mut self, cx: &LateContext<'tcx>, block: &'tcx hir::Block<'_>) {
|
fn check_block(&mut self, cx: &LateContext<'tcx>, block: &'tcx hir::Block<'_>) {
|
||||||
let mut it = block.stmts.iter().peekable();
|
for [stmt, next] in block.stmts.array_windows::<2>() {
|
||||||
while let Some(stmt) = it.next() {
|
if let hir::StmtKind::Let(local) = stmt.kind
|
||||||
if let Some(expr) = it.peek()
|
|
||||||
&& let hir::StmtKind::Let(local) = stmt.kind
|
|
||||||
&& let hir::PatKind::Binding(mode, canonical_id, ident, None) = local.pat.kind
|
&& let hir::PatKind::Binding(mode, canonical_id, ident, None) = local.pat.kind
|
||||||
&& let hir::StmtKind::Expr(if_) = expr.kind
|
&& let hir::StmtKind::Expr(if_) = next.kind
|
||||||
&& let hir::ExprKind::If(
|
&& let hir::ExprKind::If(
|
||||||
hir::Expr {
|
hir::Expr {
|
||||||
kind: hir::ExprKind::DropTemps(cond),
|
kind: hir::ExprKind::DropTemps(cond),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue