]> git.lizzy.rs Git - rust.git/blobdiff - src/test/run-pass/hygienic-labels-in-let.rs
cleanup: s/impl Copy/#[derive(Copy)]/g
[rust.git] / src / test / run-pass / hygienic-labels-in-let.rs
index 22523f5e6ccb7e39631195f76cf48aca7b0f1151..17c0299cf4dd7aaf8d6c73579a5b907891f789dd 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![feature(macro_rules)]
+// ignore-pretty: pprust doesn't print hygiene output
 
 macro_rules! loop_x {
     ($e: expr) => {
@@ -17,17 +17,24 @@ macro_rules! loop_x {
     }
 }
 
+macro_rules! while_true {
+    ($e: expr) => {
+        // $e shouldn't be able to interact with this 'x
+        'x: while 1i + 1 == 2 { $e }
+    }
+}
+
 macro_rules! run_once {
     ($e: expr) => {
         // ditto
-        'x: for _ in range(0, 1) { $e }
+        'x: for _ in range(0i, 1) { $e }
     }
 }
 
 pub fn main() {
     let mut i = 0i;
 
-    let j = {
+    let j: int = {
         'x: loop {
             // this 'x should refer to the outer loop, lexically
             loop_x!(break 'x);
@@ -37,8 +44,8 @@ pub fn main() {
     };
     assert_eq!(j, 1i);
 
-    let k = {
-        'x: for _ in range(0, 1) {
+    let k: int = {
+        'x: for _ in range(0i, 1) {
             // ditto
             loop_x!(break 'x);
             i += 1;
@@ -47,8 +54,18 @@ pub fn main() {
     };
     assert_eq!(k, 1i);
 
-    let n = {
-        'x: for _ in range(0, 1) {
+    let l: int = {
+        'x: for _ in range(0i, 1) {
+            // ditto
+            while_true!(break 'x);
+            i += 1;
+        }
+        i + 1
+    };
+    assert_eq!(l, 1i);
+
+    let n: int = {
+        'x: for _ in range(0i, 1) {
             // ditto
             run_once!(continue 'x);
             i += 1;