Add InstanceDef::VtableShim.
This commit is contained in:
parent
f99911a4a0
commit
0ad4c6f850
8 changed files with 24 additions and 1 deletions
|
|
@ -1011,6 +1011,9 @@ impl<'a, 'gcx> HashStable<StableHashingContext<'a>> for ty::InstanceDef<'gcx> {
|
|||
ty::InstanceDef::Item(def_id) => {
|
||||
def_id.hash_stable(hcx, hasher);
|
||||
}
|
||||
ty::InstanceDef::VtableShim(def_id) => {
|
||||
def_id.hash_stable(hcx, hasher);
|
||||
}
|
||||
ty::InstanceDef::Intrinsic(def_id) => {
|
||||
def_id.hash_stable(hcx, hasher);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,9 @@ pub enum InstanceDef<'tcx> {
|
|||
Item(DefId),
|
||||
Intrinsic(DefId),
|
||||
|
||||
/// `<T as Trait>::method` where `method` receives unsizeable `self: Self`.
|
||||
VtableShim(DefId),
|
||||
|
||||
/// \<fn() as FnTrait>::call_*
|
||||
/// def-id is FnTrait::call_*
|
||||
FnPtrShim(DefId, Ty<'tcx>),
|
||||
|
|
@ -63,6 +66,7 @@ impl<'tcx> InstanceDef<'tcx> {
|
|||
pub fn def_id(&self) -> DefId {
|
||||
match *self {
|
||||
InstanceDef::Item(def_id) |
|
||||
InstanceDef::VtableShim(def_id) |
|
||||
InstanceDef::FnPtrShim(def_id, _) |
|
||||
InstanceDef::Virtual(def_id, _) |
|
||||
InstanceDef::Intrinsic(def_id, ) |
|
||||
|
|
@ -120,6 +124,9 @@ impl<'tcx> fmt::Display for Instance<'tcx> {
|
|||
ppaux::parameterized(f, self.substs, self.def_id(), &[])?;
|
||||
match self.def {
|
||||
InstanceDef::Item(_) => Ok(()),
|
||||
InstanceDef::VtableShim(_) => {
|
||||
write!(f, " - shim(vtable)")
|
||||
}
|
||||
InstanceDef::Intrinsic(_) => {
|
||||
write!(f, " - intrinsic")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2759,6 +2759,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
ty::InstanceDef::Item(did) => {
|
||||
self.optimized_mir(did)
|
||||
}
|
||||
ty::InstanceDef::VtableShim(..) |
|
||||
ty::InstanceDef::Intrinsic(..) |
|
||||
ty::InstanceDef::FnPtrShim(..) |
|
||||
ty::InstanceDef::Virtual(..) |
|
||||
|
|
|
|||
|
|
@ -624,6 +624,8 @@ impl<'a, 'tcx> Lift<'tcx> for ty::InstanceDef<'a> {
|
|||
match *self {
|
||||
ty::InstanceDef::Item(def_id) =>
|
||||
Some(ty::InstanceDef::Item(def_id)),
|
||||
ty::InstanceDef::VtableShim(def_id) =>
|
||||
Some(ty::InstanceDef::VtableShim(def_id)),
|
||||
ty::InstanceDef::Intrinsic(def_id) =>
|
||||
Some(ty::InstanceDef::Intrinsic(def_id)),
|
||||
ty::InstanceDef::FnPtrShim(def_id, ref ty) =>
|
||||
|
|
@ -793,6 +795,7 @@ impl<'tcx> TypeFoldable<'tcx> for ty::instance::Instance<'tcx> {
|
|||
substs: self.substs.fold_with(folder),
|
||||
def: match self.def {
|
||||
Item(did) => Item(did.fold_with(folder)),
|
||||
VtableShim(did) => VtableShim(did.fold_with(folder)),
|
||||
Intrinsic(did) => Intrinsic(did.fold_with(folder)),
|
||||
FnPtrShim(did, ty) => FnPtrShim(
|
||||
did.fold_with(folder),
|
||||
|
|
@ -821,7 +824,7 @@ impl<'tcx> TypeFoldable<'tcx> for ty::instance::Instance<'tcx> {
|
|||
use ty::InstanceDef::*;
|
||||
self.substs.visit_with(visitor) ||
|
||||
match self.def {
|
||||
Item(did) | Intrinsic(did) | Virtual(did, _) => {
|
||||
Item(did) | VtableShim(did) | Intrinsic(did) | Virtual(did, _) => {
|
||||
did.visit_with(visitor)
|
||||
},
|
||||
FnPtrShim(did, ty) | CloneShim(did, ty) => {
|
||||
|
|
|
|||
|
|
@ -256,6 +256,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
|
|||
self.dump_place(*dest);
|
||||
Ok(())
|
||||
}
|
||||
ty::InstanceDef::VtableShim(..) |
|
||||
ty::InstanceDef::ClosureOnceShim { .. } |
|
||||
ty::InstanceDef::FnPtrShim(..) |
|
||||
ty::InstanceDef::DropGlue(..) |
|
||||
|
|
|
|||
|
|
@ -705,6 +705,7 @@ fn visit_instance_use<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
bug!("intrinsic {:?} being reified", def_id);
|
||||
}
|
||||
}
|
||||
ty::InstanceDef::VtableShim(..) |
|
||||
ty::InstanceDef::Virtual(..) |
|
||||
ty::InstanceDef::DropGlue(_, None) => {
|
||||
// don't need to emit shim if we are calling directly.
|
||||
|
|
@ -731,6 +732,7 @@ fn should_monomorphize_locally<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance:
|
|||
-> bool {
|
||||
let def_id = match instance.def {
|
||||
ty::InstanceDef::Item(def_id) => def_id,
|
||||
ty::InstanceDef::VtableShim(..) |
|
||||
ty::InstanceDef::ClosureOnceShim { .. } |
|
||||
ty::InstanceDef::Virtual(..) |
|
||||
ty::InstanceDef::FnPtrShim(..) |
|
||||
|
|
|
|||
|
|
@ -180,6 +180,7 @@ pub trait CodegenUnitExt<'tcx> {
|
|||
InstanceDef::Item(def_id) => {
|
||||
tcx.hir.as_local_node_id(def_id)
|
||||
}
|
||||
InstanceDef::VtableShim(..) |
|
||||
InstanceDef::Intrinsic(..) |
|
||||
InstanceDef::FnPtrShim(..) |
|
||||
InstanceDef::Virtual(..) |
|
||||
|
|
@ -422,6 +423,7 @@ fn mono_item_visibility(
|
|||
InstanceDef::Item(def_id) => def_id,
|
||||
|
||||
// These are all compiler glue and such, never exported, always hidden.
|
||||
InstanceDef::VtableShim(..) |
|
||||
InstanceDef::FnPtrShim(..) |
|
||||
InstanceDef::Virtual(..) |
|
||||
InstanceDef::Intrinsic(..) |
|
||||
|
|
@ -756,6 +758,7 @@ fn characteristic_def_id_of_mono_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
MonoItem::Fn(instance) => {
|
||||
let def_id = match instance.def {
|
||||
ty::InstanceDef::Item(def_id) => def_id,
|
||||
ty::InstanceDef::VtableShim(..) |
|
||||
ty::InstanceDef::FnPtrShim(..) |
|
||||
ty::InstanceDef::ClosureOnceShim { .. } |
|
||||
ty::InstanceDef::Intrinsic(..) |
|
||||
|
|
|
|||
|
|
@ -43,6 +43,9 @@ fn make_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
let mut result = match instance {
|
||||
ty::InstanceDef::Item(..) =>
|
||||
bug!("item {:?} passed to make_shim", instance),
|
||||
ty::InstanceDef::VtableShim(..) => {
|
||||
unimplemented!("make_shim({:?})", instance);
|
||||
}
|
||||
ty::InstanceDef::FnPtrShim(def_id, ty) => {
|
||||
let trait_ = tcx.trait_of_item(def_id).unwrap();
|
||||
let adjustment = match tcx.lang_items().fn_trait_kind(trait_) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue