Skip to content

Commit 74d6958

Browse files
authored
Rollup merge of #113107 - mj10021:issue-113012-fix, r=oli-obk
add check for ConstKind::Value(_) to in_operand() Added check for valtree value to close #113012 which fixes the issue, although I am not sure if adding the check there is sound or not cc `@oli-obk`
2 parents 5871bc8 + 71362c7 commit 74d6958

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

Diff for: compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -344,15 +344,18 @@ where
344344
};
345345

346346
// Check the qualifs of the value of `const` items.
347-
// FIXME(valtrees): check whether const qualifs should behave the same
348-
// way for type and mir constants.
349347
let uneval = match constant.literal {
350348
ConstantKind::Ty(ct)
351-
if matches!(ct.kind(), ty::ConstKind::Param(_) | ty::ConstKind::Error(_)) =>
349+
if matches!(
350+
ct.kind(),
351+
ty::ConstKind::Param(_) | ty::ConstKind::Error(_) | ty::ConstKind::Value(_)
352+
) =>
352353
{
353354
None
354355
}
355-
ConstantKind::Ty(c) => bug!("expected ConstKind::Param here, found {:?}", c),
356+
ConstantKind::Ty(c) => {
357+
bug!("expected ConstKind::Param or ConstKind::Value here, found {:?}", c)
358+
}
356359
ConstantKind::Unevaluated(uv, _) => Some(uv),
357360
ConstantKind::Val(..) => None,
358361
};

Diff for: tests/ui/match/issue-113012.rs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// run-pass
2+
3+
#![allow(dead_code)]
4+
struct Foo(());
5+
6+
const FOO: Foo = Foo(match 0 {
7+
0.. => (),
8+
_ => (),
9+
});
10+
11+
fn main() {
12+
}

0 commit comments

Comments
 (0)