Commit cf9cffa
authored
Fixes for
This PR fixes issues with the `missing_asserts_for_indexing` lint.
- false positive when the first index is the highest(or equal) value in
a list of indexes:
```rust
pub fn foo(slice: &[i32]) -> i32{
slice[1] * slice[0]
}
```
- false negative when an assert statement if found after the indexing
operation.
```rust
pub fn bar(slice: &[i32]) -> i32 {
let product = slice[0] * slice[1];
assert!(slice.len() > 1);
product
}
```
examples: https://godbolt.org/z/s7Y47vKdE
closes: rust-lang#14079
changelog: [`missing_asserts_for_indexing`]: ignore asserts found after
indexing, and do not require asserts if the first index is highest.missing_asserts_for_indexing (rust-lang#14108)File tree
5 files changed
+78
-13
lines changed- clippy_lints/src
- tests/ui
5 files changed
+78
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
| 171 | + | |
171 | 172 | | |
172 | 173 | | |
173 | 174 | | |
| |||
177 | 178 | | |
178 | 179 | | |
179 | 180 | | |
| 181 | + | |
180 | 182 | | |
181 | 183 | | |
182 | 184 | | |
| |||
244 | 246 | | |
245 | 247 | | |
246 | 248 | | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
255 | 260 | | |
256 | 261 | | |
257 | | - | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
258 | 266 | | |
259 | 267 | | |
260 | | - | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
261 | 272 | | |
262 | 273 | | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
263 | 277 | | |
264 | 278 | | |
265 | 279 | | |
266 | 280 | | |
267 | 281 | | |
268 | 282 | | |
| 283 | + | |
269 | 284 | | |
270 | 285 | | |
271 | 286 | | |
| |||
284 | 299 | | |
285 | 300 | | |
286 | 301 | | |
| 302 | + | |
287 | 303 | | |
288 | 304 | | |
289 | 305 | | |
| 306 | + | |
290 | 307 | | |
291 | 308 | | |
292 | 309 | | |
293 | 310 | | |
| 311 | + | |
294 | 312 | | |
295 | 313 | | |
296 | 314 | | |
| |||
325 | 343 | | |
326 | 344 | | |
327 | 345 | | |
| 346 | + | |
328 | 347 | | |
329 | 348 | | |
330 | 349 | | |
331 | 350 | | |
332 | 351 | | |
333 | | - | |
| 352 | + | |
334 | 353 | | |
335 | 354 | | |
336 | 355 | | |
| |||
378 | 397 | | |
379 | 398 | | |
380 | 399 | | |
| 400 | + | |
381 | 401 | | |
382 | | - | |
| 402 | + | |
383 | 403 | | |
384 | 404 | | |
385 | 405 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
142 | 152 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
142 | 152 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
76 | 82 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
180 | 180 | | |
181 | 181 | | |
182 | 182 | | |
183 | | - | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
184 | 203 | | |
0 commit comments