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