about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs11
-rw-r--r--tests/ui/match/issue-113012.rs12
2 files changed, 19 insertions, 4 deletions
diff --git a/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs b/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs
index a2d23425f3b..36c76e53231 100644
--- a/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs
+++ b/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs
@@ -344,15 +344,18 @@ where
     };
 
     // Check the qualifs of the value of `const` items.
-    // FIXME(valtrees): check whether const qualifs should behave the same
-    // way for type and mir constants.
     let uneval = match constant.literal {
         ConstantKind::Ty(ct)
-            if matches!(ct.kind(), ty::ConstKind::Param(_) | ty::ConstKind::Error(_)) =>
+            if matches!(
+                ct.kind(),
+                ty::ConstKind::Param(_) | ty::ConstKind::Error(_) | ty::ConstKind::Value(_)
+            ) =>
         {
             None
         }
-        ConstantKind::Ty(c) => bug!("expected ConstKind::Param here, found {:?}", c),
+        ConstantKind::Ty(c) => {
+            bug!("expected ConstKind::Param or ConstKind::Value here, found {:?}", c)
+        }
         ConstantKind::Unevaluated(uv, _) => Some(uv),
         ConstantKind::Val(..) => None,
     };
diff --git a/tests/ui/match/issue-113012.rs b/tests/ui/match/issue-113012.rs
new file mode 100644
index 00000000000..da7a8b65b97
--- /dev/null
+++ b/tests/ui/match/issue-113012.rs
@@ -0,0 +1,12 @@
+// run-pass
+
+#![allow(dead_code)]
+struct Foo(());
+
+const FOO: Foo = Foo(match 0 {
+    0.. => (),
+    _ => (),
+});
+
+fn main() {
+}