mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-12-23 03:23:33 +00:00
61 lines
2.3 KiB
Text
61 lines
2.3 KiB
Text
if_chain! {
|
|
if let ExprKind::Struct(ref qpath, ref fields, None) = expr.kind;
|
|
if match_qpath(qpath, &["Test"]);
|
|
if fields.len() == 1;
|
|
if fields[0].ident.name.as_str() == "field";
|
|
if let Some(higher::If { cond: cond, then: then, r#else: else_expr}) = higher::If::hir(fields[0].expr);
|
|
if let ExprKind::Lit(ref lit) = cond.kind;
|
|
if let LitKind::Bool(true) = lit.node;
|
|
if let ExprKind::Block(ref block, ref label) = then.kind;
|
|
if block.stmts.len() == 0;
|
|
if let Some(trailing_expr) = &block.expr;
|
|
if let ExprKind::Lit(ref lit1) = trailing_expr.kind;
|
|
if let LitKind::Int(1, LitIntType::Unsuffixed) = lit1.node;
|
|
if let ExprKind::Block(ref block1, ref label1) = else_expr.kind;
|
|
if block1.stmts.len() == 0;
|
|
if let Some(trailing_expr1) = &block1.expr;
|
|
if let ExprKind::Lit(ref lit2) = trailing_expr1.kind;
|
|
if let LitKind::Int(0, LitIntType::Unsuffixed) = lit2.node;
|
|
then {
|
|
// report your lint here
|
|
}
|
|
}
|
|
if_chain! {
|
|
if let PatKind::Struct(ref qpath, ref fields, false) = arm.kind;
|
|
if match_qpath(qpath, &["Test"]);
|
|
if fields.len() == 1;
|
|
if fields[0].ident.name.as_str() == "field";
|
|
if let PatKind::Lit(ref lit_expr) = fields[0].kind;
|
|
if let ExprKind::Lit(ref lit) = lit_expr.kind;
|
|
if let LitKind::Int(1, LitIntType::Unsuffixed) = lit.node;
|
|
if let ExprKind::Block(ref block, ref label) = lit_expr.kind;
|
|
if block.stmts.len() == 0;
|
|
if block.expr.is_none();
|
|
then {
|
|
// report your lint here
|
|
}
|
|
}
|
|
if_chain! {
|
|
if let PatKind::TupleStruct(ref qpath, ref fields, None) = arm.kind;
|
|
if match_qpath(qpath, &["TestTuple"]);
|
|
if fields.len() == 1;
|
|
if let PatKind::Lit(ref lit_expr) = fields[0].kind;
|
|
if let ExprKind::Lit(ref lit) = lit_expr.kind;
|
|
if let LitKind::Int(1, LitIntType::Unsuffixed) = lit.node;
|
|
if let ExprKind::Block(ref block, ref label) = lit_expr.kind;
|
|
if block.stmts.len() == 0;
|
|
if block.expr.is_none();
|
|
then {
|
|
// report your lint here
|
|
}
|
|
}
|
|
if_chain! {
|
|
if let ExprKind::MethodCall(ref method_name, ref args, _) = expr.kind;
|
|
if method_name.ident.name.as_str() == test;
|
|
if args.len() == 1;
|
|
if let ExprKind::Path(ref qpath) = args[0].kind;
|
|
if match_qpath(qpath, &["test_method_call"]);
|
|
then {
|
|
// report your lint here
|
|
}
|
|
}
|