diff options
Diffstat (limited to '')
-rw-r--r-- | src/test/ui/nll/closures-in-loops.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/test/ui/nll/closures-in-loops.rs b/src/test/ui/nll/closures-in-loops.rs new file mode 100644 index 000000000..491c186ec --- /dev/null +++ b/src/test/ui/nll/closures-in-loops.rs @@ -0,0 +1,24 @@ +// 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() {} |