mirror of
https://github.com/rust-lang/rust-clippy
synced 2025-02-17 06:28:42 +00:00
add more negative tests
This commit is contained in:
parent
11072b51fa
commit
33cc140f55
2 changed files with 19 additions and 1 deletions
|
@ -57,4 +57,14 @@ fn main() {
|
|||
|
||||
for _ in std::iter::once(1).take(2) {}
|
||||
//~^ ERROR: this `.take()` call takes more items than the iterator will produce
|
||||
|
||||
for x in [].iter().take(1) {
|
||||
//~^ ERROR: this `.take()` call takes more items than the iterator will produce
|
||||
let _: &i32 = x;
|
||||
}
|
||||
|
||||
// ok, not out of bounds
|
||||
for _ in [1].iter().take(1) {}
|
||||
for _ in [1, 2, 3].iter().take(2) {}
|
||||
for _ in [1, 2, 3].iter().skip(2) {}
|
||||
}
|
||||
|
|
|
@ -107,5 +107,13 @@ LL | for _ in std::iter::once(1).take(2) {}
|
|||
|
|
||||
= note: this operation is useless and the returned iterator will simply yield the same items
|
||||
|
||||
error: aborting due to 13 previous errors
|
||||
error: this `.take()` call takes more items than the iterator will produce
|
||||
--> $DIR/iter_out_of_bounds.rs:61:14
|
||||
|
|
||||
LL | for x in [].iter().take(1) {
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: this operation is useless and the returned iterator will simply yield the same items
|
||||
|
||||
error: aborting due to 14 previous errors
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue