Fix author lint and move it back to tests/ui

The author lint is not an internal lint, and should also be enabled, when Clippy
is distributed through rustup. This moves the author lint test cases back to
tests/ui.
This commit is contained in:
Philipp Krones 2024-11-07 17:12:42 +01:00
parent b816d4ee4f
commit 03daf7ccb2
No known key found for this signature in database
GPG key ID: 1CA0DF2AF59D68A5
22 changed files with 0 additions and 2 deletions

4
tests/ui/author.rs Normal file
View file

@ -0,0 +1,4 @@
fn main() {
#[clippy::author]
let x: char = 0x45 as char;
}

12
tests/ui/author.stdout Normal file
View file

@ -0,0 +1,12 @@
if let StmtKind::Let(local) = stmt.kind
&& let Some(init) = local.init
&& let ExprKind::Cast(expr, cast_ty) = init.kind
&& let TyKind::Path(ref qpath) = cast_ty.kind
&& match_qpath(qpath, &["char"])
&& let ExprKind::Lit(ref lit) = expr.kind
&& let LitKind::Int(69, LitIntType::Unsuffixed) = lit.node
&& let PatKind::Binding(BindingMode::NONE, _, name, None) = local.pat.kind
&& name.as_str() == "x"
{
// report your lint here
}

24
tests/ui/author/blocks.rs Normal file
View file

@ -0,0 +1,24 @@
//@edition:2018
#![allow(redundant_semicolons, clippy::no_effect)]
#![feature(stmt_expr_attributes)]
#![feature(async_closure)]
#[rustfmt::skip]
fn main() {
#[clippy::author]
{
let x = 42i32;
let _t = 1f32;
-x;
};
#[clippy::author]
{
let expr = String::new();
drop(expr)
};
#[clippy::author]
async move || {};
}

View file

