| if let Some(higher::ForLoop { pat: pat, arg: arg, body: body, .. }) = higher::ForLoop::hir(expr) | |
| && let PatKind::Binding(BindingMode::NONE, _, name, None) = pat.kind | |
| && name.as_str() == "i" | |
| && let ExprKind::Struct(qpath, fields, None) = arg.kind | |
| && let Some(def_id) = cx.qpath_res(qpath, arg.hir_id).opt_def_id() | |
| && paths::CORE_OPS_RANGE_RANGE.matches(cx, def_id) // Add the path to `clippy_utils::paths` if needed | |
| && fields.len() == 2 | |
| && fields[0].ident.as_str() == "start" | |
| && let ExprKind::Lit(ref lit) = fields[0].expr.kind | |
| && let LitKind::Int(0, LitIntType::Unsuffixed) = lit.node | |
| && fields[1].ident.as_str() == "end" | |
| && let ExprKind::Lit(ref lit1) = fields[1].expr.kind | |
| && let LitKind::Int(1, LitIntType::Unsuffixed) = lit1.node | |
| && let ExprKind::Block(block, None) = body.kind | |
| && block.stmts.len() == 1 | |
| && let StmtKind::Semi(e) = block.stmts[0].kind | |
| && let ExprKind::Block(block1, None) = e.kind | |
| && block1.stmts.len() == 1 | |
| && let StmtKind::Semi(e1) = block1.stmts[0].kind | |
| && let ExprKind::Call(func, args) = e1.kind | |
| && paths::STD_IO_STDIO__PRINT.matches_path(cx, func) // Add the path to `clippy_utils::paths` if needed | |
| && args.len() == 1 | |
| && let ExprKind::Block(block2, None) = args[0].kind | |
| && block2.stmts.len() == 2 | |
| && let StmtKind::Let(local) = block2.stmts[0].kind | |
| && let Some(init) = local.init | |
| && let ExprKind::Tup(elements) = init.kind | |
| && elements.len() == 1 | |
| && let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner) = elements[0].kind | |
| && let PatKind::Binding(BindingMode::NONE, _, name1, None) = local.pat.kind | |
| && name1.as_str() == "args" | |
| && let StmtKind::Let(local1) = block2.stmts[1].kind | |
| && let Some(init1) = local1.init | |
| && let ExprKind::Array(elements1) = init1.kind | |
| && elements1.len() == 1 | |
| && let ExprKind::Call(func1, args1) = elements1[0].kind | |
| && paths::CORE_FMT_RT_ARGUMENT_NEW_DISPLAY.matches_path(cx, func1) // Add the path to `clippy_utils::paths` if needed | |
| && args1.len() == 1 | |
| && let ExprKind::Field(object, field_name) = args1[0].kind | |
| && field_name.as_str() == "0" | |
| && let PatKind::Binding(BindingMode::NONE, _, name2, None) = local1.pat.kind | |
| && name2.as_str() == "args" | |
| && let Some(trailing_expr) = block2.expr | |
| && let ExprKind::Block(block3, None) = trailing_expr.kind | |
| && block3.stmts.is_empty() | |
| && let Some(trailing_expr1) = block3.expr | |
| && let ExprKind::Call(func2, args2) = trailing_expr1.kind | |
| && paths::CORE_FMT_ARGUMENTS_NEW.matches_path(cx, func2) // Add the path to `clippy_utils::paths` if needed | |
| && args2.len() == 2 | |
| && let ExprKind::Lit(ref lit2) = args2[0].kind | |
| && let LitKind::ByteStr(ref vec) = lit2.node | |
| && let [[192, 1, 10, 0]] = **vec | |
| && let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner1) = args2[1].kind | |
| && block1.expr.is_none() | |
| && block.expr.is_none() | |
| { | |
| // report your lint here | |
| } |