implement valtrees as the type-system representation for constant values

This commit is contained in:
b-naber
2022-02-16 10:56:01 +01:00
parent edab34ab2a
commit 705d818bd5
116 changed files with 1606 additions and 1032 deletions

View File

@@ -2161,22 +2161,28 @@ impl<'tcx> TyCtxt<'tcx> {
}
/// Returns the possibly-auto-generated MIR of a `(DefId, Subst)` pair.
#[instrument(skip(self), level = "debug")]
pub fn instance_mir(self, instance: ty::InstanceDef<'tcx>) -> &'tcx Body<'tcx> {
match instance {
ty::InstanceDef::Item(def) => match self.def_kind(def.did) {
DefKind::Const
| DefKind::Static(..)
| DefKind::AssocConst
| DefKind::Ctor(..)
| DefKind::AnonConst
| DefKind::InlineConst => self.mir_for_ctfe_opt_const_arg(def),
// If the caller wants `mir_for_ctfe` of a function they should not be using
// `instance_mir`, so we'll assume const fn also wants the optimized version.
_ => {
assert_eq!(def.const_param_did, None);
self.optimized_mir(def.did)
ty::InstanceDef::Item(def) => {
debug!("calling def_kind on def: {:?}", def);
let def_kind = self.def_kind(def.did);
debug!("returned from def_kind: {:?}", def_kind);
match def_kind {
DefKind::Const
| DefKind::Static(..)
| DefKind::AssocConst
| DefKind::Ctor(..)
| DefKind::AnonConst
| DefKind::InlineConst => self.mir_for_ctfe_opt_const_arg(def),
// If the caller wants `mir_for_ctfe` of a function they should not be using
// `instance_mir`, so we'll assume const fn also wants the optimized version.
_ => {
assert_eq!(def.const_param_did, None);
self.optimized_mir(def.did)
}
}
},
}
ty::InstanceDef::VtableShim(..)
| ty::InstanceDef::ReifyShim(..)
| ty::InstanceDef::Intrinsic(..)