about summary refs log tree commit diff
path: root/tests/ui/loop-match/const-continue-to-polymorphic-const.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/loop-match/const-continue-to-polymorphic-const.rs')
-rw-r--r--tests/ui/loop-match/const-continue-to-polymorphic-const.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/ui/loop-match/const-continue-to-polymorphic-const.rs b/tests/ui/loop-match/const-continue-to-polymorphic-const.rs
new file mode 100644
index 00000000000..9a91c977911
--- /dev/null
+++ b/tests/ui/loop-match/const-continue-to-polymorphic-const.rs
@@ -0,0 +1,29 @@
+// Test that a `#[const_continue]` that breaks on a polymorphic constant produces an error.
+// A polymorphic constant does not have a concrete value at MIR building time, and therefore the
+// `#[loop_match]~ desugaring can't handle such values.
+#![allow(incomplete_features)]
+#![feature(loop_match)]
+#![crate_type = "lib"]
+
+trait Foo {
+    const TARGET: u8;
+
+    fn test_u8(mut state: u8) -> &'static str {
+        #[loop_match]
+        loop {
+            state = 'blk: {
+                match state {
+                    0 => {
+                        #[const_continue]
+                        break 'blk Self::TARGET;
+                        //~^ ERROR could not determine the target branch for this `#[const_continue]`
+                    }
+
+                    1 => return "bar",
+                    2 => return "baz",
+                    _ => unreachable!(),
+                }
+            }
+        }
+    }
+}