summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_middle/src/mir/interpret/queries.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /compiler/rustc_middle/src/mir/interpret/queries.rs
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz
rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_middle/src/mir/interpret/queries.rs')
-rw-r--r--compiler/rustc_middle/src/mir/interpret/queries.rs23
1 files changed, 9 insertions, 14 deletions
diff --git a/compiler/rustc_middle/src/mir/interpret/queries.rs b/compiler/rustc_middle/src/mir/interpret/queries.rs
index f53dc8cb0..9c97431f3 100644
--- a/compiler/rustc_middle/src/mir/interpret/queries.rs
+++ b/compiler/rustc_middle/src/mir/interpret/queries.rs
@@ -95,8 +95,15 @@ 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));
- let mir_body = self.mir_for_ctfe(ct.def);
+ let def_kind = self.def_kind(instance.def_id());
+ assert!(
+ matches!(
+ def_kind,
+ DefKind::InlineConst | DefKind::AnonConst | DefKind::AssocConst
+ ),
+ "{cid:?} is {def_kind:?}",
+ );
+ let mir_body = self.mir_for_ctfe(instance.def_id());
if mir_body.is_polymorphic {
let Some(local_def_id) = ct.def.as_local() else { return };
self.struct_span_lint_hir(
@@ -236,15 +243,3 @@ impl<'tcx> TyCtxtEnsure<'tcx> {
self.eval_to_allocation_raw(param_env.and(gid))
}
}
-
-impl<'tcx> TyCtxt<'tcx> {
- /// Destructure a mir constant ADT or array into its variant index and its field values.
- /// Panics if the destructuring fails, use `try_destructure_mir_constant` for fallible version.
- pub fn destructure_mir_constant(
- self,
- param_env: ty::ParamEnv<'tcx>,
- constant: mir::ConstantKind<'tcx>,
- ) -> mir::DestructuredConstant<'tcx> {
- self.try_destructure_mir_constant(param_env.and(constant)).unwrap()
- }
-}