rust/tests/ui/nll/closures-in-loops.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

25 lines
488 B
Rust
Raw Normal View History

2018-08-01 14:40:06 -05:00
// Test messages where a closure capture conflicts with itself because it's in
// a loop.
fn repreated_move(x: String) {
for i in 0..10 {
|| x; //~ ERROR
}
}
fn repreated_mut_borrow(mut x: String) {
let mut v = Vec::new();
for i in 0..10 {
v.push(|| x = String::new()); //~ ERROR
}
}
fn repreated_unique_borrow(x: &mut String) {
let mut v = Vec::new();
for i in 0..10 {
v.push(|| *x = String::new()); //~ ERROR
}
}
fn main() {}