about summary refs log tree commit diff
path: root/tests/ui/parser/break-in-unlabeled-block-in-macro.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/parser/break-in-unlabeled-block-in-macro.rs')
-rw-r--r--tests/ui/parser/break-in-unlabeled-block-in-macro.rs43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/ui/parser/break-in-unlabeled-block-in-macro.rs b/tests/ui/parser/break-in-unlabeled-block-in-macro.rs
new file mode 100644
index 00000000000..eecc0026b12
--- /dev/null
+++ b/tests/ui/parser/break-in-unlabeled-block-in-macro.rs
@@ -0,0 +1,43 @@
+macro_rules! foo {
+    () => {
+        break (); //~ ERROR `break` outside of a loop or labeled block
+    };
+    ($e: expr) => {
+        break $e; //~ ERROR `break` outside of a loop or labeled block
+    };
+    (stmt $s: stmt) => {
+        $s
+    };
+    (@ $e: expr) => {
+        { break $e; } //~ ERROR `break` outside of a loop or labeled block
+    };
+    (=> $s: stmt) => {
+        { $s }
+    };
+}
+
+fn main() {
+    {
+        foo!();
+    }
+    {
+        foo!(());
+    }
+    {
+        foo!(stmt break ()); //~ ERROR `break` outside of a loop or labeled block
+    }
+    {
+        foo!(@ ());
+    }
+    {
+        foo!(=> break ()); //~ ERROR `break` outside of a loop or labeled block
+    }
+    {
+        macro_rules! bar {
+            () => {
+                break () //~ ERROR `break` outside of a loop or labeled block
+            };
+        }
+        bar!()
+    }
+}