Rollup merge of #112634 - mj10021:issue-112438-fix, r=compiler-errors

add InlineConst check

add check to close #112438
This commit is contained in:
Matthias Krüger 2023-06-15 17:52:38 +02:00 committed by GitHub
commit c0a089e118
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -95,7 +95,10 @@ impl<'tcx> TyCtxt<'tcx> {
// used generic parameters is a bug of evaluation, so checking for it
// here does feel somewhat sensible.
if !self.features().generic_const_exprs && ct.substs.has_non_region_param() {
assert!(matches!(self.def_kind(ct.def), DefKind::AnonConst));
assert!(matches!(
self.def_kind(ct.def),
DefKind::InlineConst | DefKind::AnonConst
));
let mir_body = self.mir_for_ctfe(ct.def);
if mir_body.is_polymorphic {
let Some(local_def_id) = ct.def.as_local() else { return };

View File

@ -0,0 +1,11 @@
// run-pass
#![feature(inline_const_pat)]
#![allow(dead_code)]
#![allow(incomplete_features)]
fn foo<const V: usize>() {
match 0 {
const { 1 << 5 } | _ => {}
}
}
fn main() {}