]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #88691 - hyd-dev:88649, r=Mark-Simulacrum
authorJack Huey <31162821+jackh726@users.noreply.github.com>
Wed, 8 Sep 2021 16:24:19 +0000 (12:24 -0400)
committerGitHub <noreply@github.com>
Wed, 8 Sep 2021 16:24:19 +0000 (12:24 -0400)
Add a regression test for #88649

I noticed that #88649 does not have a regression test, so I add one in this PR.

The test fails with this without #88678:
```
error[E0080]: evaluation of constant value failed
  --> /checkout/src/test/ui/consts/issue-88649.rs:13:52
   |
LL |             Foo::Variant1(x) | Foo::Variant2(x) if x => {}
   |                                                    ^ StorageLive on a local that was already live

error: aborting due to previous error

For more information about this error, try `rustc --explain E0080`.
```

src/test/ui/consts/issue-88649.rs [new file with mode: 0644]

diff --git a/src/test/ui/consts/issue-88649.rs b/src/test/ui/consts/issue-88649.rs
new file mode 100644 (file)
index 0000000..43e562b
--- /dev/null
@@ -0,0 +1,18 @@
+// check-pass
+#![crate_type = "lib"]
+
+enum Foo {
+    Variant1(bool),
+    Variant2(bool),
+}
+
+const _: () = {
+    let mut n = 0;
+    while n < 2 {
+        match Foo::Variant1(true) {
+            Foo::Variant1(x) | Foo::Variant2(x) if x => {}
+            _ => {}
+        }
+        n += 1;
+    }
+};