@ -0,0 +1,58 @@
if let ExprKind::Block(block, None) = expr.kind
&& block.stmts.len() == 3
&& let StmtKind::Let(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(BindingMode::NONE, _, name, None) = local.pat.kind
&& name.as_str() == "x"
&& let StmtKind::Let(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(BindingMode::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
}
if let ExprKind::Block(block, None) = expr.kind
&& block.stmts.len() == 1
&& let StmtKind::Let(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(BindingMode::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
}
if let ExprKind::Closure { capture_clause: CaptureBy::Value { .. }, fn_decl: fn_decl, body: body_id, closure_kind: ClosureKind::CoroutineClosure(CoroutineDesugaring::Async), .. } = expr.kind
&& let FnRetTy::DefaultReturn(_) = fn_decl.output
&& expr1 = &cx.tcx.hir().body(body_id).value
&& 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
&& 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()
&& 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()
{
// report your lint here
}

4
tests/ui/author/call.rs Normal file
View file

@ -0,0 +1,4 @@
fn main() {
#[clippy::author]
let _ = ::std::cmp::min(3, 4);
}

View file

@ -0,0 +1,14 @@
if let StmtKind::Let(local) = stmt.kind
&& let Some(init) = local.init
&& let ExprKind::Call(func, args) = init.kind
&& let ExprKind::Path(ref qpath) = func.kind
&& match_qpath(qpath, &["{{root}}", "std", "cmp", "min"])
&& args.len() == 2
&& let ExprKind::Lit(ref lit) = args[0].kind
&& let LitKind::Int(3, LitIntType::Unsuffixed) = lit.node
&& let ExprKind::Lit(ref lit1) = args[1].kind
&& let LitKind::Int(4, LitIntType::Unsuffixed) = lit1.node
&& let PatKind::Wild = local.pat.kind
{
// report your lint here
}

17
tests/ui/author/if.rs Normal file
View file

@ -0,0 +1,17 @@
#[allow(clippy::all)]
fn main() {
#[clippy::author]
let _ = if true {
1 == 1;
} else {
2 == 2;
};
let a = true;
#[clippy::author]
if let true = a {
} else {
};
}

46
tests/ui/author/if.stdout Normal file
View file

@ -0,0 +1,46 @@
if let StmtKind::Let(local) = stmt.kind
&& let Some(init) = local.init
&& let ExprKind::If(cond, then, Some(else_expr)) = init.kind
&& let ExprKind::DropTemps(expr) = cond.kind
&& let ExprKind::Lit(ref lit) = expr.kind
&& let LitKind::Bool(true) = lit.node
&& let ExprKind::Block(block, None) = then.kind
&& block.stmts.len() == 1
&& let StmtKind::Semi(e) = block.stmts[0].kind
&& let ExprKind::Binary(op, left, right) = e.kind
&& BinOpKind::Eq == op.node
&& let ExprKind::Lit(ref lit1) = left.kind
&& let LitKind::Int(1, LitIntType::Unsuffixed) = lit1.node
&& let ExprKind::Lit(ref lit2) = right.kind
&& let LitKind::Int(1, LitIntType::Unsuffixed) = lit2.node
&& block.expr.is_none()
&& let ExprKind::Block(block1, None) = else_expr.kind
&& block1.stmts.len() == 1
&& let StmtKind::Semi(e1) = block1.stmts[0].kind
&& let ExprKind::Binary(op1, left1, right1) = e1.kind
&& BinOpKind::Eq == op1.node
&& let ExprKind::Lit(ref lit3) = left1.kind
&& let LitKind::Int(2, LitIntType::Unsuffixed) = lit3.node
&& let ExprKind::Lit(ref lit4) = right1.kind
&& let LitKind::Int(2, LitIntType::Unsuffixed) = lit4.node
&& block1.expr.is_none()
&& let PatKind::Wild = local.pat.kind
{
// report your lint here
}
if let ExprKind::If(cond, then, Some(else_expr)) = expr.kind
&& let ExprKind::Let(let_expr) = cond.kind
&& let PatKind::Lit(lit_expr) = let_expr.pat.kind
&& let ExprKind::Lit(ref lit) = lit_expr.kind
&& let LitKind::Bool(true) = lit.node
&& let ExprKind::Path(ref qpath) = let_expr.init.kind
&& match_qpath(qpath, &["a"])
&& let ExprKind::Block(block, None) = then.kind
&& block.stmts.is_empty()
&& block.expr.is_none()
&& let ExprKind::Block(block1, None) = else_expr.kind
&& block1.stmts.is_empty()
&& block1.expr.is_none()
{
// report your lint here
}

View file

@ -0,0 +1,14 @@
#![allow(dead_code)]
#![allow(clippy::zero_ptr)]
#![allow(clippy::transmute_ptr_to_ref)]
#![allow(clippy::transmuting_null, clippy::missing_transmute_annotations)]
pub const ZPTR: *const usize = 0 as *const _;
fn main() {
unsafe {
#[clippy::author]
let _: &i32 = std::mem::transmute(ZPTR);
let _: &i32 = std::mem::transmute(0 as *const i32);
}
}

View file

@ -0,0 +1,12 @@
if let StmtKind::Let(local) = stmt.kind
&& let Some(init) = local.init
&& let ExprKind::Call(func, args) = init.kind
&& let ExprKind::Path(ref qpath) = func.kind
&& match_qpath(qpath, &["std", "mem", "transmute"])
&& args.len() == 1
&& let ExprKind::Path(ref qpath1) = args[0].kind
&& match_qpath(qpath1, &["ZPTR"])
&& let PatKind::Wild = local.pat.kind
{
// report your lint here
}

40
tests/ui/author/loop.rs Normal file
View file

@ -0,0 +1,40 @@
#![feature(stmt_expr_attributes)]
#![allow(
clippy::never_loop,
clippy::while_immutable_condition,
clippy::redundant_pattern_matching
)]
fn main() {
#[clippy::author]
for y in 0..10 {
let z = y;
}
#[clippy::author]
for _ in 0..10 {
break;
}
#[clippy::author]
'label: for _ in 0..10 {
break 'label;
}
let a = true;
#[clippy::author]
while a {
break;
}
#[clippy::author]
while let true = a {
break;
}
#[clippy::author]
loop {
break;
}
}

101
tests/ui/author/loop.stdout Normal file
View file

