about summary refs log tree commit diff
path: root/tests/ui/loop-match/const-continue-to-loop.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/loop-match/const-continue-to-loop.rs')
-rw-r--r--tests/ui/loop-match/const-continue-to-loop.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/ui/loop-match/const-continue-to-loop.rs b/tests/ui/loop-match/const-continue-to-loop.rs
new file mode 100644
index 00000000000..c363e617cfb
--- /dev/null
+++ b/tests/ui/loop-match/const-continue-to-loop.rs
@@ -0,0 +1,27 @@
+// Test that a `#[const_continue]` that breaks to the label of the loop itself
+// rather than to the label of the block within the `#[loop_match]` produces an
+// error.
+
+#![allow(incomplete_features)]
+#![feature(loop_match)]
+#![crate_type = "lib"]
+
+fn const_continue_to_loop() -> u8 {
+    let mut state = 0;
+    #[loop_match]
+    'a: loop {
+        state = 'blk: {
+            match state {
+                0 => {
+                    #[const_continue]
+                    break 'blk 1;
+                }
+                _ => {
+                    #[const_continue]
+                    break 'a 2;
+                    //~^ ERROR `#[const_continue]` must break to a labeled block that participates in a `#[loop_match]`
+                }
+            }
+        }
+    }
+}