2018-05-11 17:05:34 +00:00
|
|
|
if_chain! {
|
2018-07-12 07:30:57 +00:00
|
|
|
if let ExprKind::Block(ref block) = expr.node;
|
2019-01-20 10:21:30 +00:00
|
|
|
if let StmtKind::Local(ref local) = block.node;
|
2019-03-07 13:07:01 +00:00
|
|
|
if let Some(ref init) = local.init;
|
2018-07-12 07:30:57 +00:00
|
|
|
if let ExprKind::Match(ref expr, ref arms, MatchSource::ForLoopDesugar) = init.node;
|
|
|
|
if let ExprKind::Call(ref func, ref args) = expr.node;
|
|
|
|
if let ExprKind::Path(ref path) = func.node;
|
2018-05-28 12:50:41 +00:00
|
|
|
if match_qpath(path, &["{{root}}", "std", "iter", "IntoIterator", "into_iter"]);
|
|
|
|
if args.len() == 1;
|
2018-07-12 07:30:57 +00:00
|
|
|
if let ExprKind::Struct(ref path1, ref fields, None) = args[0].node;
|
2018-05-28 12:50:41 +00:00
|
|
|
if match_qpath(path1, &["{{root}}", "std", "ops", "Range"]);
|
|
|
|
if fields.len() == 2;
|
|
|
|
// unimplemented: field checks
|
2018-05-11 17:05:34 +00:00
|
|
|
if arms.len() == 1;
|
2018-07-12 07:30:57 +00:00
|
|
|
if let ExprKind::Loop(ref body, ref label, LoopSource::ForLoop) = arms[0].body.node;
|
2019-01-20 10:21:30 +00:00
|
|
|
if let StmtKind::Local(ref local1) = body.node;
|
2018-05-11 17:05:34 +00:00
|
|
|
if let PatKind::Binding(BindingAnnotation::Mutable, _, name, None) = local1.pat.node;
|
|
|
|
if name.node.as_str() == "__next";
|
2018-07-12 08:53:53 +00:00
|
|
|
if let StmtKind::Expr(ref e, _) = local1.pat.node
|
2018-07-12 07:30:57 +00:00
|
|
|
if let ExprKind::Match(ref expr1, ref arms1, MatchSource::ForLoopDesugar) = e.node;
|
|
|
|
if let ExprKind::Call(ref func1, ref args1) = expr1.node;
|
|
|
|
if let ExprKind::Path(ref path2) = func1.node;
|
2018-05-28 12:50:41 +00:00
|
|
|
if match_qpath(path2, &["{{root}}", "std", "iter", "Iterator", "next"]);
|
|
|
|
if args1.len() == 1;
|
2018-07-12 07:30:57 +00:00
|
|
|
if let ExprKind::AddrOf(MutMutable, ref inner) = args1[0].node;
|
|
|
|
if let ExprKind::Path(ref path3) = inner.node;
|
2018-05-28 12:50:41 +00:00
|
|
|
if match_qpath(path3, &["iter"]);
|
2018-05-11 17:05:34 +00:00
|
|
|
if arms1.len() == 2;
|
2018-07-12 07:30:57 +00:00
|
|
|
if let ExprKind::Assign(ref target, ref value) = arms1[0].body.node;
|
|
|
|
if let ExprKind::Path(ref path4) = target.node;
|
2018-05-28 12:50:41 +00:00
|
|
|
if match_qpath(path4, &["__next"]);
|
2018-07-12 07:30:57 +00:00
|
|
|
if let ExprKind::Path(ref path5) = value.node;
|
2018-05-28 12:50:41 +00:00
|
|
|
if match_qpath(path5, &["val"]);
|
2018-05-11 17:05:34 +00:00
|
|
|
if arms1[0].pats.len() == 1;
|
2018-05-28 12:50:41 +00:00
|
|
|
if let PatKind::TupleStruct(ref path6, ref fields1, None) = arms1[0].pats[0].node;
|
|
|
|
if match_qpath(path6, &["{{root}}", "std", "option", "Option", "Some"]);
|
|
|
|
if fields1.len() == 1;
|
2018-05-11 17:05:34 +00:00
|
|
|
// unimplemented: field checks
|
2018-07-12 07:30:57 +00:00
|
|
|
if let ExprKind::Break(ref destination, None) = arms1[1].body.node;
|
2018-05-11 17:05:34 +00:00
|
|
|
if arms1[1].pats.len() == 1;
|
2018-05-28 12:50:41 +00:00
|
|
|
if let PatKind::Path(ref path7) = arms1[1].pats[0].node;
|
|
|
|
if match_qpath(path7, &["{{root}}", "std", "option", "Option", "None"]);
|
2019-01-20 10:21:30 +00:00
|
|
|
if let StmtKind::Local(ref local2) = path7.node;
|
2019-03-07 13:07:01 +00:00
|
|
|
if let Some(ref init1) = local2.init;
|
2018-07-12 07:30:57 +00:00
|
|
|
if let ExprKind::Path(ref path8) = init1.node;
|
2018-05-28 12:50:41 +00:00
|
|
|
if match_qpath(path8, &["__next"]);
|
2018-05-11 17:05:34 +00:00
|
|
|
if let PatKind::Binding(BindingAnnotation::Unannotated, _, name1, None) = local2.pat.node;
|
|
|
|
if name1.node.as_str() == "y";
|
2018-07-12 08:53:53 +00:00
|
|
|
if let StmtKind::Expr(ref e1, _) = local2.pat.node
|
2018-07-12 07:30:57 +00:00
|
|
|
if let ExprKind::Block(ref block1) = e1.node;
|
2019-01-20 10:21:30 +00:00
|
|
|
if let StmtKind::Local(ref local3) = block1.node;
|
2019-03-07 13:07:01 +00:00
|
|
|
if let Some(ref init2) = local3.init;
|
2018-07-12 07:30:57 +00:00
|
|
|
if let ExprKind::Path(ref path9) = init2.node;
|
2018-05-28 12:50:41 +00:00
|
|
|
if match_qpath(path9, &["y"]);
|
2018-05-11 17:05:34 +00:00
|
|
|
if let PatKind::Binding(BindingAnnotation::Unannotated, _, name2, None) = local3.pat.node;
|
|
|
|
if name2.node.as_str() == "z";
|
|
|
|
if arms[0].pats.len() == 1;
|
|
|
|
if let PatKind::Binding(BindingAnnotation::Mutable, _, name3, None) = arms[0].pats[0].node;
|
|
|
|
if name3.node.as_str() == "iter";
|
|
|
|
if let PatKind::Binding(BindingAnnotation::Unannotated, _, name4, None) = local.pat.node;
|
|
|
|
if name4.node.as_str() == "_result";
|
2018-07-12 07:30:57 +00:00
|
|
|
if let ExprKind::Path(ref path10) = local.pat.node;
|
2018-05-28 12:50:41 +00:00
|
|
|
if match_qpath(path10, &["_result"]);
|
2018-05-11 17:05:34 +00:00
|
|
|
then {
|
|
|
|
// report your lint here
|
|
|
|
}
|
|
|
|
}
|