hygiene for for loops, if let, while let

and some unrelated test cleanups
This commit is contained in:
Nick Cameron 2015-09-30 12:19:45 +13:00
parent e0c74868c3
commit 08f3752270
8 changed files with 94 additions and 48 deletions

View file

@ -1,18 +0,0 @@
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test that we get an expansion stack for `for` loops.
// error-pattern:in this expansion of for loop expansion
fn main() {
for t in &foo {
}
}

View file

@ -9,7 +9,5 @@
// except according to those terms.
fn main() {
for
&1 //~ ERROR refutable pattern in `for` loop binding
in [1].iter() {}
for &1 in [1].iter() {} //~ ERROR refutable pattern in `for` loop binding
}

View file

@ -16,4 +16,17 @@ fn main() -> (){
for n in 0..1 {
println!("{}", f!()); //~ ERROR unresolved name `n`
}
if let Some(n) = None {
println!("{}", f!()); //~ ERROR unresolved name `n`
}
if false {
} else if let Some(n) = None {
println!("{}", f!()); //~ ERROR unresolved name `n`
}
while let Some(n) = None {
println!("{}", f!()); //~ ERROR unresolved name `n`
}
}

View file

@ -13,10 +13,8 @@
fn main() {
let values: Vec<u8> = vec![1,2,3,4,5,6,7,8];
for
[x,y,z]
//~^ ERROR refutable pattern in `for` loop binding: `[]` not covered
in values.chunks(3).filter(|&xs| xs.len() == 3) {
for [x,y,z] in values.chunks(3).filter(|&xs| xs.len() == 3) {
//~^ ERROR refutable pattern in `for` loop binding: `[]` not covered
println!("y={}", y);
}
}