| if let StmtKind::Let(local) = stmt.kind |
| && let Some(init) = local.init |
| && let ExprKind::Closure { capture_clause: CaptureBy::Ref, fn_decl: fn_decl, body: body_id, closure_kind: ClosureKind::Closure, .. } = init.kind |
| && let FnRetTy::DefaultReturn(_) = fn_decl.output |
| && expr = &cx.tcx.hir_body(body_id).value |
| && let ExprKind::Block(block, None) = expr.kind |
| && block.stmts.len() == 1 |
| && let StmtKind::Semi(e) = block.stmts[0].kind |
| && let ExprKind::Call(func, args) = e.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(block1, None) = args[0].kind |
| && block1.stmts.len() == 2 |
| && let StmtKind::Let(local1) = block1.stmts[0].kind |
| && let Some(init1) = local1.init |
| && let ExprKind::Tup(elements) = init1.kind |
| && elements.len() == 1 |
| && let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner) = elements[0].kind |
| && let PatKind::Binding(BindingMode::NONE, _, name, None) = local1.pat.kind |
| && name.as_str() == "args" |
| && let StmtKind::Let(local2) = block1.stmts[1].kind |
| && let Some(init2) = local2.init |
| && let ExprKind::Array(elements1) = init2.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, _, name1, None) = local2.pat.kind |
| && name1.as_str() == "args" |
| && let Some(trailing_expr) = block1.expr |
| && let ExprKind::Block(block2, None) = trailing_expr.kind |
| && block2.stmts.is_empty() |
| && let Some(trailing_expr1) = block2.expr |
| && let ExprKind::Call(func2, args2) = trailing_expr1.kind |
| && paths::CORE_FMT_RT_NEW.matches_path(cx, func2) // Add the path to `clippy_utils::paths` if needed |
| && args2.len() == 2 |
| && let ExprKind::Lit(ref lit) = args2[0].kind |
| && let LitKind::ByteStr(ref vec) = lit.node |
| && let [[128, 1, 10, 0]] = **vec |
| && let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner1) = args2[1].kind |
| && block.expr.is_none() |
| && let PatKind::Binding(BindingMode::NONE, _, name2, None) = local.pat.kind |
| && name2.as_str() == "print_text" |
| { |
| // report your lint here |
| } |