@ -0,0 +1,101 @@
if let Some(higher::ForLoop { pat: pat, arg: arg, body: body, .. }) = higher::ForLoop::hir(expr)
&& let PatKind::Binding(BindingMode::NONE, _, name, None) = pat.kind
&& name.as_str() == "y"
&& let ExprKind::Struct(qpath, fields, None) = arg.kind
&& matches!(qpath, QPath::LangItem(LangItem::Range, _))
&& fields.len() == 2
&& fields[0].ident.as_str() == "start"
&& let ExprKind::Lit(ref lit) = fields[0].expr.kind
&& let LitKind::Int(0, LitIntType::Unsuffixed) = lit.node
&& fields[1].ident.as_str() == "end"
&& let ExprKind::Lit(ref lit1) = fields[1].expr.kind
&& let LitKind::Int(10, LitIntType::Unsuffixed) = lit1.node
&& let ExprKind::Block(block, None) = body.kind
&& block.stmts.len() == 1
&& let StmtKind::Let(local) = block.stmts[0].kind
&& let Some(init) = local.init
&& let ExprKind::Path(ref qpath1) = init.kind
&& match_qpath(qpath1, &["y"])
&& let PatKind::Binding(BindingMode::NONE, _, name1, None) = local.pat.kind
&& name1.as_str() == "z"
&& block.expr.is_none()
{
// report your lint here
}
if let Some(higher::ForLoop { pat: pat, arg: arg, body: body, .. }) = higher::ForLoop::hir(expr)
&& let PatKind::Wild = pat.kind
&& let ExprKind::Struct(qpath, fields, None) = arg.kind
&& matches!(qpath, QPath::LangItem(LangItem::Range, _))
&& fields.len() == 2
&& fields[0].ident.as_str() == "start"
&& let ExprKind::Lit(ref lit) = fields[0].expr.kind
&& let LitKind::Int(0, LitIntType::Unsuffixed) = lit.node
&& fields[1].ident.as_str() == "end"
&& let ExprKind::Lit(ref lit1) = fields[1].expr.kind
&& let LitKind::Int(10, LitIntType::Unsuffixed) = lit1.node
&& let ExprKind::Block(block, None) = body.kind
&& block.stmts.len() == 1
&& let StmtKind::Semi(e) = block.stmts[0].kind
&& let ExprKind::Break(destination, None) = e.kind
&& destination.label.is_none()
&& block.expr.is_none()
{
// report your lint here
}
if let Some(higher::ForLoop { pat: pat, arg: arg, body: body, .. }) = higher::ForLoop::hir(expr)
&& let PatKind::Wild = pat.kind
&& let ExprKind::Struct(qpath, fields, None) = arg.kind
&& matches!(qpath, QPath::LangItem(LangItem::Range, _))
&& fields.len() == 2
&& fields[0].ident.as_str() == "start"
&& let ExprKind::Lit(ref lit) = fields[0].expr.kind
&& let LitKind::Int(0, LitIntType::Unsuffixed) = lit.node
&& fields[1].ident.as_str() == "end"
&& let ExprKind::Lit(ref lit1) = fields[1].expr.kind
&& let LitKind::Int(10, LitIntType::Unsuffixed) = lit1.node
&& let ExprKind::Block(block, None) = body.kind
&& block.stmts.len() == 1
&& let StmtKind::Semi(e) = block.stmts[0].kind
&& let ExprKind::Break(destination, None) = e.kind
&& let Some(label) = destination.label
&& label.ident.as_str() == "'label"
&& block.expr.is_none()
{
// report your lint here
}
if let Some(higher::While { condition: condition, body: body }) = higher::While::hir(expr)
&& let ExprKind::Path(ref qpath) = condition.kind
&& match_qpath(qpath, &["a"])
&& let ExprKind::Block(block, None) = body.kind
&& block.stmts.len() == 1
&& let StmtKind::Semi(e) = block.stmts[0].kind
&& let ExprKind::Break(destination, None) = e.kind
&& destination.label.is_none()
&& block.expr.is_none()
{
// report your lint here
}
if let Some(higher::WhileLet { let_pat: let_pat, let_expr: let_expr, if_then: if_then }) = higher::WhileLet::hir(expr)
&& let PatKind::Lit(lit_expr) = let_pat.kind
&& let ExprKind::Lit(ref lit) = lit_expr.kind
&& let LitKind::Bool(true) = lit.node
&& let ExprKind::Path(ref qpath) = let_expr.kind
&& match_qpath(qpath, &["a"])
&& let ExprKind::Block(block, None) = if_then.kind
&& block.stmts.len() == 1
&& let StmtKind::Semi(e) = block.stmts[0].kind
&& let ExprKind::Break(destination, None) = e.kind
&& destination.label.is_none()
&& block.expr.is_none()
{
// report your lint here
}
if let ExprKind::Loop(body, None, LoopSource::Loop, _) = expr.kind
&& body.stmts.len() == 1
&& let StmtKind::Semi(e) = body.stmts[0].kind
&& let ExprKind::Break(destination, None) = e.kind
&& destination.label.is_none()
&& body.expr.is_none()
{
// report your lint here
}

