2018-05-11 12:05:34 -05:00
|
|
|
if_chain! {
|
2019-09-27 10:16:06 -05:00
|
|
|
if let ExprKind::DropTemps(ref expr) = expr.kind;
|
|
|
|
if let ExprKind::Match(ref expr1, ref arms, MatchSource::ForLoopDesugar) = expr.kind;
|
|
|
|
if let ExprKind::Call(ref func, ref args) = expr1.kind;
|
|
|
|
if let ExprKind::Path(ref path) = func.kind;
|
2020-08-04 08:24:13 -05:00
|
|
|
if matches!(path, QPath::LangItem(LangItem::IntoIterIntoIter, _));
|
2018-05-28 07:50:41 -05:00
|
|
|
if args.len() == 1;
|
2019-09-27 10:16:06 -05:00
|
|
|
if let ExprKind::Struct(ref path1, ref fields, None) = args[0].kind;
|
2020-08-04 08:24:13 -05:00
|
|
|
if matches!(path1, QPath::LangItem(LangItem::Range, _));
|
2018-05-28 07:50:41 -05:00
|
|
|
if fields.len() == 2;
|
|
|
|
// unimplemented: field checks
|
2018-05-11 12:05:34 -05:00
|
|
|
if arms.len() == 1;
|
2019-09-27 10:16:06 -05:00
|
|
|
if let ExprKind::Loop(ref body, ref label, LoopSource::ForLoop) = arms[0].body.kind;
|
2019-05-19 09:52:44 -05:00
|
|
|
if let Some(trailing_expr) = &body.expr;
|
|
|
|
if body.stmts.len() == 4;
|
2019-09-27 10:16:06 -05:00
|
|
|
if let StmtKind::Local(ref local) = body.stmts[0].kind;
|
|
|
|
if let PatKind::Binding(BindingAnnotation::Mutable, _, name, None) = local.pat.kind;
|
2019-09-27 11:01:04 -05:00
|
|
|
if name.as_str() == "__next";
|
2019-09-27 10:16:06 -05:00
|
|
|
if let StmtKind::Expr(ref e, _) = body.stmts[1].kind
|
|
|
|
if let ExprKind::Match(ref expr2, ref arms1, MatchSource::ForLoopDesugar) = e.kind;
|
|
|
|
if let ExprKind::Call(ref func1, ref args1) = expr2.kind;
|
|
|
|
if let ExprKind::Path(ref path2) = func1.kind;
|
2020-08-04 08:24:13 -05:00
|
|
|
if matches!(path2, QPath::LangItem(LangItem::IteratorNext, _));
|
2018-05-28 07:50:41 -05:00
|
|
|
if args1.len() == 1;
|
2019-12-21 12:38:45 -06:00
|
|
|
if let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Mut, ref inner) = args1[0].kind;
|
2019-09-27 10:16:06 -05:00
|
|
|
if let ExprKind::Path(ref path3) = inner.kind;
|
2018-05-28 07:50:41 -05:00
|
|
|
if match_qpath(path3, &["iter"]);
|
2018-05-11 12:05:34 -05:00
|
|
|
if arms1.len() == 2;
|
2019-12-23 22:16:04 -06:00
|
|
|
if let ExprKind::Assign(ref target, ref value, ref _span) = arms1[0].body.kind;
|
2019-09-27 10:16:06 -05:00
|
|
|
if let ExprKind::Path(ref path4) = target.kind;
|
2018-05-28 07:50:41 -05:00
|
|
|
if match_qpath(path4, &["__next"]);
|
2019-09-27 10:16:06 -05:00
|
|
|
if let ExprKind::Path(ref path5) = value.kind;
|
2018-05-28 07:50:41 -05:00
|
|
|
if match_qpath(path5, &["val"]);
|
2020-08-04 08:24:13 -05:00
|
|
|
if let PatKind::Struct(ref path6, ref fields1, false) = arms1[0].pat.kind;
|
|
|
|
if matches!(path6, QPath::LangItem(LangItem::OptionSome, _));
|
2018-05-28 07:50:41 -05:00
|
|
|
if fields1.len() == 1;
|
2018-05-11 12:05:34 -05:00
|
|
|
// unimplemented: field checks
|
2019-09-27 10:16:06 -05:00
|
|
|
if let ExprKind::Break(ref destination, None) = arms1[1].body.kind;
|
2020-08-04 08:24:13 -05:00
|
|
|
if let PatKind::Struct(ref path7, ref fields2, false) = arms1[1].pat.kind;
|
|
|
|
if matches!(path7, QPath::LangItem(LangItem::OptionNone, _));
|
|
|
|
if fields2.len() == 0;
|
|
|
|
// unimplemented: field checks
|
2019-09-27 10:16:06 -05:00
|
|
|
if let StmtKind::Local(ref local1) = body.stmts[2].kind;
|
2019-04-28 02:11:20 -05:00
|
|
|
if let Some(ref init) = local1.init;
|
2019-09-27 10:16:06 -05:00
|
|
|
if let ExprKind::Path(ref path8) = init.kind;
|
2018-05-28 07:50:41 -05:00
|
|
|
if match_qpath(path8, &["__next"]);
|
2019-09-27 10:16:06 -05:00
|
|
|
if let PatKind::Binding(BindingAnnotation::Unannotated, _, name1, None) = local1.pat.kind;
|
2019-09-27 11:01:04 -05:00
|
|
|
if name1.as_str() == "y";
|
2019-09-27 10:16:06 -05:00
|
|
|
if let StmtKind::Expr(ref e1, _) = body.stmts[3].kind
|
|
|
|
if let ExprKind::Block(ref block) = e1.kind;
|
2019-05-19 09:52:44 -05:00
|
|
|
if let Some(trailing_expr1) = &block.expr;
|
|
|
|
if block.stmts.len() == 1;
|
2019-09-27 10:16:06 -05:00
|
|
|
if let StmtKind::Local(ref local2) = block.stmts[0].kind;
|
2019-04-28 02:11:20 -05:00
|
|
|
if let Some(ref init1) = local2.init;
|
2019-09-27 10:16:06 -05:00
|
|
|
if let ExprKind::Path(ref path9) = init1.kind;
|
2018-05-28 07:50:41 -05:00
|
|
|
if match_qpath(path9, &["y"]);
|
2019-09-27 10:16:06 -05:00
|
|
|
if let PatKind::Binding(BindingAnnotation::Unannotated, _, name2, None) = local2.pat.kind;
|
2019-09-27 11:01:04 -05:00
|
|
|
if name2.as_str() == "z";
|
2019-09-27 10:16:06 -05:00
|
|
|
if let PatKind::Binding(BindingAnnotation::Mutable, _, name3, None) = arms[0].pat.kind;
|
2019-09-27 11:01:04 -05:00
|
|
|
if name3.as_str() == "iter";
|
2018-05-11 12:05:34 -05:00
|
|
|
then {
|
|
|
|
// report your lint here
|
|
|
|
}
|
|
|
|
}
|