2021-10-29 01:39:41 +00:00
|
|
|
if_chain! {
|
2021-11-10 21:59:49 +00:00
|
|
|
if let ExprKind::DropTemps(expr) = expr.kind;
|
2021-11-10 21:42:49 +00:00
|
|
|
if let Some(higher::ForLoop { pat: pat, arg: arg, body: body, ..}) = higher::ForLoop::hir(expr);
|
2021-10-29 01:39:41 +00:00
|
|
|
if let PatKind::Binding(BindingAnnotation::Unannotated, _, name, None) = pat.kind;
|
|
|
|
if name.as_str() == "y";
|
2021-11-10 21:59:49 +00:00
|
|
|
if let ExprKind::Struct(qpath, fields, None) = arg.kind;
|
2021-11-08 23:05:37 +00:00
|
|
|
if matches!(qpath, QPath::LangItem(LangItem::Range, _));
|
2021-10-29 01:39:41 +00:00
|
|
|
if fields.len() == 2;
|
2021-11-10 21:42:49 +00:00
|
|
|
if fields[0].ident.name.as_str() == "start";
|
|
|
|
if let ExprKind::Lit(ref lit) = fields[0].expr.kind;
|
2021-10-29 01:39:41 +00:00
|
|
|
if let LitKind::Int(0, LitIntType::Unsuffixed) = lit.node;
|
2021-11-10 21:42:49 +00:00
|
|
|
if fields[1].ident.name.as_str() == "end";
|
|
|
|
if let ExprKind::Lit(ref lit1) = fields[1].expr.kind;
|
2021-10-29 01:39:41 +00:00
|
|
|
if let LitKind::Int(10, LitIntType::Unsuffixed) = lit1.node;
|
2021-11-10 21:59:49 +00:00
|
|
|
if let ExprKind::Block(block, label) = body.kind;
|
2021-10-29 01:39:41 +00:00
|
|
|
if block.stmts.len() == 1;
|
2021-11-10 21:59:49 +00:00
|
|
|
if let StmtKind::Local(local) = block.stmts[0].kind;
|
|
|
|
if let Some(init) = local.init;
|
2021-11-08 23:05:37 +00:00
|
|
|
if let ExprKind::Path(ref qpath1) = init.kind;
|
|
|
|
if match_qpath(qpath1, &["y"]);
|
2021-10-29 01:39:41 +00:00
|
|
|
if let PatKind::Binding(BindingAnnotation::Unannotated, _, name1, None) = local.pat.kind;
|
|
|
|
if name1.as_str() == "z";
|
|
|
|
if block.expr.is_none();
|
|
|
|
then {
|
|
|
|
// report your lint here
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if_chain! {
|
2021-11-10 21:59:49 +00:00
|
|
|
if let ExprKind::DropTemps(expr) = expr.kind;
|
2021-11-10 21:42:49 +00:00
|
|
|
if let Some(higher::ForLoop { pat: pat, arg: arg, body: body, ..}) = higher::ForLoop::hir(expr);
|
2021-10-29 01:39:41 +00:00
|
|
|
if let PatKind::Wild = pat.kind;
|
2021-11-10 21:59:49 +00:00
|
|
|
if let ExprKind::Struct(qpath, fields, None) = arg.kind;
|
2021-11-08 23:05:37 +00:00
|
|
|
if matches!(qpath, QPath::LangItem(LangItem::Range, _));
|
2021-10-29 01:39:41 +00:00
|
|
|
if fields.len() == 2;
|
2021-11-10 21:42:49 +00:00
|
|
|
if fields[0].ident.name.as_str() == "start";
|
|
|
|
if let ExprKind::Lit(ref lit) = fields[0].expr.kind;
|
2021-10-29 01:39:41 +00:00
|
|
|
if let LitKind::Int(0, LitIntType::Unsuffixed) = lit.node;
|
2021-11-10 21:42:49 +00:00
|
|
|
if fields[1].ident.name.as_str() == "end";
|
|
|
|
if let ExprKind::Lit(ref lit1) = fields[1].expr.kind;
|
2021-10-29 01:39:41 +00:00
|
|
|
if let LitKind::Int(10, LitIntType::Unsuffixed) = lit1.node;
|
2021-11-10 21:59:49 +00:00
|
|
|
if let ExprKind::Block(block, label) = body.kind;
|
2021-10-29 01:39:41 +00:00
|
|
|
if block.stmts.len() == 1;
|
2021-11-10 21:59:49 +00:00
|
|
|
if let StmtKind::Semi(e) = block.stmts[0].kind;
|
|
|
|
if let ExprKind::Break(destination, None) = e.kind;
|
2021-10-29 01:39:41 +00:00
|
|
|
if block.expr.is_none();
|
|
|
|
then {
|
|
|
|
// report your lint here
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if_chain! {
|
2021-11-10 21:59:49 +00:00
|
|
|
if let ExprKind::DropTemps(expr) = expr.kind;
|
2021-11-10 21:42:49 +00:00
|
|
|
if let Some(higher::ForLoop { pat: pat, arg: arg, body: body, ..}) = higher::ForLoop::hir(expr);
|
2021-10-29 01:39:41 +00:00
|
|
|
if let PatKind::Wild = pat.kind;
|
2021-11-10 21:59:49 +00:00
|
|
|
if let ExprKind::Struct(qpath, fields, None) = arg.kind;
|
2021-11-08 23:05:37 +00:00
|
|
|
if matches!(qpath, QPath::LangItem(LangItem::Range, _));
|
2021-10-29 01:39:41 +00:00
|
|
|
if fields.len() == 2;
|
2021-11-10 21:42:49 +00:00
|
|
|
if fields[0].ident.name.as_str() == "start";
|
|
|
|
if let ExprKind::Lit(ref lit) = fields[0].expr.kind;
|
2021-10-29 01:39:41 +00:00
|
|
|
if let LitKind::Int(0, LitIntType::Unsuffixed) = lit.node;
|
2021-11-10 21:42:49 +00:00
|
|
|
if fields[1].ident.name.as_str() == "end";
|
|
|
|
if let ExprKind::Lit(ref lit1) = fields[1].expr.kind;
|
2021-10-29 01:39:41 +00:00
|
|
|
if let LitKind::Int(10, LitIntType::Unsuffixed) = lit1.node;
|
2021-11-10 21:59:49 +00:00
|
|
|
if let ExprKind::Block(block, label) = body.kind;
|
2021-10-29 01:39:41 +00:00
|
|
|
if block.stmts.len() == 1;
|
2021-11-10 21:59:49 +00:00
|
|
|
if let StmtKind::Semi(e) = block.stmts[0].kind;
|
|
|
|
if let ExprKind::Break(destination, None) = e.kind;
|
|
|
|
if let Some(label1) = destination.label;
|
2021-10-29 01:39:41 +00:00
|
|
|
if label_name.ident.name.as_str() == "'label";
|
|
|
|
if block.expr.is_none();
|
|
|
|
then {
|
|
|
|
// report your lint here
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if_chain! {
|
2021-11-10 21:42:49 +00:00
|
|
|
if let Some(higher::While { condition: condition, body: body }) = higher::While::hir(expr);
|
2021-11-08 23:05:37 +00:00
|
|
|
if let ExprKind::Path(ref qpath) = condition.kind;
|
|
|
|
if match_qpath(qpath, &["a"]);
|
2021-11-10 21:59:49 +00:00
|
|
|
if let ExprKind::Block(block, label) = body.kind;
|
2021-10-29 01:39:41 +00:00
|
|
|
if block.stmts.len() == 1;
|
2021-11-10 21:59:49 +00:00
|
|
|
if let StmtKind::Semi(e) = block.stmts[0].kind;
|
|
|
|
if let ExprKind::Break(destination, None) = e.kind;
|
2021-10-29 01:39:41 +00:00
|
|
|
if block.expr.is_none();
|
|
|
|
then {
|
|
|
|
// report your lint here
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if_chain! {
|
2021-11-10 21:42:49 +00:00
|
|
|
if let Some(higher::WhileLet { let_pat: let_pat, let_expr: let_expr, if_then: if_then }) = higher::WhileLet::hir(expr);
|
2021-11-10 21:59:49 +00:00
|
|
|
if let PatKind::Lit(lit_expr) = let_pat.kind;
|
2021-10-29 01:39:41 +00:00
|
|
|
if let ExprKind::Lit(ref lit) = lit_expr.kind;
|
|
|
|
if let LitKind::Bool(true) = lit.node;
|
2021-11-08 23:05:37 +00:00
|
|
|
if let ExprKind::Path(ref qpath) = let_expr.kind;
|
|
|
|
if match_qpath(qpath, &["a"]);
|
2021-11-10 21:59:49 +00:00
|
|
|
if let ExprKind::Block(block, label) = if_then.kind;
|
2021-10-29 01:39:41 +00:00
|
|
|
if block.stmts.len() == 1;
|
2021-11-10 21:59:49 +00:00
|
|
|
if let StmtKind::Semi(e) = block.stmts[0].kind;
|
|
|
|
if let ExprKind::Break(destination, None) = e.kind;
|
2021-10-29 01:39:41 +00:00
|
|
|
if block.expr.is_none();
|
|
|
|
then {
|
|
|
|
// report your lint here
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if_chain! {
|
2021-11-10 21:59:49 +00:00
|
|
|
if let ExprKind::Loop(body, label, LoopSource::Loop, _) = expr.kind;
|
2021-10-29 01:39:41 +00:00
|
|
|
if body.stmts.len() == 1;
|
2021-11-10 21:59:49 +00:00
|
|
|
if let StmtKind::Semi(e) = body.stmts[0].kind;
|
|
|
|
if let ExprKind::Break(destination, None) = e.kind;
|
2021-10-29 01:39:41 +00:00
|
|
|
if body.expr.is_none();
|
|
|
|
then {
|
|
|
|
// report your lint here
|
|
|
|
}
|
|
|
|
}
|