View file

@ -0,0 +1,5 @@
fn main() {
#[clippy::author]
let print_text = |x| println!("{}", x);
print_text("hello");
}

View file

@ -0,0 +1,41 @@
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
&& let ExprKind::Path(ref qpath) = func.kind
&& match_qpath(qpath, &["$crate", "io", "_print"])
&& args.len() == 1
&& let ExprKind::Call(func1, args1) = args[0].kind
&& let ExprKind::Path(ref qpath1) = func1.kind
&& match_qpath(qpath1, &["format_arguments", "new_v1"])
&& args1.len() == 2
&& let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner) = args1[0].kind
&& let ExprKind::Array(elements) = inner.kind
&& elements.len() == 2
&& let ExprKind::Lit(ref lit) = elements[0].kind
&& let LitKind::Str(s, _) = lit.node
&& s.as_str() == ""
&& let ExprKind::Lit(ref lit1) = elements[1].kind
&& let LitKind::Str(s1, _) = lit1.node
&& s1.as_str() == "\n"
&& let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner1) = args1[1].kind
&& let ExprKind::Array(elements1) = inner1.kind
&& elements1.len() == 1
&& let ExprKind::Call(func2, args2) = elements1[0].kind
&& let ExprKind::Path(ref qpath2) = func2.kind
&& match_qpath(qpath2, &["format_argument", "new_display"])
&& args2.len() == 1
&& let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner2) = args2[0].kind
&& let ExprKind::Path(ref qpath3) = inner2.kind
&& match_qpath(qpath3, &["x"])
&& block.expr.is_none()
&& let PatKind::Binding(BindingMode::NONE, _, name, None) = local.pat.kind
&& name.as_str() == "print_text"
{
// report your lint here
}

View file

@ -0,0 +1,8 @@
#![feature(stmt_expr_attributes)]
fn main() {
#[clippy::author]
for i in 0..1 {
println!("{}", i);
}
}

View file

