Skip to content

Commit

Permalink
Rollup merge of #113107 - mj10021:issue-113012-fix, r=oli-obk
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
TaKO8Ki authored Jun 28, 2023
2 parents 5871bc8 + 71362c7 commit 74d6958
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
11 changes: 7 additions & 4 deletions compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
12 changes: 12 additions & 0 deletions tests/ui/match/issue-113012.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// run-pass

#![allow(dead_code)]
struct Foo(());

const FOO: Foo = Foo(match 0 {
0.. => (),
_ => (),
});

fn main() {
}

0 comments on commit 74d6958

Please sign in to comment.