mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 21:23:56 +00:00
40 lines
1.5 KiB
Text
40 lines
1.5 KiB
Text
if_chain! {
|
|
if let ExprKind::Block(ref block) = expr.kind;
|
|
if block.stmts.len() == 2;
|
|
if let StmtKind::Local(ref local) = block.stmts[0].kind;
|
|
if let Some(ref init) = local.init;
|
|
if let ExprKind::Lit(ref lit) = init.kind;
|
|
if let LitKind::Int(42, _) = lit.node;
|
|
if let PatKind::Binding(BindingAnnotation::Unannotated, _, name, None) = local.pat.kind;
|
|
if name.as_str() == "x";
|
|
if let StmtKind::Semi(ref e, _) = block.stmts[1].kind
|
|
if let ExprKind::Unary(UnOp::Neg, ref inner) = e.kind;
|
|
if let ExprKind::Path(ref path) = inner.kind;
|
|
if match_qpath(path, &["x"]);
|
|
if block.expr.is_none();
|
|
then {
|
|
// report your lint here
|
|
}
|
|
}
|
|
if_chain! {
|
|
if let ExprKind::Block(ref block) = expr.kind;
|
|
if block.stmts.len() == 1;
|
|
if let StmtKind::Local(ref local) = block.stmts[0].kind;
|
|
if let Some(ref init) = local.init;
|
|
if let ExprKind::Call(ref func, ref args) = init.kind;
|
|
if let ExprKind::Path(ref path) = func.kind;
|
|
if match_qpath(path, &["String", "new"]);
|
|
if args.len() == 0;
|
|
if let PatKind::Binding(BindingAnnotation::Unannotated, _, name, None) = local.pat.kind;
|
|
if name.as_str() == "expr";
|
|
if let Some(trailing_expr) = &block.expr;
|
|
if let ExprKind::Call(ref func1, ref args1) = trailing_expr.kind;
|
|
if let ExprKind::Path(ref path1) = func1.kind;
|
|
if match_qpath(path1, &["drop"]);
|
|
if args1.len() == 1;
|
|
if let ExprKind::Path(ref path2) = args1[0].kind;
|
|
if match_qpath(path2, &["expr"]);
|
|
then {
|
|
// report your lint here
|
|
}
|
|
}
|