2022-10-23 13:18:45 +00:00
|
|
|
if let ExprKind::Block(block, None) = expr.kind
|
|
|
|
&& block.stmts.len() == 3
|
|
|
|
&& let StmtKind::Local(local) = block.stmts[0].kind
|
|
|
|
&& let Some(init) = local.init
|
|
|
|
&& let ExprKind::Lit(ref lit) = init.kind
|
|
|
|
&& let LitKind::Int(42, LitIntType::Signed(IntTy::I32)) = lit.node
|
|
|
|
&& let PatKind::Binding(BindingAnnotation::NONE, _, name, None) = local.pat.kind
|
|
|
|
&& name.as_str() == "x"
|
|
|
|
&& let StmtKind::Local(local1) = block.stmts[1].kind
|
|
|
|
&& let Some(init1) = local1.init
|
|
|
|
&& let ExprKind::Lit(ref lit1) = init1.kind
|
|
|
|
&& let LitKind::Float(_, LitFloatType::Suffixed(FloatTy::F32)) = lit1.node
|
|
|
|
&& let PatKind::Binding(BindingAnnotation::NONE, _, name1, None) = local1.pat.kind
|
|
|
|
&& name1.as_str() == "_t"
|
|
|
|
&& let StmtKind::Semi(e) = block.stmts[2].kind
|
|
|
|
&& let ExprKind::Unary(UnOp::Neg, inner) = e.kind
|
|
|
|
&& let ExprKind::Path(ref qpath) = inner.kind
|
|
|
|
&& match_qpath(qpath, &["x"])
|
|
|
|
&& block.expr.is_none()
|
|
|
|
{
|
|
|
|
// report your lint here
|
2019-05-19 14:52:44 +00:00
|
|
|
}
|
2022-10-23 13:18:45 +00:00
|
|
|
if let ExprKind::Block(block, None) = expr.kind
|
|
|
|
&& block.stmts.len() == 1
|
|
|
|
&& let StmtKind::Local(local) = block.stmts[0].kind
|
|
|
|
&& let Some(init) = local.init
|
|
|
|
&& let ExprKind::Call(func, args) = init.kind
|
|
|
|
&& let ExprKind::Path(ref qpath) = func.kind
|
|
|
|
&& match_qpath(qpath, &["String", "new"])
|
|
|
|
&& args.is_empty()
|
|
|
|
&& let PatKind::Binding(BindingAnnotation::NONE, _, name, None) = local.pat.kind
|
|
|
|
&& name.as_str() == "expr"
|
|
|
|
&& let Some(trailing_expr) = block.expr
|
|
|
|
&& let ExprKind::Call(func1, args1) = trailing_expr.kind
|
|
|
|
&& let ExprKind::Path(ref qpath1) = func1.kind
|
|
|
|
&& match_qpath(qpath1, &["drop"])
|
|
|
|
&& args1.len() == 1
|
|
|
|
&& let ExprKind::Path(ref qpath2) = args1[0].kind
|
|
|
|
&& match_qpath(qpath2, &["expr"])
|
|
|
|
{
|
|
|
|
// report your lint here
|
2021-12-06 11:33:31 +00:00
|
|
|
}
|
2024-01-24 18:01:56 +00:00
|
|
|
if let ExprKind::Closure { capture_clause: CaptureBy::Value { .. }, fn_decl: fn_decl, body: body_id, closure_kind: ClosureKind::CoroutineClosure(CoroutineDesugaring::Async), .. } = expr.kind
|
2022-10-23 13:18:45 +00:00
|
|
|
&& let FnRetTy::DefaultReturn(_) = fn_decl.output
|
|
|
|
&& expr1 = &cx.tcx.hir().body(body_id).value
|
2024-01-24 18:01:56 +00:00
|
|
|
&& let ExprKind::Closure { capture_clause: CaptureBy::Ref, fn_decl: fn_decl1, body: body_id1, closure_kind: ClosureKind::Coroutine(CoroutineKind::Desugared(CoroutineDesugaring::Async, CoroutineSource::Closure)), .. } = expr1.kind
|
2022-10-23 13:18:45 +00:00
|
|
|
&& let FnRetTy::DefaultReturn(_) = fn_decl1.output
|
|
|
|
&& expr2 = &cx.tcx.hir().body(body_id1).value
|
|
|
|
&& let ExprKind::Block(block, None) = expr2.kind
|
|
|
|
&& block.stmts.is_empty()
|
2024-01-15 19:38:53 +00:00
|
|
|
&& let Some(trailing_expr) = block.expr
|
|
|
|
&& let ExprKind::DropTemps(expr3) = trailing_expr.kind
|
|
|
|
&& let ExprKind::Block(block1, None) = expr3.kind
|
|
|
|
&& block1.stmts.is_empty()
|
|
|
|
&& block1.expr.is_none()
|
2022-10-23 13:18:45 +00:00
|
|
|
{
|
|
|
|
// report your lint here
|
2019-05-19 14:52:44 +00:00
|
|
|
}
|