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 a2d23425f3bc2..36c76e532313d 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 0000000000000..da7a8b65b97ba --- /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() { +}