about summary refs log tree commit diff
path: root/tests/ui/loop-match/const-continue-to-loop.rs
diff options
context:
space:
mode:
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>2025-02-18 14:16:57 +0100
committerFolkert de Vries <folkert@folkertdev.nl>2025-06-23 20:43:04 +0200
commitba5556d239c11232dc8d95123ea70a2783019476 (patch)
tree0fc9a5eb5964d18de0ab43107b5964818f8bb49f /tests/ui/loop-match/const-continue-to-loop.rs
parent42245d34d22ade32b3f276dcf74deb826841594c (diff)
downloadrust-ba5556d239c11232dc8d95123ea70a2783019476.tar.gz
rust-ba5556d239c11232dc8d95123ea70a2783019476.zip
Add `#[loop_match]` for improved DFA codegen
Co-authored-by: Folkert de Vries <folkert@folkertdev.nl>
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]`
+                }
+            }
+        }
+    }
+}