summaryrefslogtreecommitdiffstats
path: root/src/test/ui/for-loop-while/while-with-break.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/for-loop-while/while-with-break.rs')
-rw-r--r--src/test/ui/for-loop-while/while-with-break.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/test/ui/for-loop-while/while-with-break.rs b/src/test/ui/for-loop-while/while-with-break.rs
new file mode 100644
index 000000000..a9d52dda5
--- /dev/null
+++ b/src/test/ui/for-loop-while/while-with-break.rs
@@ -0,0 +1,17 @@
+// run-pass
+
+pub fn main() {
+ let mut i: isize = 90;
+ while i < 100 {
+ println!("{}", i);
+ i = i + 1;
+ if i == 95 {
+ let _v: Vec<isize> =
+ vec![1, 2, 3, 4, 5]; // we check that it is freed by break
+
+ println!("breaking");
+ break;
+ }
+ }
+ assert_eq!(i, 95);
+}