@ -0,0 +1,50 @@
if let Some(higher::ForLoop { pat: pat, arg: arg, body: body, .. }) = higher::ForLoop::hir(expr)
&& let PatKind::Binding(BindingMode::NONE, _, name, None) = pat.kind
&& name.as_str() == "i"
&& let ExprKind::Struct(qpath, fields, None) = arg.kind
&& matches!(qpath, QPath::LangItem(LangItem::Range, _))
&& fields.len() == 2
&& fields[0].ident.as_str() == "start"
&& let ExprKind::Lit(ref lit) = fields[0].expr.kind
&& let LitKind::Int(0, LitIntType::Unsuffixed) = lit.node
&& fields[1].ident.as_str() == "end"
&& let ExprKind::Lit(ref lit1) = fields[1].expr.kind
&& let LitKind::Int(1, LitIntType::Unsuffixed) = lit1.node
&& let ExprKind::Block(block, None) = body.kind
&& block.stmts.len() == 1
&& let StmtKind::Semi(e) = block.stmts[0].kind
&& let ExprKind::Block(block1, None) = e.kind
&& block1.stmts.len() == 1
&& let StmtKind::Semi(e1) = block1.stmts[0].kind
&& let ExprKind::Call(func, args) = e1.kind
&& let ExprKind::Path(ref qpath1) = func.kind
&& match_qpath(qpath1, &["$crate", "io", "_print"])
&& args.len() == 1
&& let ExprKind::Call(func1, args1) = args[0].kind
&& let ExprKind::Path(ref qpath2) = func1.kind
&& match_qpath(qpath2, &["format_arguments", "new_v1"])
&& args1.len() == 2
&& let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner) = args1[0].kind
&& let ExprKind::Array(elements) = inner.kind
&& elements.len() == 2
&& let ExprKind::Lit(ref lit2) = elements[0].kind
&& let LitKind::Str(s, _) = lit2.node
&& s.as_str() == ""
&& let ExprKind::Lit(ref lit3) = elements[1].kind
&& let LitKind::Str(s1, _) = lit3.node
&& s1.as_str() == "\n"
&& let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner1) = args1[1].kind
&& let ExprKind::Array(elements1) = inner1.kind
&& elements1.len() == 1
&& let ExprKind::Call(func2, args2) = elements1[0].kind
&& let ExprKind::Path(ref qpath3) = func2.kind
&& match_qpath(qpath3, &["format_argument", "new_display"])
&& args2.len() == 1
&& let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner2) = args2[0].kind
&& let ExprKind::Path(ref qpath4) = inner2.kind
&& match_qpath(qpath4, &["i"])
&& block1.expr.is_none()
&& block.expr.is_none()
{
// report your lint here
}

View file

@ -0,0 +1,13 @@
#![allow(clippy::let_and_return)]
fn main() {
#[clippy::author]
let a = match 42 {
16 => 5,
17 => {
let x = 3;
x
},
_ => 1,
};
}

View file

@ -0,0 +1,36 @@
if let StmtKind::Let(local) = stmt.kind
&& let Some(init) = local.init
&& let ExprKind::Match(scrutinee, arms, MatchSource::Normal) = init.kind
&& let ExprKind::Lit(ref lit) = scrutinee.kind
&& let LitKind::Int(42, LitIntType::Unsuffixed) = lit.node
&& arms.len() == 3
&& let PatKind::Lit(lit_expr) = arms[0].pat.kind
&& let ExprKind::Lit(ref lit1) = lit_expr.kind
&& let LitKind::Int(16, LitIntType::Unsuffixed) = lit1.node
&& arms[0].guard.is_none()
&& let ExprKind::Lit(ref lit2) = arms[0].body.kind
&& let LitKind::Int(5, LitIntType::Unsuffixed) = lit2.node
&& let PatKind::Lit(lit_expr1) = arms[1].pat.kind
&& let ExprKind::Lit(ref lit3) = lit_expr1.kind
&& let LitKind::Int(17, LitIntType::Unsuffixed) = lit3.node
&& arms[1].guard.is_none()
&& let ExprKind::Block(block, None) = arms[1].body.kind
&& block.stmts.len() == 1
&& let StmtKind::Let(local1) = block.stmts[0].kind
&& let Some(init1) = local1.init
&& let ExprKind::Lit(ref lit4) = init1.kind
&& let LitKind::Int(3, LitIntType::Unsuffixed) = lit4.node
&& let PatKind::Binding(BindingMode::NONE, _, name, None) = local1.pat.kind
&& name.as_str() == "x"
&& let Some(trailing_expr) = block.expr
&& let ExprKind::Path(ref qpath) = trailing_expr.kind
&& match_qpath(qpath, &["x"])
&& let PatKind::Wild = arms[2].pat.kind
&& arms[2].guard.is_none()
&& let ExprKind::Lit(ref lit5) = arms[2].body.kind
&& let LitKind::Int(1, LitIntType::Unsuffixed) = lit5.node
&& let PatKind::Binding(BindingMode::NONE, _, name1, None) = local.pat.kind
&& name1.as_str() == "a"
{
// report your lint here
}

View file

@ -0,0 +1,5 @@
#[allow(clippy::no_effect)]
fn main() {
#[clippy::author]
[1_u8; 5];
}

View file

