@@ -8,7 +8,12 @@ if_chain! {
8
8
if let ExprKind::Struct(ref path1, ref fields, None) = args[0].kind;
9
9
if matches!(path1, QPath::LangItem(LangItem::Range, _));
10
10
if fields.len() == 2;
11
- // unimplemented: field checks
11
+ if fields[0].ident.name.as_str() == "start"
12
+ if let ExprKind::Lit(ref lit) = fields[0].kind;
13
+ if let LitKind::Int(0, LitIntType::Unsuffixed) = lit.node;
14
+ if fields[1].ident.name.as_str() == "end"
15
+ if let ExprKind::Lit(ref lit1) = fields[1].kind;
16
+ if let LitKind::Int(10, LitIntType::Unsuffixed) = lit1.node;
12
17
if arms.len() == 1;
13
18
if let ExprKind::Loop(ref body, ref label, LoopSource::ForLoop) = arms[0].body.kind;
14
19
if body.stmts.len() == 4;
@@ -33,31 +38,166 @@ if_chain! {
33
38
if let PatKind::Struct(ref path6, ref fields1, false) = arms1[0].pat.kind;
34
39
if matches!(path6, QPath::LangItem(LangItem::OptionSome, _));
35
40
if fields1.len() == 1;
36
- // unimplemented: field checks
41
+ if fields1[0].ident.name.as_str() == "0"
42
+ if let PatKind::Binding(BindingAnnotation::Unannotated, _, name1, None) = fields1[0].kind;
43
+ if name1.as_str() == "val";
37
44
if let ExprKind::Break(ref destination, None) = arms1[1].body.kind;
38
45
if let PatKind::Struct(ref path7, ref fields2, false) = arms1[1].pat.kind;
39
46
if matches!(path7, QPath::LangItem(LangItem::OptionNone, _));
40
47
if fields2.len() == 0;
41
- // unimplemented: field checks
42
48
if let StmtKind::Local(ref local1) = body.stmts[2].kind;
43
49
if let Some(ref init) = local1.init;
44
50
if let ExprKind::Path(ref path8) = init.kind;
45
51
if match_qpath(path8, &["__next"]);
46
- if let PatKind::Binding(BindingAnnotation::Unannotated, _, name1 , None) = local1.pat.kind;
47
- if name1 .as_str() == "y";
52
+ if let PatKind::Binding(BindingAnnotation::Unannotated, _, name2 , None) = local1.pat.kind;
53
+ if name2 .as_str() == "y";
48
54
if let StmtKind::Expr(ref e1, _) = body.stmts[3].kind
49
55
if let ExprKind::Block(ref block) = e1.kind;
50
56
if block.stmts.len() == 1;
51
57
if let StmtKind::Local(ref local2) = block.stmts[0].kind;
52
58
if let Some(ref init1) = local2.init;
53
59
if let ExprKind::Path(ref path9) = init1.kind;
54
60
if match_qpath(path9, &["y"]);
55
- if let PatKind::Binding(BindingAnnotation::Unannotated, _, name2 , None) = local2.pat.kind;
56
- if name2 .as_str() == "z";
61
+ if let PatKind::Binding(BindingAnnotation::Unannotated, _, name3 , None) = local2.pat.kind;
62
+ if name3 .as_str() == "z";
57
63
if block.expr.is_none();
58
64
if body.expr.is_none();
59
- if let PatKind::Binding(BindingAnnotation::Mutable, _, name3, None) = arms[0].pat.kind;
60
- if name3.as_str() == "iter";
65
+ if let PatKind::Binding(BindingAnnotation::Mutable, _, name4, None) = arms[0].pat.kind;
66
+ if name4.as_str() == "iter";
67
+ then {
68
+ // report your lint here
69
+ }
70
+ }
71
+ if_chain! {
72
+ if let ExprKind::DropTemps(ref expr) = expr.kind;
73
+ if let ExprKind::Match(ref expr1, ref arms, MatchSource::ForLoopDesugar) = expr.kind;
74
+ if let ExprKind::Call(ref func, ref args) = expr1.kind;
75
+ if let ExprKind::Path(ref path) = func.kind;
76
+ if matches!(path, QPath::LangItem(LangItem::IntoIterIntoIter, _));
77
+ if args.len() == 1;
78
+ if let ExprKind::Struct(ref path1, ref fields, None) = args[0].kind;
79
+ if matches!(path1, QPath::LangItem(LangItem::Range, _));
80
+ if fields.len() == 2;
81
+ if fields[0].ident.name.as_str() == "start"
82
+ if let ExprKind::Lit(ref lit) = fields[0].kind;
83
+ if let LitKind::Int(0, LitIntType::Unsuffixed) = lit.node;
84
+ if fields[1].ident.name.as_str() == "end"
85
+ if let ExprKind::Lit(ref lit1) = fields[1].kind;
86
+ if let LitKind::Int(10, LitIntType::Unsuffixed) = lit1.node;
87
+ if arms.len() == 1;
88
+ if let ExprKind::Loop(ref body, ref label, LoopSource::ForLoop) = arms[0].body.kind;
89
+ if body.stmts.len() == 4;
90
+ if let StmtKind::Local(ref local) = body.stmts[0].kind;
91
+ if let PatKind::Binding(BindingAnnotation::Mutable, _, name, None) = local.pat.kind;
92
+ if name.as_str() == "__next";
93
+ if let StmtKind::Expr(ref e, _) = body.stmts[1].kind
94
+ if let ExprKind::Match(ref expr2, ref arms1, MatchSource::ForLoopDesugar) = e.kind;
95
+ if let ExprKind::Call(ref func1, ref args1) = expr2.kind;
96
+ if let ExprKind::Path(ref path2) = func1.kind;
97
+ if matches!(path2, QPath::LangItem(LangItem::IteratorNext, _));
98
+ if args1.len() == 1;
99
+ if let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Mut, ref inner) = args1[0].kind;
100
+ if let ExprKind::Path(ref path3) = inner.kind;
101
+ if match_qpath(path3, &["iter"]);
102
+ if arms1.len() == 2;
103
+ if let ExprKind::Assign(ref target, ref value, ref _span) = arms1[0].body.kind;
104
+ if let ExprKind::Path(ref path4) = target.kind;
105
+ if match_qpath(path4, &["__next"]);
106
+ if let ExprKind::Path(ref path5) = value.kind;
107
+ if match_qpath(path5, &["val"]);
108
+ if let PatKind::Struct(ref path6, ref fields1, false) = arms1[0].pat.kind;
109
+ if matches!(path6, QPath::LangItem(LangItem::OptionSome, _));
110
+ if fields1.len() == 1;
111
+ if fields1[0].ident.name.as_str() == "0"
112
+ if let PatKind::Binding(BindingAnnotation::Unannotated, _, name1, None) = fields1[0].kind;
113
+ if name1.as_str() == "val";
114
+ if let ExprKind::Break(ref destination, None) = arms1[1].body.kind;
115
+ if let PatKind::Struct(ref path7, ref fields2, false) = arms1[1].pat.kind;
116
+ if matches!(path7, QPath::LangItem(LangItem::OptionNone, _));
117
+ if fields2.len() == 0;
118
+ if let StmtKind::Local(ref local1) = body.stmts[2].kind;
119
+ if let Some(ref init) = local1.init;
120
+ if let ExprKind::Path(ref path8) = init.kind;
121
+ if match_qpath(path8, &["__next"]);
122
+ if let PatKind::Wild = local1.pat.kind;
123
+ if let StmtKind::Expr(ref e1, _) = body.stmts[3].kind
124
+ if let ExprKind::Block(ref block) = e1.kind;
125
+ if block.stmts.len() == 1;
126
+ if let StmtKind::Semi(ref e2, _) = block.stmts[0].kind
127
+ if let ExprKind::Break(ref destination1, None) = e2.kind;
128
+ if block.expr.is_none();
129
+ if body.expr.is_none();
130
+ if let PatKind::Binding(BindingAnnotation::Mutable, _, name2, None) = arms[0].pat.kind;
131
+ if name2.as_str() == "iter";
132
+ then {
133
+ // report your lint here
134
+ }
135
+ }
136
+ if_chain! {
137
+ if let ExprKind::DropTemps(ref expr) = expr.kind;
138
+ if let ExprKind::Match(ref expr1, ref arms, MatchSource::ForLoopDesugar) = expr.kind;
139
+ if let ExprKind::Call(ref func, ref args) = expr1.kind;
140
+ if let ExprKind::Path(ref path) = func.kind;
141
+ if matches!(path, QPath::LangItem(LangItem::IntoIterIntoIter, _));
142
+ if args.len() == 1;
143
+ if let ExprKind::Struct(ref path1, ref fields, None) = args[0].kind;
144
+ if matches!(path1, QPath::LangItem(LangItem::Range, _));
145
+ if fields.len() == 2;
146
+ if fields[0].ident.name.as_str() == "start"
147
+ if let ExprKind::Lit(ref lit) = fields[0].kind;
148
+ if let LitKind::Int(0, LitIntType::Unsuffixed) = lit.node;
149
+ if fields[1].ident.name.as_str() == "end"
150
+ if let ExprKind::Lit(ref lit1) = fields[1].kind;
151
+ if let LitKind::Int(10, LitIntType::Unsuffixed) = lit1.node;
152
+ if arms.len() == 1;
153
+ if let ExprKind::Loop(ref body, ref label, LoopSource::ForLoop) = arms[0].body.kind;
154
+ if body.stmts.len() == 4;
155
+ if let StmtKind::Local(ref local) = body.stmts[0].kind;
156
+ if let PatKind::Binding(BindingAnnotation::Mutable, _, name, None) = local.pat.kind;
157
+ if name.as_str() == "__next";
158
+ if let StmtKind::Expr(ref e, _) = body.stmts[1].kind
159
+ if let ExprKind::Match(ref expr2, ref arms1, MatchSource::ForLoopDesugar) = e.kind;
160
+ if let ExprKind::Call(ref func1, ref args1) = expr2.kind;
161
+ if let ExprKind::Path(ref path2) = func1.kind;
162
+ if matches!(path2, QPath::LangItem(LangItem::IteratorNext, _));
163
+ if args1.len() == 1;
164
+ if let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Mut, ref inner) = args1[0].kind;
165
+ if let ExprKind::Path(ref path3) = inner.kind;
166
+ if match_qpath(path3, &["iter"]);
167
+ if arms1.len() == 2;
168
+ if let ExprKind::Assign(ref target, ref value, ref _span) = arms1[0].body.kind;
169
+ if let ExprKind::Path(ref path4) = target.kind;
170
+ if match_qpath(path4, &["__next"]);
171
+ if let ExprKind::Path(ref path5) = value.kind;
172
+ if match_qpath(path5, &["val"]);
173
+ if let PatKind::Struct(ref path6, ref fields1, false) = arms1[0].pat.kind;
174
+ if matches!(path6, QPath::LangItem(LangItem::OptionSome, _));
175
+ if fields1.len() == 1;
176
+ if fields1[0].ident.name.as_str() == "0"
177
+ if let PatKind::Binding(BindingAnnotation::Unannotated, _, name1, None) = fields1[0].kind;
178
+ if name1.as_str() == "val";
179
+ if let ExprKind::Break(ref destination, None) = arms1[1].body.kind;
180
+ if let PatKind::Struct(ref path7, ref fields2, false) = arms1[1].pat.kind;
181
+ if matches!(path7, QPath::LangItem(LangItem::OptionNone, _));
182
+ if fields2.len() == 0;
183
+ if let StmtKind::Local(ref local1) = body.stmts[2].kind;
184
+ if let Some(ref init) = local1.init;
185
+ if let ExprKind::Path(ref path8) = init.kind;
186
+ if match_qpath(path8, &["__next"]);
187
+ if let PatKind::Wild = local1.pat.kind;
188
+ if let StmtKind::Expr(ref e1, _) = body.stmts[3].kind
189
+ if let ExprKind::Block(ref block) = e1.kind;
190
+ if block.stmts.len() == 1;
191
+ if let StmtKind::Semi(ref e2, _) = block.stmts[0].kind
192
+ if let ExprKind::Break(ref destination1, None) = e2.kind;
193
+ if let Some(ref label1) = destination1.label
194
+ if label_name.ident.name.as_str() == "'label";
195
+ if block.expr.is_none();
196
+ if body.expr.is_none();
197
+ if let Some(ref label2) = label
198
+ if label_name1.ident.name.as_str() == "'label";
199
+ if let PatKind::Binding(BindingAnnotation::Mutable, _, name2, None) = arms[0].pat.kind;
200
+ if name2.as_str() == "iter";
61
201
then {
62
202
// report your lint here
63
203
}
0 commit comments