]>
Commit | Line | Data |
---|---|---|
2b03887a FG |
1 | if let ExprKind::Block(block, None) = expr.kind |
2 | && block.stmts.len() == 3 | |
3 | && let StmtKind::Local(local) = block.stmts[0].kind | |
4 | && let Some(init) = local.init | |
5 | && let ExprKind::Lit(ref lit) = init.kind | |
6 | && let LitKind::Int(42, LitIntType::Signed(IntTy::I32)) = lit.node | |
7 | && let PatKind::Binding(BindingAnnotation::NONE, _, name, None) = local.pat.kind | |
8 | && name.as_str() == "x" | |
9 | && let StmtKind::Local(local1) = block.stmts[1].kind | |
10 | && let Some(init1) = local1.init | |
11 | && let ExprKind::Lit(ref lit1) = init1.kind | |
12 | && let LitKind::Float(_, LitFloatType::Suffixed(FloatTy::F32)) = lit1.node | |
13 | && let PatKind::Binding(BindingAnnotation::NONE, _, name1, None) = local1.pat.kind | |
14 | && name1.as_str() == "_t" | |
15 | && let StmtKind::Semi(e) = block.stmts[2].kind | |
16 | && let ExprKind::Unary(UnOp::Neg, inner) = e.kind | |
17 | && let ExprKind::Path(ref qpath) = inner.kind | |
18 | && match_qpath(qpath, &["x"]) | |
19 | && block.expr.is_none() | |
20 | { | |
21 | // report your lint here | |
f20569fa | 22 | } |
2b03887a FG |
23 | if let ExprKind::Block(block, None) = expr.kind |
24 | && block.stmts.len() == 1 | |
25 | && let StmtKind::Local(local) = block.stmts[0].kind | |
26 | && let Some(init) = local.init | |
27 | && let ExprKind::Call(func, args) = init.kind | |
28 | && let ExprKind::Path(ref qpath) = func.kind | |
29 | && match_qpath(qpath, &["String", "new"]) | |
30 | && args.is_empty() | |
31 | && let PatKind::Binding(BindingAnnotation::NONE, _, name, None) = local.pat.kind | |
32 | && name.as_str() == "expr" | |
33 | && let Some(trailing_expr) = block.expr | |
34 | && let ExprKind::Call(func1, args1) = trailing_expr.kind | |
35 | && let ExprKind::Path(ref qpath1) = func1.kind | |
36 | && match_qpath(qpath1, &["drop"]) | |
37 | && args1.len() == 1 | |
38 | && let ExprKind::Path(ref qpath2) = args1[0].kind | |
39 | && match_qpath(qpath2, &["expr"]) | |
40 | { | |
41 | // report your lint here | |
a2a8927a | 42 | } |
2b03887a FG |
43 | if let ExprKind::Closure(CaptureBy::Value, fn_decl, body_id, _, None) = expr.kind |
44 | && let FnRetTy::DefaultReturn(_) = fn_decl.output | |
45 | && expr1 = &cx.tcx.hir().body(body_id).value | |
46 | && let ExprKind::Call(func, args) = expr1.kind | |
47 | && let ExprKind::Path(ref qpath) = func.kind | |
487cf647 | 48 | && matches!(qpath, QPath::LangItem(LangItem::IdentityFuture, _)) |
2b03887a FG |
49 | && args.len() == 1 |
50 | && let ExprKind::Closure(CaptureBy::Value, fn_decl1, body_id1, _, Some(Movability::Static)) = args[0].kind | |
51 | && let FnRetTy::DefaultReturn(_) = fn_decl1.output | |
52 | && expr2 = &cx.tcx.hir().body(body_id1).value | |
53 | && let ExprKind::Block(block, None) = expr2.kind | |
54 | && block.stmts.is_empty() | |
55 | && block.expr.is_none() | |
56 | { | |
57 | // report your lint here | |
f20569fa | 58 | } |