113 lines
4.7 KiB
Plaintext
113 lines
4.7 KiB
Plaintext
|
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 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 fields.len() == 2;
|
||
|
if fields[0].ident.name.as_str() == "start"
|
||
|
if let ExprKind::Lit(ref lit) = fields[0].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 let LitKind::Int(10, LitIntType::Unsuffixed) = lit1.node;
|
||
|
if let ExprKind::Block(ref block, ref label) = 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 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! {
|
||
|
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 PatKind::Wild = pat.kind;
|
||
|
if let ExprKind::Struct(ref path, ref fields, None) = arg.kind;
|
||
|
if matches!(path, 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 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 let LitKind::Int(10, LitIntType::Unsuffixed) = lit1.node;
|
||
|
if let ExprKind::Block(ref block, ref label) = 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 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 PatKind::Wild = pat.kind;
|
||
|
if let ExprKind::Struct(ref path, ref fields, None) = arg.kind;
|
||
|
if matches!(path, 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 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 let LitKind::Int(10, LitIntType::Unsuffixed) = lit1.node;
|
||
|
if let ExprKind::Block(ref block, ref label) = 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 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 block.stmts.len() == 1;
|
||
|
if let StmtKind::Semi(ref e, _) = block.stmts[0].kind
|
||
|
if let ExprKind::Break(ref destination, None) = e.kind;
|
||
|
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 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() == 1;
|
||
|
if let StmtKind::Semi(ref e, _) = block.stmts[0].kind
|
||
|
if let ExprKind::Break(ref destination, None) = e.kind;
|
||
|
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 body.stmts.len() == 1;
|
||
|
if let StmtKind::Semi(ref e, _) = body.stmts[0].kind
|
||
|
if let ExprKind::Break(ref destination, None) = e.kind;
|
||
|
if body.expr.is_none();
|
||
|
then {
|
||
|
// report your lint here
|
||
|
}
|
||
|
}
|