@ -0,0 +1,11 @@
if let ExprKind::Repeat(value, length) = expr.kind
&& let ExprKind::Lit(ref lit) = value.kind
&& let LitKind::Int(1, LitIntType::Unsigned(UintTy::U8)) = lit.node
&& let ArrayLen::Body(const_arg) = length
&& let ConstArgKind::Anon(anon_const) = const_arg.kind
&& expr1 = &cx.tcx.hir().body(anon_const.body).value
&& let ExprKind::Lit(ref lit1) = expr1.kind
&& let LitKind::Int(5, LitIntType::Unsuffixed) = lit1.node
{
// report your lint here
}

45
tests/ui/author/struct.rs Normal file
View file

@ -0,0 +1,45 @@
#![allow(
clippy::unnecessary_operation,
clippy::single_match,
clippy::no_effect,
clippy::bool_to_int_with_if
)]
fn main() {
struct Test {
field: u32,
}
#[clippy::author]
Test {
field: if true { 1 } else { 0 },
};
let test = Test { field: 1 };
match test {
#[clippy::author]
Test { field: 1 } => {},
_ => {},
}
struct TestTuple(u32);
let test_tuple = TestTuple(1);
match test_tuple {
#[clippy::author]
TestTuple(1) => {},
_ => {},
}
struct TestMethodCall(u32);
impl TestMethodCall {
fn test(&self) {}
}
let test_method_call = TestMethodCall(1);
#[clippy::author]
test_method_call.test();
}

View file

@ -0,0 +1,56 @@
if let ExprKind::Struct(qpath, fields, None) = expr.kind
&& match_qpath(qpath, &["Test"])
&& fields.len() == 1
&& fields[0].ident.as_str() == "field"
&& let ExprKind::If(cond, then, Some(else_expr)) = fields[0].expr.kind
&& let ExprKind::DropTemps(expr1) = cond.kind
&& let ExprKind::Lit(ref lit) = expr1.kind
&& let LitKind::Bool(true) = lit.node
&& let ExprKind::Block(block, None) = then.kind
&& block.stmts.is_empty()
&& let Some(trailing_expr) = block.expr
&& let ExprKind::Lit(ref lit1) = trailing_expr.kind
&& let LitKind::Int(1, LitIntType::Unsuffixed) = lit1.node
&& let ExprKind::Block(block1, None) = else_expr.kind
&& block1.stmts.is_empty()
&& let Some(trailing_expr1) = block1.expr
&& let ExprKind::Lit(ref lit2) = trailing_expr1.kind
&& let LitKind::Int(0, LitIntType::Unsuffixed) = lit2.node
{
// report your lint here
}
if let PatKind::Struct(ref qpath, fields, false) = arm.pat.kind
&& match_qpath(qpath, &["Test"])
&& fields.len() == 1
&& fields[0].ident.as_str() == "field"
&& let PatKind::Lit(lit_expr) = fields[0].pat.kind
&& let ExprKind::Lit(ref lit) = lit_expr.kind
&& let LitKind::Int(1, LitIntType::Unsuffixed) = lit.node
&& arm.guard.is_none()
&& let ExprKind::Block(block, None) = arm.body.kind
&& block.stmts.is_empty()
&& block.expr.is_none()
{
// report your lint here
}
if let PatKind::TupleStruct(ref qpath, fields, None) = arm.pat.kind
&& match_qpath(qpath, &["TestTuple"])
&& fields.len() == 1
&& let PatKind::Lit(lit_expr) = fields[0].kind
&& let ExprKind::Lit(ref lit) = lit_expr.kind
&& let LitKind::Int(1, LitIntType::Unsuffixed) = lit.node
&& arm.guard.is_none()
&& let ExprKind::Block(block, None) = arm.body.kind
&& block.stmts.is_empty()
&& block.expr.is_none()
{
// report your lint here
}
if let ExprKind::MethodCall(method_name, receiver, args, _) = expr.kind
&& method_name.ident.as_str() == "test"
&& let ExprKind::Path(ref qpath) = receiver.kind
&& match_qpath(qpath, &["test_method_call"])
&& args.is_empty()
{
// report your lint here
}