add more negative tests

This commit is contained in:
y21 2023-08-27 23:38:43 +02:00
parent 11072b51fa
commit 33cc140f55
2 changed files with 19 additions and 1 deletions

View File

@ -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) {}
}

View File

@ -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