about summary refs log tree commit diff
path: root/src/tools/clippy/tests/ui/author/macro_in_closure.stdout
blob: 786c61e0c018eff5a17ed2187a59ab4def0332dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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::Call(func2, args2) = trailing_expr.kind
    && paths::CORE_FMT_RT_NEW_V1.matches_path(cx, func2) // Add the path to `clippy_utils::paths` if needed
    && args2.len() == 2
    && let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner1) = args2[0].kind
    && let ExprKind::Array(elements2) = inner1.kind
    && elements2.len() == 2
    && let ExprKind::Lit(ref lit) = elements2[0].kind
    && let LitKind::Str(s, _) = lit.node
    && s.as_str() == ""
    && let ExprKind::Lit(ref lit1) = elements2[1].kind
    && let LitKind::Str(s1, _) = lit1.node
    && s1.as_str() == "\n"
    && let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner2) = 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
}