fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

master
4.2 KiB101 linesraw
1if let Some(higher::ForLoop { pat: pat, arg: arg, body: body, .. }) = higher::ForLoop::hir(expr)
2    && let PatKind::Binding(BindingAnnotation::NONE, _, name, None) = pat.kind
3    && name.as_str() == "y"
4    && let ExprKind::Struct(qpath, fields, None) = arg.kind
5    && matches!(qpath, QPath::LangItem(LangItem::Range, _))
6    && fields.len() == 2
7    && fields[0].ident.as_str() == "start"
8    && let ExprKind::Lit(ref lit) = fields[0].expr.kind
9    && let LitKind::Int(0, LitIntType::Unsuffixed) = lit.node
10    && fields[1].ident.as_str() == "end"
11    && let ExprKind::Lit(ref lit1) = fields[1].expr.kind
12    && let LitKind::Int(10, LitIntType::Unsuffixed) = lit1.node
13    && let ExprKind::Block(block, None) = body.kind
14    && block.stmts.len() == 1
15    && let StmtKind::Local(local) = block.stmts[0].kind
16    && let Some(init) = local.init
17    && let ExprKind::Path(ref qpath1) = init.kind
18    && match_qpath(qpath1, &["y"])
19    && let PatKind::Binding(BindingAnnotation::NONE, _, name1, None) = local.pat.kind
20    && name1.as_str() == "z"
21    && block.expr.is_none()
22{
23    // report your lint here
24}
25if let Some(higher::ForLoop { pat: pat, arg: arg, body: body, .. }) = higher::ForLoop::hir(expr)
26    && let PatKind::Wild = pat.kind
27    && let ExprKind::Struct(qpath, fields, None) = arg.kind
28    && matches!(qpath, QPath::LangItem(LangItem::Range, _))
29    && fields.len() == 2
30    && fields[0].ident.as_str() == "start"
31    && let ExprKind::Lit(ref lit) = fields[0].expr.kind
32    && let LitKind::Int(0, LitIntType::Unsuffixed) = lit.node
33    && fields[1].ident.as_str() == "end"
34    && let ExprKind::Lit(ref lit1) = fields[1].expr.kind
35    && let LitKind::Int(10, LitIntType::Unsuffixed) = lit1.node
36    && let ExprKind::Block(block, None) = body.kind
37    && block.stmts.len() == 1
38    && let StmtKind::Semi(e) = block.stmts[0].kind
39    && let ExprKind::Break(destination, None) = e.kind
40    && destination.label.is_none()
41    && block.expr.is_none()
42{
43    // report your lint here
44}
45if let Some(higher::ForLoop { pat: pat, arg: arg, body: body, .. }) = higher::ForLoop::hir(expr)
46    && let PatKind::Wild = pat.kind
47    && let ExprKind::Struct(qpath, fields, None) = arg.kind
48    && matches!(qpath, QPath::LangItem(LangItem::Range, _))
49    && fields.len() == 2
50    && fields[0].ident.as_str() == "start"
51    && let ExprKind::Lit(ref lit) = fields[0].expr.kind
52    && let LitKind::Int(0, LitIntType::Unsuffixed) = lit.node
53    && fields[1].ident.as_str() == "end"
54    && let ExprKind::Lit(ref lit1) = fields[1].expr.kind
55    && let LitKind::Int(10, LitIntType::Unsuffixed) = lit1.node
56    && let ExprKind::Block(block, None) = body.kind
57    && block.stmts.len() == 1
58    && let StmtKind::Semi(e) = block.stmts[0].kind
59    && let ExprKind::Break(destination, None) = e.kind
60    && let Some(label) = destination.label
61    && label.ident.as_str() == "'label"
62    && block.expr.is_none()
63{
64    // report your lint here
65}
66if let Some(higher::While { condition: condition, body: body }) = higher::While::hir(expr)
67    && let ExprKind::Path(ref qpath) = condition.kind
68    && match_qpath(qpath, &["a"])
69    && let ExprKind::Block(block, None) = body.kind
70    && block.stmts.len() == 1
71    && let StmtKind::Semi(e) = block.stmts[0].kind
72    && let ExprKind::Break(destination, None) = e.kind
73    && destination.label.is_none()
74    && block.expr.is_none()
75{
76    // report your lint here
77}
78if let Some(higher::WhileLet { let_pat: let_pat, let_expr: let_expr, if_then: if_then }) = higher::WhileLet::hir(expr)
79    && let PatKind::Lit(lit_expr) = let_pat.kind
80    && let ExprKind::Lit(ref lit) = lit_expr.kind
81    && let LitKind::Bool(true) = lit.node
82    && let ExprKind::Path(ref qpath) = let_expr.kind
83    && match_qpath(qpath, &["a"])
84    && let ExprKind::Block(block, None) = if_then.kind
85    && block.stmts.len() == 1
86    && let StmtKind::Semi(e) = block.stmts[0].kind
87    && let ExprKind::Break(destination, None) = e.kind
88    && destination.label.is_none()
89    && block.expr.is_none()
90{
91    // report your lint here
92}
93if let ExprKind::Loop(body, None, LoopSource::Loop, _) = expr.kind
94    && body.stmts.len() == 1
95    && let StmtKind::Semi(e) = body.stmts[0].kind
96    && let ExprKind::Break(destination, None) = e.kind
97    && destination.label.is_none()
98    && body.expr.is_none()
99{
100    // report your lint here
101}