Skip to content

Commit

Permalink
Add a test for rust-lang#398
Browse files Browse the repository at this point in the history
  • Loading branch information
mcarton committed Jan 14, 2016
1 parent 387e099 commit e6b905d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/compile-fail/for_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ fn main() {
println!("{} {}", vec[i], vec2[i]);
}

for i in 0..vec.len() {
//~^ ERROR `i` is only used to index `vec2`. Consider using `for item in vec2.iter().take(vec.len())`
println!("{}", vec2[i]);
}

for i in 5..vec.len() {
//~^ ERROR `i` is only used to index `vec`. Consider using `for item in vec.iter().skip(5)`
println!("{}", vec[i]);
Expand Down

0 comments on commit e6b905d

Please sign in to comment.