Auto merge of #7956 - camsteffen:author, r=llogiq

Author improvements

changelog: none

Various aspects of the author implementation are re-imagined to be much less repetitive. Also fixes some bugs. I hope this makes author more fun to work on for future contributors.

The last commit is pretty heavy but I tried to at least separate some changes so that the test file diffs per commit are simple.
This commit is contained in:
bors 2021-11-11 19:33:06 +00:00
commit 8b84a760ca
11 changed files with 674 additions and 1054 deletions

View File

@ -2,6 +2,7 @@
#![feature(box_patterns)]
#![feature(drain_filter)]
#![feature(format_args_capture)]
#![feature(in_band_lifetimes)]
#![feature(iter_zip)]
#![feature(once_cell)]

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,9 @@
if_chain! {
if let StmtKind::Local(ref local) = stmt.kind;
if let Some(ref init) = local.init;
if let ExprKind::Cast(ref expr, ref cast_ty) = init.kind;
if let TyKind::Path(ref qp) = cast_ty.kind;
if match_qpath(qp, &["char"]);
if let StmtKind::Local(local) = stmt.kind;
if let Some(init) = local.init;
if let ExprKind::Cast(expr, cast_ty) = init.kind;
if let TyKind::Path(ref qpath) = cast_ty.kind;
if match_qpath(qpath, &["char"]);
if let ExprKind::Lit(ref lit) = expr.kind;
if let LitKind::Int(69, LitIntType::Unsuffixed) = lit.node;
if let PatKind::Binding(BindingAnnotation::Unannotated, _, name, None) = local.pat.kind;

View File

@ -1,62 +1,62 @@
if_chain! {
if let ExprKind::Block(ref block, ref label) = expr.kind;
if let ExprKind::Block(block, None) = expr.kind;
if block.stmts.len() == 3;
if let StmtKind::Local(ref local) = block.stmts[0].kind;
if let Some(ref init) = local.init;
if let StmtKind::Local(local) = block.stmts[0].kind;
if let Some(init) = local.init;
if let ExprKind::Lit(ref lit) = init.kind;
if let LitKind::Int(42, LitIntType::Signed(IntTy::I32)) = lit.node;
if let PatKind::Binding(BindingAnnotation::Unannotated, _, name, None) = local.pat.kind;
if name.as_str() == "x";
if let StmtKind::Local(ref local1) = block.stmts[1].kind;
if let Some(ref init1) = local1.init;
if let StmtKind::Local(local1) = block.stmts[1].kind;
if let Some(init1) = local1.init;
if let ExprKind::Lit(ref lit1) = init1.kind;
if let LitKind::Float(_, LitFloatType::Suffixed(FloatTy::F32)) = lit1.node;
if let PatKind::Binding(BindingAnnotation::Unannotated, _, name1, None) = local1.pat.kind;
if name1.as_str() == "_t";
if let StmtKind::Semi(ref e, _) = block.stmts[2].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 let StmtKind::Semi(e) = block.stmts[2].kind;
if let ExprKind::Unary(UnOp::Neg, inner) = e.kind;
if let ExprKind::Path(ref qpath) = inner.kind;
if match_qpath(qpath, &["x"]);
if block.expr.is_none();
then {
// report your lint here
}
}
if_chain! {
if let ExprKind::Block(ref block, ref label) = expr.kind;
if let ExprKind::Block(block, None) = 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 StmtKind::Local(local) = block.stmts[0].kind;
if let Some(init) = local.init;
if let ExprKind::Call(func, args) = init.kind;
if let ExprKind::Path(ref qpath) = func.kind;
if match_qpath(qpath, &["String", "new"]);
if args.is_empty();
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 let Some(trailing_expr) = block.expr;
if let ExprKind::Call(func1, args1) = trailing_expr.kind;
if let ExprKind::Path(ref qpath1) = func1.kind;
if match_qpath(qpath1, &["drop"]);
if args1.len() == 1;
if let ExprKind::Path(ref path2) = args1[0].kind;
if match_qpath(path2, &["expr"]);
if let ExprKind::Path(ref qpath2) = args1[0].kind;
if match_qpath(qpath2, &["expr"]);
then {
// report your lint here
}
}
if_chain! {
if let ExprKind::Closure(CaptureBy::Value, ref fn_decl, ref body_id, _, None) = expr.kind
if let FnRetTy::DefaultReturn(_) = fn_decl.output
let body = cx.tcx.hir().body(body_id);
if let ExprKind::Call(ref func, ref args) = body.value.kind;
if let ExprKind::Path(ref path) = func.kind;
if matches!(path, QPath::LangItem(LangItem::FromGenerator, _));
if let ExprKind::Closure(CaptureBy::Value, fn_decl, body_id, _, None) = expr.kind;
if let FnRetTy::DefaultReturn(_) = fn_decl.output;
let expr1 = &cx.tcx.hir().body(body_id).value;
if let ExprKind::Call(func, args) = expr1.kind;
if let ExprKind::Path(ref qpath) = func.kind;
if matches!(qpath, QPath::LangItem(LangItem::FromGenerator, _));
if args.len() == 1;
if let ExprKind::Closure(CaptureBy::Value, ref fn_decl1, ref body_id1, _, Some(Movability::Static)) = args[0].kind
if let FnRetTy::DefaultReturn(_) = fn_decl1.output
let body1 = cx.tcx.hir().body(body_id1);
if let ExprKind::Block(ref block, ref label) = body1.value.kind;
if block.stmts.len() == 0;
if let ExprKind::Closure(CaptureBy::Value, fn_decl1, body_id1, _, Some(Movability::Static)) = args[0].kind;
if let FnRetTy::DefaultReturn(_) = fn_decl1.output;
let expr2 = &cx.tcx.hir().body(body_id1).value;
if let ExprKind::Block(block, None) = expr2.kind;
if block.stmts.is_empty();
if block.expr.is_none();
then {
// report your lint here

View File

@ -1,9 +1,9 @@
if_chain! {
if let StmtKind::Local(ref local) = stmt.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, &["{{root}}", "std", "cmp", "min"]);
if let StmtKind::Local(local) = stmt.kind;
if let Some(init) = local.init;
if let ExprKind::Call(func, args) = init.kind;
if let ExprKind::Path(ref qpath) = func.kind;
if match_qpath(qpath, &["{{root}}", "std", "cmp", "min"]);
if args.len() == 2;
if let ExprKind::Lit(ref lit) = args[0].kind;
if let LitKind::Int(3, LitIntType::Unsuffixed) = lit.node;

View File

@ -1,23 +1,24 @@
if_chain! {
if let StmtKind::Local(ref local) = stmt.kind;
if let Some(ref init) = local.init;
if let Some(higher::If { cond: cond, then: then, r#else: else_expr}) = higher::If::hir(init)
if let ExprKind::Lit(ref lit) = cond.kind;
if let StmtKind::Local(local) = stmt.kind;
if let Some(init) = local.init;
if let ExprKind::If(cond, then, Some(else_expr)) = init.kind;
if let ExprKind::DropTemps(expr) = cond.kind;
if let ExprKind::Lit(ref lit) = expr.kind;
if let LitKind::Bool(true) = lit.node;
if let ExprKind::Block(ref block, ref label) = then.kind;
if let ExprKind::Block(block, None) = then.kind;
if block.stmts.len() == 1;
if let StmtKind::Semi(ref e, _) = block.stmts[0].kind
if let ExprKind::Binary(ref op, ref left, ref right) = e.kind;
if let StmtKind::Semi(e) = block.stmts[0].kind;
if let ExprKind::Binary(op, left, right) = e.kind;
if BinOpKind::Eq == op.node;
if let ExprKind::Lit(ref lit1) = left.kind;
if let LitKind::Int(1, LitIntType::Unsuffixed) = lit1.node;
if let ExprKind::Lit(ref lit2) = right.kind;
if let LitKind::Int(1, LitIntType::Unsuffixed) = lit2.node;
if block.expr.is_none();
if let ExprKind::Block(ref block1, ref label1) = else_expr.kind;
if let ExprKind::Block(block1, None) = else_expr.kind;
if block1.stmts.len() == 1;
if let StmtKind::Semi(ref e1, _) = block1.stmts[0].kind
if let ExprKind::Binary(ref op1, ref left1, ref right1) = e1.kind;
if let StmtKind::Semi(e1) = block1.stmts[0].kind;
if let ExprKind::Binary(op1, left1, right1) = e1.kind;
if BinOpKind::Eq == op1.node;
if let ExprKind::Lit(ref lit3) = left1.kind;
if let LitKind::Int(2, LitIntType::Unsuffixed) = lit3.node;
@ -30,17 +31,18 @@ if_chain! {
}
}
if_chain! {
if let Some(higher::IfLet { let_pat: let_pat, let_expr: let_expr, if_then: if_then, if_else: else_expr}) = higher::IfLet::hir(expr)
if let PatKind::Lit(ref lit_expr) = let_pat.kind
if let ExprKind::If(cond, then, Some(else_expr)) = expr.kind;
if let ExprKind::Let(pat, expr1, _) = cond.kind;
if let PatKind::Lit(lit_expr) = pat.kind;
if let ExprKind::Lit(ref lit) = lit_expr.kind;
if let LitKind::Bool(true) = lit.node;
if let ExprKind::Path(ref path) = let_expr.kind;
if match_qpath(path, &["a"]);
if let ExprKind::Block(ref block, ref label) = if_then.kind;
if block.stmts.len() == 0;
if let ExprKind::Path(ref qpath) = expr1.kind;
if match_qpath(qpath, &["a"]);
if let ExprKind::Block(block, None) = then.kind;
if block.stmts.is_empty();
if block.expr.is_none();
if let ExprKind::Block(ref block1, ref label1) = else_expr.kind;
if block1.stmts.len() == 0;
if let ExprKind::Block(block1, None) = else_expr.kind;
if block1.stmts.is_empty();
if block1.expr.is_none();
then {
// report your lint here

View File

@ -1,12 +1,12 @@
if_chain! {
if let StmtKind::Local(ref local) = stmt.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, &["std", "mem", "transmute"]);
if let StmtKind::Local(local) = stmt.kind;
if let Some(init) = local.init;
if let ExprKind::Call(func, args) = init.kind;
if let ExprKind::Path(ref qpath) = func.kind;
if match_qpath(qpath, &["std", "mem", "transmute"]);
if args.len() == 1;
if let ExprKind::Path(ref path1) = args[0].kind;
if match_qpath(path1, &["ZPTR"]);
if let ExprKind::Path(ref qpath1) = args[0].kind;
if match_qpath(qpath1, &["ZPTR"]);
if let PatKind::Wild = local.pat.kind;
then {
// report your lint here

View File

@ -1,23 +1,23 @@
if_chain! {
if let ExprKind::DropTemps(ref expr) = expr.kind;
if let Some(higher::ForLoop { pat: pat, arg: arg, body: body, ..}) = higher::ForLoop::hir(expr)
if let ExprKind::DropTemps(expr1) = expr.kind;
if let Some(higher::ForLoop { pat: pat, arg: arg, body: body, .. }) = higher::ForLoop::hir(expr1);
if let PatKind::Binding(BindingAnnotation::Unannotated, _, name, None) = pat.kind;
if name.as_str() == "y";
if let ExprKind::Struct(ref path, ref fields, None) = arg.kind;
if matches!(path, QPath::LangItem(LangItem::Range, _));
if let ExprKind::Struct(qpath, fields, None) = arg.kind;
if matches!(qpath, QPath::LangItem(LangItem::Range, _));
if fields.len() == 2;
if fields[0].ident.name.as_str() == "start"
if let ExprKind::Lit(ref lit) = fields[0].kind;
if fields[0].ident.as_str() == "start";
if let ExprKind::Lit(ref lit) = fields[0].expr.kind;
if let LitKind::Int(0, LitIntType::Unsuffixed) = lit.node;
if fields[1].ident.name.as_str() == "end"
if let ExprKind::Lit(ref lit1) = fields[1].kind;
if fields[1].ident.as_str() == "end";
if let ExprKind::Lit(ref lit1) = fields[1].expr.kind;
if let LitKind::Int(10, LitIntType::Unsuffixed) = lit1.node;
if let ExprKind::Block(ref block, ref label) = body.kind;
if let ExprKind::Block(block, None) = body.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::Path(ref path1) = init.kind;
if match_qpath(path1, &["y"]);
if let StmtKind::Local(local) = block.stmts[0].kind;
if let Some(init) = local.init;
if let ExprKind::Path(ref qpath1) = init.kind;
if match_qpath(qpath1, &["y"]);
if let PatKind::Binding(BindingAnnotation::Unannotated, _, name1, None) = local.pat.kind;
if name1.as_str() == "z";
if block.expr.is_none();
@ -26,85 +26,89 @@ if_chain! {
}
}
if_chain! {
if let ExprKind::DropTemps(ref expr) = expr.kind;
if let Some(higher::ForLoop { pat: pat, arg: arg, body: body, ..}) = higher::ForLoop::hir(expr)
if let ExprKind::DropTemps(expr1) = expr.kind;
if let Some(higher::ForLoop { pat: pat, arg: arg, body: body, .. }) = higher::ForLoop::hir(expr1);
if let PatKind::Wild = pat.kind;
if let ExprKind::Struct(ref path, ref fields, None) = arg.kind;
if matches!(path, QPath::LangItem(LangItem::Range, _));
if let ExprKind::Struct(qpath, fields, None) = arg.kind;
if matches!(qpath, QPath::LangItem(LangItem::Range, _));
if fields.len() == 2;
if fields[0].ident.name.as_str() == "start"
if let ExprKind::Lit(ref lit) = fields[0].kind;
if fields[0].ident.as_str() == "start";
if let ExprKind::Lit(ref lit) = fields[0].expr.kind;
if let LitKind::Int(0, LitIntType::Unsuffixed) = lit.node;
if fields[1].ident.name.as_str() == "end"
if let ExprKind::Lit(ref lit1) = fields[1].kind;
if fields[1].ident.as_str() == "end";
if let ExprKind::Lit(ref lit1) = fields[1].expr.kind;
if let LitKind::Int(10, LitIntType::Unsuffixed) = lit1.node;
if let ExprKind::Block(ref block, ref label) = body.kind;
if let ExprKind::Block(block, None) = body.kind;
if block.stmts.len() == 1;
if let StmtKind::Semi(ref e, _) = block.stmts[0].kind
if let ExprKind::Break(ref destination, None) = e.kind;
if let StmtKind::Semi(e) = block.stmts[0].kind;
if let ExprKind::Break(destination, None) = e.kind;
if destination.label.is_none();
if block.expr.is_none();
then {
// report your lint here
}
}
if_chain! {
if let ExprKind::DropTemps(ref expr) = expr.kind;
if let Some(higher::ForLoop { pat: pat, arg: arg, body: body, ..}) = higher::ForLoop::hir(expr)
if let ExprKind::DropTemps(expr1) = expr.kind;
if let Some(higher::ForLoop { pat: pat, arg: arg, body: body, .. }) = higher::ForLoop::hir(expr1);
if let PatKind::Wild = pat.kind;
if let ExprKind::Struct(ref path, ref fields, None) = arg.kind;
if matches!(path, QPath::LangItem(LangItem::Range, _));
if let ExprKind::Struct(qpath, fields, None) = arg.kind;
if matches!(qpath, QPath::LangItem(LangItem::Range, _));
if fields.len() == 2;
if fields[0].ident.name.as_str() == "start"
if let ExprKind::Lit(ref lit) = fields[0].kind;
if fields[0].ident.as_str() == "start";
if let ExprKind::Lit(ref lit) = fields[0].expr.kind;
if let LitKind::Int(0, LitIntType::Unsuffixed) = lit.node;
if fields[1].ident.name.as_str() == "end"
if let ExprKind::Lit(ref lit1) = fields[1].kind;
if fields[1].ident.as_str() == "end";
if let ExprKind::Lit(ref lit1) = fields[1].expr.kind;
if let LitKind::Int(10, LitIntType::Unsuffixed) = lit1.node;
if let ExprKind::Block(ref block, ref label) = body.kind;
if let ExprKind::Block(block, None) = body.kind;
if block.stmts.len() == 1;
if let StmtKind::Semi(ref e, _) = block.stmts[0].kind
if let ExprKind::Break(ref destination, None) = e.kind;
if let Some(ref label1) = destination.label
if label_name.ident.name.as_str() == "'label";
if let StmtKind::Semi(e) = block.stmts[0].kind;
if let ExprKind::Break(destination, None) = e.kind;
if let Some(label) = destination.label;
if label.ident.as_str() == "'label";
if block.expr.is_none();
then {
// report your lint here
}
}
if_chain! {
if let Some(higher::While { condition: condition, body: body }) = higher::While::hir(expr)
if let ExprKind::Path(ref path) = condition.kind;
if match_qpath(path, &["a"]);
if let ExprKind::Block(ref block, ref label) = body.kind;
if let Some(higher::While { condition: condition, body: body }) = higher::While::hir(expr);
if let ExprKind::Path(ref qpath) = condition.kind;
if match_qpath(qpath, &["a"]);
if let ExprKind::Block(block, None) = body.kind;
if block.stmts.len() == 1;
if let StmtKind::Semi(ref e, _) = block.stmts[0].kind
if let ExprKind::Break(ref destination, None) = e.kind;
if let StmtKind::Semi(e) = block.stmts[0].kind;
if let ExprKind::Break(destination, None) = e.kind;
if destination.label.is_none();
if block.expr.is_none();
then {
// report your lint here
}
}
if_chain! {
if let Some(higher::WhileLet { let_pat: let_pat, let_expr: let_expr, if_then: if_then }) = higher::WhileLet::hir(expr)
if let PatKind::Lit(ref lit_expr) = let_pat.kind
if let Some(higher::WhileLet { let_pat: let_pat, let_expr: let_expr, if_then: if_then }) = higher::WhileLet::hir(expr);
if let PatKind::Lit(lit_expr) = let_pat.kind;
if let ExprKind::Lit(ref lit) = lit_expr.kind;
if let LitKind::Bool(true) = lit.node;
if let ExprKind::Path(ref path) = let_expr.kind;
if match_qpath(path, &["a"]);
if let ExprKind::Block(ref block, ref label) = if_then.kind;
if let ExprKind::Path(ref qpath) = let_expr.kind;
if match_qpath(qpath, &["a"]);
if let ExprKind::Block(block, None) = if_then.kind;
if block.stmts.len() == 1;
if let StmtKind::Semi(ref e, _) = block.stmts[0].kind
if let ExprKind::Break(ref destination, None) = e.kind;
if let StmtKind::Semi(e) = block.stmts[0].kind;
if let ExprKind::Break(destination, None) = e.kind;
if destination.label.is_none();
if block.expr.is_none();
then {
// report your lint here
}
}
if_chain! {
if let ExprKind::Loop(ref body, ref label, LoopSource::Loop) = expr.kind;
if let ExprKind::Loop(body, None, LoopSource::Loop, _) = expr.kind;
if body.stmts.len() == 1;
if let StmtKind::Semi(ref e, _) = body.stmts[0].kind
if let ExprKind::Break(ref destination, None) = e.kind;
if let StmtKind::Semi(e) = body.stmts[0].kind;
if let ExprKind::Break(destination, None) = e.kind;
if destination.label.is_none();
if body.expr.is_none();
then {
// report your lint here

View File

@ -1,32 +1,35 @@
if_chain! {
if let StmtKind::Local(ref local) = stmt.kind;
if let Some(ref init) = local.init;
if let ExprKind::Match(ref expr, ref arms, MatchSource::Normal) = init.kind;
if let ExprKind::Lit(ref lit) = expr.kind;
if let StmtKind::Local(local) = stmt.kind;
if let Some(init) = local.init;
if let ExprKind::Match(scrutinee, arms, MatchSource::Normal) = init.kind;
if let ExprKind::Lit(ref lit) = scrutinee.kind;
if let LitKind::Int(42, LitIntType::Unsuffixed) = lit.node;
if arms.len() == 3;
if let ExprKind::Lit(ref lit1) = arms[0].body.kind;
if let LitKind::Int(5, LitIntType::Unsuffixed) = lit1.node;
if let PatKind::Lit(ref lit_expr) = arms[0].pat.kind
if let ExprKind::Lit(ref lit2) = lit_expr.kind;
if let LitKind::Int(16, LitIntType::Unsuffixed) = lit2.node;
if let ExprKind::Block(ref block, ref label) = arms[1].body.kind;
if let PatKind::Lit(lit_expr) = arms[0].pat.kind;
if let ExprKind::Lit(ref lit1) = lit_expr.kind;
if let LitKind::Int(16, LitIntType::Unsuffixed) = lit1.node;
if arms[0].guard.is_none();
if let ExprKind::Lit(ref lit2) = arms[0].body.kind;
if let LitKind::Int(5, LitIntType::Unsuffixed) = lit2.node;
if let PatKind::Lit(lit_expr1) = arms[1].pat.kind;
if let ExprKind::Lit(ref lit3) = lit_expr1.kind;
if let LitKind::Int(17, LitIntType::Unsuffixed) = lit3.node;
if arms[1].guard.is_none();
if let ExprKind::Block(block, None) = arms[1].body.kind;
if block.stmts.len() == 1;
if let StmtKind::Local(ref local1) = block.stmts[0].kind;
if let Some(ref init1) = local1.init;
if let ExprKind::Lit(ref lit3) = init1.kind;
if let LitKind::Int(3, LitIntType::Unsuffixed) = lit3.node;
if let StmtKind::Local(local1) = block.stmts[0].kind;
if let Some(init1) = local1.init;
if let ExprKind::Lit(ref lit4) = init1.kind;
if let LitKind::Int(3, LitIntType::Unsuffixed) = lit4.node;
if let PatKind::Binding(BindingAnnotation::Unannotated, _, name, None) = local1.pat.kind;
if name.as_str() == "x";
if let Some(trailing_expr) = &block.expr;
if let ExprKind::Path(ref path) = trailing_expr.kind;
if match_qpath(path, &["x"]);
if let PatKind::Lit(ref lit_expr1) = arms[1].pat.kind
if let ExprKind::Lit(ref lit4) = lit_expr1.kind;
if let LitKind::Int(17, LitIntType::Unsuffixed) = lit4.node;
if let Some(trailing_expr) = block.expr;
if let ExprKind::Path(ref qpath) = trailing_expr.kind;
if match_qpath(qpath, &["x"]);
if let PatKind::Wild = arms[2].pat.kind;
if arms[2].guard.is_none();
if let ExprKind::Lit(ref lit5) = arms[2].body.kind;
if let LitKind::Int(1, LitIntType::Unsuffixed) = lit5.node;
if let PatKind::Wild = arms[2].pat.kind;
if let PatKind::Binding(BindingAnnotation::Unannotated, _, name1, None) = local.pat.kind;
if name1.as_str() == "a";
then {

View File

@ -1,8 +1,9 @@
if_chain! {
if let ExprKind::Repeat(ref value, ref length) = expr.kind;
if let ExprKind::Repeat(value, length) = expr.kind;
if let ExprKind::Lit(ref lit) = value.kind;
if let LitKind::Int(1, LitIntType::Unsigned(UintTy::U8)) = lit.node;
if let ExprKind::Lit(ref lit1) = length.value.kind;
let expr1 = &cx.tcx.hir().body(length.body).value;
if let ExprKind::Lit(ref lit1) = expr1.kind;
if let LitKind::Int(5, LitIntType::Unsuffixed) = lit1.node;
then {
// report your lint here

View File

@ -1,19 +1,20 @@
if_chain! {
if let ExprKind::Struct(ref path, ref fields, None) = expr.kind;
if match_qpath(path, &["Test"]);
if let ExprKind::Struct(qpath, 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])
if let ExprKind::Lit(ref lit) = cond.kind;
if fields[0].ident.as_str() == "field";
if let ExprKind::If(cond, then, Some(else_expr)) = fields[0].expr.kind;
if let ExprKind::DropTemps(expr1) = cond.kind;
if let ExprKind::Lit(ref lit) = expr1.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::Block(block, None) = then.kind;
if block.stmts.is_empty();
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::Block(block1, None) = else_expr.kind;
if block1.stmts.is_empty();
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 {
@ -21,40 +22,42 @@ if_chain! {
}
}
if_chain! {
if let PatKind::Struct(ref path, ref fields, false) = arm.kind;
if match_qpath(path, &["Test"]);
if let PatKind::Struct(ref qpath, fields, false) = arm.pat.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 fields[0].ident.as_str() == "field";
if let PatKind::Lit(lit_expr) = fields[0].pat.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 arm.guard.is_none();
if let ExprKind::Block(block, None) = arm.body.kind;
if block.stmts.is_empty();
if block.expr.is_none();
then {
// report your lint here
}
}
if_chain! {
if let PatKind::TupleStruct(ref path, ref fields, None) = arm.kind;
if match_qpath(path, &["TestTuple"]);
if let PatKind::TupleStruct(ref qpath, fields, None) = arm.pat.kind;
if match_qpath(qpath, &["TestTuple"]);
if fields.len() == 1;
if let PatKind::Lit(ref lit_expr) = fields[0].kind
if let PatKind::Lit(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 arm.guard.is_none();
if let ExprKind::Block(block, None) = arm.body.kind;
if block.stmts.is_empty();
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 let ExprKind::MethodCall(method_name, _, args, _) = expr.kind;
if method_name.ident.as_str() == "test";
if args.len() == 1;
if let ExprKind::Path(ref path) = args[0].kind;
if match_qpath(path, &["test_method_call"]);
if let ExprKind::Path(ref qpath) = args[0].kind;
if match_qpath(qpath, &["test_method_call"]);
then {
// report your lint here
}