]> git.lizzy.rs Git - rust.git/blob - src/test/ui/nll/closures-in-loops.rs
Rollup merge of #60685 - dtolnay:spdx, r=nikomatsakis
[rust.git] / src / test / ui / nll / closures-in-loops.rs
1 // Test messages where a closure capture conflicts with itself because it's in
2 // a loop.
3
4 #![feature(nll)]
5
6 fn repreated_move(x: String) {
7     for i in 0..10 {
8         || x; //~ ERROR
9     }
10 }
11
12 fn repreated_mut_borrow(mut x: String) {
13     let mut v = Vec::new();
14     for i in 0..10 {
15         v.push(|| x = String::new()); //~ ERROR
16     }
17 }
18
19 fn repreated_unique_borrow(x: &mut String) {
20     let mut v = Vec::new();
21     for i in 0..10 {
22         v.push(|| *x = String::new()); //~ ERROR
23     }
24 }
25
26 fn main() {}