50 lines
2.3 KiB
Plaintext
50 lines
2.3 KiB
Plaintext
if_chain! {
|
|
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;
|
|
if matches!(path, QPath::LangItem(LangItem::IntoIterIntoIter, _));
|
|
if args.len() == 1;
|
|
if let ExprKind::Struct(ref path1, ref fields, None) = args[0].kind;
|
|
if matches!(path1, QPath::LangItem(LangItem::Range, _));
|
|
if fields.len() == 2;
|
|
// unimplemented: field checks
|
|
if arms.len() == 1;
|
|
if let ExprKind::Loop(ref body, ref label, LoopSource::ForLoop) = arms[0].body.kind;
|
|
if body.stmts.len() == 1;
|
|
if let StmtKind::Expr(ref e, _) = body.stmts[0].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;
|
|
if matches!(path2, QPath::LangItem(LangItem::IteratorNext, _));
|
|
if args1.len() == 1;
|
|
if let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Mut, ref inner) = args1[0].kind;
|
|
if let ExprKind::Path(ref path3) = inner.kind;
|
|
if match_qpath(path3, &["iter"]);
|
|
if arms1.len() == 2;
|
|
if let ExprKind::Break(ref destination, None) = arms1[0].body.kind;
|
|
if let PatKind::Struct(ref path4, ref fields1, false) = arms1[0].pat.kind;
|
|
if matches!(path4, QPath::LangItem(LangItem::OptionNone, _));
|
|
if fields1.len() == 0;
|
|
// unimplemented: field checks
|
|
if let ExprKind::Block(ref block) = arms1[1].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 path5) = init.kind;
|
|
if match_qpath(path5, &["y"]);
|
|
if let PatKind::Binding(BindingAnnotation::Unannotated, _, name, None) = local.pat.kind;
|
|
if name.as_str() == "z";
|
|
if block.expr.is_none();
|
|
if let PatKind::Struct(ref path6, ref fields2, false) = arms1[1].pat.kind;
|
|
if matches!(path6, QPath::LangItem(LangItem::OptionSome, _));
|
|
if fields2.len() == 1;
|
|
// unimplemented: field checks
|
|
if body.expr.is_none();
|
|
if let PatKind::Binding(BindingAnnotation::Mutable, _, name1, None) = arms[0].pat.kind;
|
|
if name1.as_str() == "iter";
|
|
then {
|
|
// report your lint here
|
|
}
|
|
}
|