summaryrefslogtreecommitdiffstats
path: root/src/test/ui/for-loop-while/foreach-simple-outer-slot.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/for-loop-while/foreach-simple-outer-slot.rs')
-rw-r--r--src/test/ui/for-loop-while/foreach-simple-outer-slot.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/test/ui/for-loop-while/foreach-simple-outer-slot.rs b/src/test/ui/for-loop-while/foreach-simple-outer-slot.rs
new file mode 100644
index 000000000..a8d42a789
--- /dev/null
+++ b/src/test/ui/for-loop-while/foreach-simple-outer-slot.rs
@@ -0,0 +1,16 @@
+// run-pass
+
+
+
+pub fn main() {
+ let mut sum: isize = 0;
+ first_ten(|i| { println!("main"); println!("{}", i); sum = sum + i; });
+ println!("sum");
+ println!("{}", sum);
+ assert_eq!(sum, 45);
+}
+
+fn first_ten<F>(mut it: F) where F: FnMut(isize) {
+ let mut i: isize = 0;
+ while i < 10 { println!("first_ten"); it(i); i = i + 1; }
+}