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