Rollup merge of #126567 - compiler-errors:instance-kind, r=oli-obk,lcnr
Rename `InstanceDef` -> `InstanceKind` Renames `InstanceDef` to `InstanceKind`. The `Def` here is confusing, and makes it hard to distinguish `Instance` and `InstanceDef`. `InstanceKind` makes this more obvious, since it's really just describing what *kind* of instance we have. Not sure if this is large enough to warrant a types team MCP -- it's only 53 files. I don't personally think it does, but happy to write one if anyone disagrees. cc ``@rust-lang/types`` r? types
This commit is contained in:
commit
940ff24ec0
53 changed files with 421 additions and 418 deletions
|
@ -68,7 +68,7 @@ use rustc_index::{Idx, IndexVec};
|
|||
use rustc_middle::mir::visit::{MutVisitor, PlaceContext, Visitor};
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::ty::CoroutineArgs;
|
||||
use rustc_middle::ty::InstanceDef;
|
||||
use rustc_middle::ty::InstanceKind;
|
||||
use rustc_middle::ty::{self, CoroutineArgsExt, Ty, TyCtxt};
|
||||
use rustc_middle::{bug, span_bug};
|
||||
use rustc_mir_dataflow::impls::{
|
||||
|
@ -1276,7 +1276,7 @@ fn create_coroutine_drop_shim<'tcx>(
|
|||
// Update the body's def to become the drop glue.
|
||||
let coroutine_instance = body.source.instance;
|
||||
let drop_in_place = tcx.require_lang_item(LangItem::DropInPlace, None);
|
||||
let drop_instance = InstanceDef::DropGlue(drop_in_place, Some(coroutine_ty));
|
||||
let drop_instance = InstanceKind::DropGlue(drop_in_place, Some(coroutine_ty));
|
||||
|
||||
// Temporary change MirSource to coroutine's instance so that dump_mir produces more sensible
|
||||
// filename.
|
||||
|
|
|
@ -75,7 +75,7 @@ use rustc_middle::bug;
|
|||
use rustc_middle::hir::place::{Projection, ProjectionKind};
|
||||
use rustc_middle::mir::visit::MutVisitor;
|
||||
use rustc_middle::mir::{self, dump_mir, MirPass};
|
||||
use rustc_middle::ty::{self, InstanceDef, Ty, TyCtxt, TypeVisitableExt};
|
||||
use rustc_middle::ty::{self, InstanceKind, Ty, TyCtxt, TypeVisitableExt};
|
||||
use rustc_target::abi::{FieldIdx, VariantIdx};
|
||||
|
||||
pub struct ByMoveBody;
|
||||
|
@ -102,7 +102,7 @@ impl<'tcx> MirPass<'tcx> for ByMoveBody {
|
|||
|
||||
// We don't need to generate a by-move coroutine if the coroutine body was
|
||||
// produced by the `CoroutineKindShim`, since it's already by-move.
|
||||
if matches!(body.source.instance, ty::InstanceDef::CoroutineKindShim { .. }) {
|
||||
if matches!(body.source.instance, ty::InstanceKind::CoroutineKindShim { .. }) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -193,7 +193,7 @@ impl<'tcx> MirPass<'tcx> for ByMoveBody {
|
|||
MakeByMoveBody { tcx, field_remapping, by_move_coroutine_ty }.visit_body(&mut by_move_body);
|
||||
dump_mir(tcx, false, "coroutine_by_move", &0, &by_move_body, |_, _| Ok(()));
|
||||
// FIXME: use query feeding to generate the body right here and then only store the `DefId` of the new body.
|
||||
by_move_body.source = mir::MirSource::from_instance(InstanceDef::CoroutineKindShim {
|
||||
by_move_body.source = mir::MirSource::from_instance(InstanceKind::CoroutineKindShim {
|
||||
coroutine_def_id: coroutine_def_id.to_def_id(),
|
||||
});
|
||||
body.coroutine.as_mut().unwrap().by_move_body = Some(by_move_body);
|
||||
|
|
|
@ -49,7 +49,7 @@ fn is_eligible_for_coverage(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
|
|||
/// Query implementation for `coverage_ids_info`.
|
||||
fn coverage_ids_info<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
instance_def: ty::InstanceDef<'tcx>,
|
||||
instance_def: ty::InstanceKind<'tcx>,
|
||||
) -> CoverageIdsInfo {
|
||||
let mir_body = tcx.instance_mir(instance_def);
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs}
|
|||
use rustc_middle::mir::visit::*;
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::ty::TypeVisitableExt;
|
||||
use rustc_middle::ty::{self, Instance, InstanceDef, ParamEnv, Ty, TyCtxt};
|
||||
use rustc_middle::ty::{self, Instance, InstanceKind, ParamEnv, Ty, TyCtxt};
|
||||
use rustc_session::config::{DebugInfo, OptLevel};
|
||||
use rustc_span::source_map::Spanned;
|
||||
use rustc_span::sym;
|
||||
|
@ -293,7 +293,7 @@ impl<'tcx> Inliner<'tcx> {
|
|||
}
|
||||
|
||||
match callee.def {
|
||||
InstanceDef::Item(_) => {
|
||||
InstanceKind::Item(_) => {
|
||||
// If there is no MIR available (either because it was not in metadata or
|
||||
// because it has no MIR because it's an extern function), then the inliner
|
||||
// won't cause cycles on this.
|
||||
|
@ -302,24 +302,24 @@ impl<'tcx> Inliner<'tcx> {
|
|||
}
|
||||
}
|
||||
// These have no own callable MIR.
|
||||
InstanceDef::Intrinsic(_) | InstanceDef::Virtual(..) => {
|
||||
InstanceKind::Intrinsic(_) | InstanceKind::Virtual(..) => {
|
||||
return Err("instance without MIR (intrinsic / virtual)");
|
||||
}
|
||||
// This cannot result in an immediate cycle since the callee MIR is a shim, which does
|
||||
// not get any optimizations run on it. Any subsequent inlining may cause cycles, but we
|
||||
// do not need to catch this here, we can wait until the inliner decides to continue
|
||||
// inlining a second time.
|
||||
InstanceDef::VTableShim(_)
|
||||
| InstanceDef::ReifyShim(..)
|
||||
| InstanceDef::FnPtrShim(..)
|
||||
| InstanceDef::ClosureOnceShim { .. }
|
||||
| InstanceDef::ConstructCoroutineInClosureShim { .. }
|
||||
| InstanceDef::CoroutineKindShim { .. }
|
||||
| InstanceDef::DropGlue(..)
|
||||
| InstanceDef::CloneShim(..)
|
||||
| InstanceDef::ThreadLocalShim(..)
|
||||
| InstanceDef::FnPtrAddrShim(..)
|
||||
| InstanceDef::AsyncDropGlueCtorShim(..) => return Ok(()),
|
||||
InstanceKind::VTableShim(_)
|
||||
| InstanceKind::ReifyShim(..)
|
||||
| InstanceKind::FnPtrShim(..)
|
||||
| InstanceKind::ClosureOnceShim { .. }
|
||||
| InstanceKind::ConstructCoroutineInClosureShim { .. }
|
||||
| InstanceKind::CoroutineKindShim { .. }
|
||||
| InstanceKind::DropGlue(..)
|
||||
| InstanceKind::CloneShim(..)
|
||||
| InstanceKind::ThreadLocalShim(..)
|
||||
| InstanceKind::FnPtrAddrShim(..)
|
||||
| InstanceKind::AsyncDropGlueCtorShim(..) => return Ok(()),
|
||||
}
|
||||
|
||||
if self.tcx.is_constructor(callee_def_id) {
|
||||
|
@ -372,7 +372,7 @@ impl<'tcx> Inliner<'tcx> {
|
|||
let callee =
|
||||
Instance::resolve(self.tcx, self.param_env, def_id, args).ok().flatten()?;
|
||||
|
||||
if let InstanceDef::Virtual(..) | InstanceDef::Intrinsic(_) = callee.def {
|
||||
if let InstanceKind::Virtual(..) | InstanceKind::Intrinsic(_) = callee.def {
|
||||
return None;
|
||||
}
|
||||
|
||||
|
@ -384,7 +384,7 @@ impl<'tcx> Inliner<'tcx> {
|
|||
|
||||
// Additionally, check that the body that we're inlining actually agrees
|
||||
// with the ABI of the trait that the item comes from.
|
||||
if let InstanceDef::Item(instance_def_id) = callee.def
|
||||
if let InstanceKind::Item(instance_def_id) = callee.def
|
||||
&& self.tcx.def_kind(instance_def_id) == DefKind::AssocFn
|
||||
&& let instance_fn_sig = self.tcx.fn_sig(instance_def_id).skip_binder()
|
||||
&& instance_fn_sig.abi() != fn_sig.abi()
|
||||
|
@ -1063,10 +1063,10 @@ impl<'tcx> MutVisitor<'tcx> for Integrator<'_, 'tcx> {
|
|||
#[instrument(skip(tcx), level = "debug")]
|
||||
fn try_instance_mir<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
instance: InstanceDef<'tcx>,
|
||||
instance: InstanceKind<'tcx>,
|
||||
) -> Result<&'tcx Body<'tcx>, &'static str> {
|
||||
if let ty::InstanceDef::DropGlue(_, Some(ty))
|
||||
| ty::InstanceDef::AsyncDropGlueCtorShim(_, Some(ty)) = instance
|
||||
if let ty::InstanceKind::DropGlue(_, Some(ty))
|
||||
| ty::InstanceKind::AsyncDropGlueCtorShim(_, Some(ty)) = instance
|
||||
&& let ty::Adt(def, args) = ty.kind()
|
||||
{
|
||||
let fields = def.all_fields();
|
||||
|
|
|
@ -3,7 +3,7 @@ use rustc_data_structures::stack::ensure_sufficient_stack;
|
|||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_middle::mir::TerminatorKind;
|
||||
use rustc_middle::ty::TypeVisitableExt;
|
||||
use rustc_middle::ty::{self, GenericArgsRef, InstanceDef, TyCtxt};
|
||||
use rustc_middle::ty::{self, GenericArgsRef, InstanceKind, TyCtxt};
|
||||
use rustc_session::Limit;
|
||||
use rustc_span::sym;
|
||||
|
||||
|
@ -22,7 +22,7 @@ pub(crate) fn mir_callgraph_reachable<'tcx>(
|
|||
"you should not call `mir_callgraph_reachable` on immediate self recursion"
|
||||
);
|
||||
assert!(
|
||||
matches!(root.def, InstanceDef::Item(_)),
|
||||
matches!(root.def, InstanceKind::Item(_)),
|
||||
"you should not call `mir_callgraph_reachable` on shims"
|
||||
);
|
||||
assert!(
|
||||
|
@ -70,7 +70,7 @@ pub(crate) fn mir_callgraph_reachable<'tcx>(
|
|||
}
|
||||
|
||||
match callee.def {
|
||||
InstanceDef::Item(_) => {
|
||||
InstanceKind::Item(_) => {
|
||||
// If there is no MIR available (either because it was not in metadata or
|
||||
// because it has no MIR because it's an extern function), then the inliner
|
||||
// won't cause cycles on this.
|
||||
|
@ -80,24 +80,24 @@ pub(crate) fn mir_callgraph_reachable<'tcx>(
|
|||
}
|
||||
}
|
||||
// These have no own callable MIR.
|
||||
InstanceDef::Intrinsic(_) | InstanceDef::Virtual(..) => continue,
|
||||
InstanceKind::Intrinsic(_) | InstanceKind::Virtual(..) => continue,
|
||||
// These have MIR and if that MIR is inlined, instantiated and then inlining is run
|
||||
// again, a function item can end up getting inlined. Thus we'll be able to cause
|
||||
// a cycle that way
|
||||
InstanceDef::VTableShim(_)
|
||||
| InstanceDef::ReifyShim(..)
|
||||
| InstanceDef::FnPtrShim(..)
|
||||
| InstanceDef::ClosureOnceShim { .. }
|
||||
| InstanceDef::ConstructCoroutineInClosureShim { .. }
|
||||
| InstanceDef::CoroutineKindShim { .. }
|
||||
| InstanceDef::ThreadLocalShim { .. }
|
||||
| InstanceDef::CloneShim(..) => {}
|
||||
InstanceKind::VTableShim(_)
|
||||
| InstanceKind::ReifyShim(..)
|
||||
| InstanceKind::FnPtrShim(..)
|
||||
| InstanceKind::ClosureOnceShim { .. }
|
||||
| InstanceKind::ConstructCoroutineInClosureShim { .. }
|
||||
| InstanceKind::CoroutineKindShim { .. }
|
||||
| InstanceKind::ThreadLocalShim { .. }
|
||||
| InstanceKind::CloneShim(..) => {}
|
||||
|
||||
// This shim does not call any other functions, thus there can be no recursion.
|
||||
InstanceDef::FnPtrAddrShim(..) => {
|
||||
InstanceKind::FnPtrAddrShim(..) => {
|
||||
continue;
|
||||
}
|
||||
InstanceDef::DropGlue(..) | InstanceDef::AsyncDropGlueCtorShim(..) => {
|
||||
InstanceKind::DropGlue(..) | InstanceKind::AsyncDropGlueCtorShim(..) => {
|
||||
// FIXME: A not fully instantiated drop shim can cause ICEs if one attempts to
|
||||
// have its MIR built. Likely oli-obk just screwed up the `ParamEnv`s, so this
|
||||
// needs some more analysis.
|
||||
|
@ -151,12 +151,12 @@ pub(crate) fn mir_callgraph_reachable<'tcx>(
|
|||
|
||||
pub(crate) fn mir_inliner_callees<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
instance: ty::InstanceDef<'tcx>,
|
||||
instance: ty::InstanceKind<'tcx>,
|
||||
) -> &'tcx [(DefId, GenericArgsRef<'tcx>)] {
|
||||
let steal;
|
||||
let guard;
|
||||
let body = match (instance, instance.def_id().as_local()) {
|
||||
(InstanceDef::Item(_), Some(def_id)) => {
|
||||
(InstanceKind::Item(_), Some(def_id)) => {
|
||||
steal = tcx.mir_promoted(def_id).0;
|
||||
guard = steal.borrow();
|
||||
&*guard
|
||||
|
|
|
@ -398,7 +398,7 @@ fn mir_drops_elaborated_and_const_checked(tcx: TyCtxt<'_>, def: LocalDefId) -> &
|
|||
if is_fn_like {
|
||||
// Do not compute the mir call graph without said call graph actually being used.
|
||||
if pm::should_run_pass(tcx, &inline::Inline) {
|
||||
tcx.ensure_with_value().mir_inliner_callees(ty::InstanceDef::Item(def.to_def_id()));
|
||||
tcx.ensure_with_value().mir_inliner_callees(ty::InstanceKind::Item(def.to_def_id()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,16 +29,16 @@ pub fn provide(providers: &mut Providers) {
|
|||
providers.mir_shims = make_shim;
|
||||
}
|
||||
|
||||
fn make_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: ty::InstanceDef<'tcx>) -> Body<'tcx> {
|
||||
fn make_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: ty::InstanceKind<'tcx>) -> Body<'tcx> {
|
||||
debug!("make_shim({:?})", instance);
|
||||
|
||||
let mut result = match instance {
|
||||
ty::InstanceDef::Item(..) => bug!("item {:?} passed to make_shim", instance),
|
||||
ty::InstanceDef::VTableShim(def_id) => {
|
||||
ty::InstanceKind::Item(..) => bug!("item {:?} passed to make_shim", instance),
|
||||
ty::InstanceKind::VTableShim(def_id) => {
|
||||
let adjustment = Adjustment::Deref { source: DerefSource::MutPtr };
|
||||
build_call_shim(tcx, instance, Some(adjustment), CallKind::Direct(def_id))
|
||||
}
|
||||
ty::InstanceDef::FnPtrShim(def_id, ty) => {
|
||||
ty::InstanceKind::FnPtrShim(def_id, ty) => {
|
||||
let trait_ = tcx.trait_of_item(def_id).unwrap();
|
||||
// Supports `Fn` or `async Fn` traits.
|
||||
let adjustment = match tcx
|
||||
|
@ -58,10 +58,10 @@ fn make_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: ty::InstanceDef<'tcx>) -> Body<'
|
|||
// a virtual call, or a direct call to a function for which
|
||||
// indirect calls must be codegen'd differently than direct ones
|
||||
// (such as `#[track_caller]`).
|
||||
ty::InstanceDef::ReifyShim(def_id, _) => {
|
||||
ty::InstanceKind::ReifyShim(def_id, _) => {
|
||||
build_call_shim(tcx, instance, None, CallKind::Direct(def_id))
|
||||
}
|
||||
ty::InstanceDef::ClosureOnceShim { call_once: _, track_caller: _ } => {
|
||||
ty::InstanceKind::ClosureOnceShim { call_once: _, track_caller: _ } => {
|
||||
let fn_mut = tcx.require_lang_item(LangItem::FnMut, None);
|
||||
let call_mut = tcx
|
||||
.associated_items(fn_mut)
|
||||
|
@ -73,16 +73,16 @@ fn make_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: ty::InstanceDef<'tcx>) -> Body<'
|
|||
build_call_shim(tcx, instance, Some(Adjustment::RefMut), CallKind::Direct(call_mut))
|
||||
}
|
||||
|
||||
ty::InstanceDef::ConstructCoroutineInClosureShim {
|
||||
ty::InstanceKind::ConstructCoroutineInClosureShim {
|
||||
coroutine_closure_def_id,
|
||||
receiver_by_ref,
|
||||
} => build_construct_coroutine_by_move_shim(tcx, coroutine_closure_def_id, receiver_by_ref),
|
||||
|
||||
ty::InstanceDef::CoroutineKindShim { coroutine_def_id } => {
|
||||
ty::InstanceKind::CoroutineKindShim { coroutine_def_id } => {
|
||||
return tcx.optimized_mir(coroutine_def_id).coroutine_by_move_body().unwrap().clone();
|
||||
}
|
||||
|
||||
ty::InstanceDef::DropGlue(def_id, ty) => {
|
||||
ty::InstanceKind::DropGlue(def_id, ty) => {
|
||||
// FIXME(#91576): Drop shims for coroutines aren't subject to the MIR passes at the end
|
||||
// of this function. Is this intentional?
|
||||
if let Some(ty::Coroutine(coroutine_def_id, args)) = ty.map(Ty::kind) {
|
||||
|
@ -127,16 +127,16 @@ fn make_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: ty::InstanceDef<'tcx>) -> Body<'
|
|||
|
||||
build_drop_shim(tcx, def_id, ty)
|
||||
}
|
||||
ty::InstanceDef::ThreadLocalShim(..) => build_thread_local_shim(tcx, instance),
|
||||
ty::InstanceDef::CloneShim(def_id, ty) => build_clone_shim(tcx, def_id, ty),
|
||||
ty::InstanceDef::FnPtrAddrShim(def_id, ty) => build_fn_ptr_addr_shim(tcx, def_id, ty),
|
||||
ty::InstanceDef::AsyncDropGlueCtorShim(def_id, ty) => {
|
||||
ty::InstanceKind::ThreadLocalShim(..) => build_thread_local_shim(tcx, instance),
|
||||
ty::InstanceKind::CloneShim(def_id, ty) => build_clone_shim(tcx, def_id, ty),
|
||||
ty::InstanceKind::FnPtrAddrShim(def_id, ty) => build_fn_ptr_addr_shim(tcx, def_id, ty),
|
||||
ty::InstanceKind::AsyncDropGlueCtorShim(def_id, ty) => {
|
||||
async_destructor_ctor::build_async_destructor_ctor_shim(tcx, def_id, ty)
|
||||
}
|
||||
ty::InstanceDef::Virtual(..) => {
|
||||
bug!("InstanceDef::Virtual ({:?}) is for direct calls only", instance)
|
||||
ty::InstanceKind::Virtual(..) => {
|
||||
bug!("InstanceKind::Virtual ({:?}) is for direct calls only", instance)
|
||||
}
|
||||
ty::InstanceDef::Intrinsic(_) => {
|
||||
ty::InstanceKind::Intrinsic(_) => {
|
||||
bug!("creating shims from intrinsics ({:?}) is unsupported", instance)
|
||||
}
|
||||
};
|
||||
|
@ -240,7 +240,7 @@ fn build_drop_shim<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, ty: Option<Ty<'tcx>>)
|
|||
block(&mut blocks, TerminatorKind::Goto { target: return_block });
|
||||
block(&mut blocks, TerminatorKind::Return);
|
||||
|
||||
let source = MirSource::from_instance(ty::InstanceDef::DropGlue(def_id, ty));
|
||||
let source = MirSource::from_instance(ty::InstanceKind::DropGlue(def_id, ty));
|
||||
let mut body =
|
||||
new_body(source, blocks, local_decls_for_sig(&sig, span), sig.inputs().len(), span);
|
||||
|
||||
|
@ -392,7 +392,10 @@ impl<'a, 'tcx> DropElaborator<'a, 'tcx> for DropShimElaborator<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn build_thread_local_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: ty::InstanceDef<'tcx>) -> Body<'tcx> {
|
||||
fn build_thread_local_shim<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
instance: ty::InstanceKind<'tcx>,
|
||||
) -> Body<'tcx> {
|
||||
let def_id = instance.def_id();
|
||||
|
||||
let span = tcx.def_span(def_id);
|
||||
|
@ -472,7 +475,7 @@ impl<'tcx> CloneShimBuilder<'tcx> {
|
|||
}
|
||||
|
||||
fn into_mir(self) -> Body<'tcx> {
|
||||
let source = MirSource::from_instance(ty::InstanceDef::CloneShim(
|
||||
let source = MirSource::from_instance(ty::InstanceKind::CloneShim(
|
||||
self.def_id,
|
||||
self.sig.inputs_and_output[0],
|
||||
));
|
||||
|
@ -682,14 +685,14 @@ impl<'tcx> CloneShimBuilder<'tcx> {
|
|||
#[instrument(level = "debug", skip(tcx), ret)]
|
||||
fn build_call_shim<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
instance: ty::InstanceDef<'tcx>,
|
||||
instance: ty::InstanceKind<'tcx>,
|
||||
rcvr_adjustment: Option<Adjustment>,
|
||||
call_kind: CallKind<'tcx>,
|
||||
) -> Body<'tcx> {
|
||||
// `FnPtrShim` contains the fn pointer type that a call shim is being built for - this is used
|
||||
// to instantiate into the signature of the shim. It is not necessary for users of this
|
||||
// MIR body to perform further instantiations (see `InstanceDef::has_polymorphic_mir_body`).
|
||||
let (sig_args, untuple_args) = if let ty::InstanceDef::FnPtrShim(_, ty) = instance {
|
||||
// MIR body to perform further instantiations (see `InstanceKind::has_polymorphic_mir_body`).
|
||||
let (sig_args, untuple_args) = if let ty::InstanceKind::FnPtrShim(_, ty) = instance {
|
||||
let sig = tcx.instantiate_bound_regions_with_erased(ty.fn_sig(tcx));
|
||||
|
||||
let untuple_args = sig.inputs();
|
||||
|
@ -741,8 +744,8 @@ fn build_call_shim<'tcx>(
|
|||
}
|
||||
|
||||
// FIXME(eddyb) avoid having this snippet both here and in
|
||||
// `Instance::fn_sig` (introduce `InstanceDef::fn_sig`?).
|
||||
if let ty::InstanceDef::VTableShim(..) = instance {
|
||||
// `Instance::fn_sig` (introduce `InstanceKind::fn_sig`?).
|
||||
if let ty::InstanceKind::VTableShim(..) = instance {
|
||||
// Modify fn(self, ...) to fn(self: *mut Self, ...)
|
||||
let mut inputs_and_output = sig.inputs_and_output.to_vec();
|
||||
let self_arg = &mut inputs_and_output[0];
|
||||
|
@ -1007,7 +1010,7 @@ fn build_fn_ptr_addr_shim<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, self_ty: Ty<'t
|
|||
terminator: Some(Terminator { source_info, kind: TerminatorKind::Return }),
|
||||
is_cleanup: false,
|
||||
};
|
||||
let source = MirSource::from_instance(ty::InstanceDef::FnPtrAddrShim(def_id, self_ty));
|
||||
let source = MirSource::from_instance(ty::InstanceKind::FnPtrAddrShim(def_id, self_ty));
|
||||
new_body(source, IndexVec::from_elem_n(start_block, 1), locals, sig.inputs().len(), span)
|
||||
}
|
||||
|
||||
|
@ -1087,7 +1090,7 @@ fn build_construct_coroutine_by_move_shim<'tcx>(
|
|||
is_cleanup: false,
|
||||
};
|
||||
|
||||
let source = MirSource::from_instance(ty::InstanceDef::ConstructCoroutineInClosureShim {
|
||||
let source = MirSource::from_instance(ty::InstanceKind::ConstructCoroutineInClosureShim {
|
||||
coroutine_closure_def_id,
|
||||
receiver_by_ref,
|
||||
});
|
||||
|
|
|
@ -529,7 +529,7 @@ impl<'tcx> AsyncDestructorCtorShimBuilder<'tcx> {
|
|||
|
||||
last_bb.terminator = Some(Terminator { source_info, kind: TerminatorKind::Return });
|
||||
|
||||
let source = MirSource::from_instance(ty::InstanceDef::AsyncDropGlueCtorShim(
|
||||
let source = MirSource::from_instance(ty::InstanceKind::AsyncDropGlueCtorShim(
|
||||
self.def_id,
|
||||
self.self_ty,
|
||||
));
|
||||
|
|
|
@ -10,7 +10,7 @@ use rustc_middle::mir::visit::{NonUseContext, PlaceContext, Visitor};
|
|||
use rustc_middle::mir::*;
|
||||
use rustc_middle::ty::adjustment::PointerCoercion;
|
||||
use rustc_middle::ty::{
|
||||
self, CoroutineArgsExt, InstanceDef, ParamEnv, ScalarInt, Ty, TyCtxt, TypeVisitableExt,
|
||||
self, CoroutineArgsExt, InstanceKind, ParamEnv, ScalarInt, Ty, TyCtxt, TypeVisitableExt,
|
||||
Variance,
|
||||
};
|
||||
use rustc_middle::{bug, span_bug};
|
||||
|
@ -44,7 +44,7 @@ impl<'tcx> MirPass<'tcx> for Validator {
|
|||
// terribly important that they pass the validator. However, I think other passes might
|
||||
// still see them, in which case they might be surprised. It would probably be better if we
|
||||
// didn't put this through the MIR pipeline at all.
|
||||
if matches!(body.source.instance, InstanceDef::Intrinsic(..) | InstanceDef::Virtual(..)) {
|
||||
if matches!(body.source.instance, InstanceKind::Intrinsic(..) | InstanceKind::Virtual(..)) {
|
||||
return;
|
||||
}
|
||||
let def_id = body.source.def_id();
|
||||
|
@ -95,7 +95,7 @@ impl<'tcx> MirPass<'tcx> for Validator {
|
|||
}
|
||||
|
||||
if let MirPhase::Runtime(_) = body.phase {
|
||||
if let ty::InstanceDef::Item(_) = body.source.instance {
|
||||
if let ty::InstanceKind::Item(_) = body.source.instance {
|
||||
if body.has_free_regions() {
|
||||
cfg_checker.fail(
|
||||
Location::START,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue