From e6b905d92529eb50de7073d34a6f9db7f2c6ab10 Mon Sep 17 00:00:00 2001 From: mcarton Date: Thu, 14 Jan 2016 21:04:34 +0100 Subject: [PATCH] Add a test for #398 --- tests/compile-fail/for_loop.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/compile-fail/for_loop.rs b/tests/compile-fail/for_loop.rs index 6791d71ca..37ecd2901 100644 --- a/tests/compile-fail/for_loop.rs +++ b/tests/compile-fail/for_loop.rs @@ -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]);