mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-21 04:03:11 +00:00
add more negative tests
This commit is contained in:
parent
11072b51fa
commit
33cc140f55
@ -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…
Reference in New Issue
Block a user