Skip to content

Commit 0ad4c6f

Browse files
committed
Add InstanceDef::VtableShim.
1 parent f99911a commit 0ad4c6f

File tree

8 files changed

+24
-1
lines changed

8 files changed

+24
-1
lines changed

src/librustc/ich/impls_ty.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,9 @@ impl<'a, 'gcx> HashStable<StableHashingContext<'a>> for ty::InstanceDef<'gcx> {
10111011
ty::InstanceDef::Item(def_id) => {
10121012
def_id.hash_stable(hcx, hasher);
10131013
}
1014+
ty::InstanceDef::VtableShim(def_id) => {
1015+
def_id.hash_stable(hcx, hasher);
1016+
}
10141017
ty::InstanceDef::Intrinsic(def_id) => {
10151018
def_id.hash_stable(hcx, hasher);
10161019
}

src/librustc/ty/instance.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ pub enum InstanceDef<'tcx> {
2727
Item(DefId),
2828
Intrinsic(DefId),
2929

30+
/// `<T as Trait>::method` where `method` receives unsizeable `self: Self`.
31+
VtableShim(DefId),
32+
3033
/// \<fn() as FnTrait>::call_*
3134
/// def-id is FnTrait::call_*
3235
FnPtrShim(DefId, Ty<'tcx>),
@@ -63,6 +66,7 @@ impl<'tcx> InstanceDef<'tcx> {
6366
pub fn def_id(&self) -> DefId {
6467
match *self {
6568
InstanceDef::Item(def_id) |
69+
InstanceDef::VtableShim(def_id) |
6670
InstanceDef::FnPtrShim(def_id, _) |
6771
InstanceDef::Virtual(def_id, _) |
6872
InstanceDef::Intrinsic(def_id, ) |
@@ -120,6 +124,9 @@ impl<'tcx> fmt::Display for Instance<'tcx> {
120124
ppaux::parameterized(f, self.substs, self.def_id(), &[])?;
121125
match self.def {
122126
InstanceDef::Item(_) => Ok(()),
127+
InstanceDef::VtableShim(_) => {
128+
write!(f, " - shim(vtable)")
129+
}
123130
InstanceDef::Intrinsic(_) => {
124131
write!(f, " - intrinsic")
125132
}

src/librustc/ty/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2759,6 +2759,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
27592759
ty::InstanceDef::Item(did) => {
27602760
self.optimized_mir(did)
27612761
}
2762+
ty::InstanceDef::VtableShim(..) |
27622763
ty::InstanceDef::Intrinsic(..) |
27632764
ty::InstanceDef::FnPtrShim(..) |
27642765
ty::InstanceDef::Virtual(..) |

src/librustc/ty/structural_impls.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,8 @@ impl<'a, 'tcx> Lift<'tcx> for ty::InstanceDef<'a> {
624624
match *self {
625625
ty::InstanceDef::Item(def_id) =>
626626
Some(ty::InstanceDef::Item(def_id)),
627+
ty::InstanceDef::VtableShim(def_id) =>
628+
Some(ty::InstanceDef::VtableShim(def_id)),
627629
ty::InstanceDef::Intrinsic(def_id) =>
628630
Some(ty::InstanceDef::Intrinsic(def_id)),
629631
ty::InstanceDef::FnPtrShim(def_id, ref ty) =>
@@ -793,6 +795,7 @@ impl<'tcx> TypeFoldable<'tcx> for ty::instance::Instance<'tcx> {
793795
substs: self.substs.fold_with(folder),
794796
def: match self.def {
795797
Item(did) => Item(did.fold_with(folder)),
798+
VtableShim(did) => VtableShim(did.fold_with(folder)),
796799
Intrinsic(did) => Intrinsic(did.fold_with(folder)),
797800
FnPtrShim(did, ty) => FnPtrShim(
798801
did.fold_with(folder),
@@ -821,7 +824,7 @@ impl<'tcx> TypeFoldable<'tcx> for ty::instance::Instance<'tcx> {
821824
use ty::InstanceDef::*;
822825
self.substs.visit_with(visitor) ||
823826
match self.def {
824-
Item(did) | Intrinsic(did) | Virtual(did, _) => {
827+
Item(did) | VtableShim(did) | Intrinsic(did) | Virtual(did, _) => {
825828
did.visit_with(visitor)
826829
},
827830
FnPtrShim(did, ty) | CloneShim(did, ty) => {

src/librustc_mir/interpret/terminator.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
256256
self.dump_place(*dest);
257257
Ok(())
258258
}
259+
ty::InstanceDef::VtableShim(..) |
259260
ty::InstanceDef::ClosureOnceShim { .. } |
260261
ty::InstanceDef::FnPtrShim(..) |
261262
ty::InstanceDef::DropGlue(..) |

src/librustc_mir/monomorphize/collector.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,7 @@ fn visit_instance_use<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
705705
bug!("intrinsic {:?} being reified", def_id);
706706
}
707707
}
708+
ty::InstanceDef::VtableShim(..) |
708709
ty::InstanceDef::Virtual(..) |
709710
ty::InstanceDef::DropGlue(_, None) => {
710711
// 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:
731732
-> bool {
732733
let def_id = match instance.def {
733734
ty::InstanceDef::Item(def_id) => def_id,
735+
ty::InstanceDef::VtableShim(..) |
734736
ty::InstanceDef::ClosureOnceShim { .. } |
735737
ty::InstanceDef::Virtual(..) |
736738
ty::InstanceDef::FnPtrShim(..) |

src/librustc_mir/monomorphize/partitioning.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ pub trait CodegenUnitExt<'tcx> {
180180
InstanceDef::Item(def_id) => {
181181
tcx.hir.as_local_node_id(def_id)
182182
}
183+
InstanceDef::VtableShim(..) |
183184
InstanceDef::Intrinsic(..) |
184185
InstanceDef::FnPtrShim(..) |
185186
InstanceDef::Virtual(..) |
@@ -422,6 +423,7 @@ fn mono_item_visibility(
422423
InstanceDef::Item(def_id) => def_id,
423424

424425
// These are all compiler glue and such, never exported, always hidden.
426+
InstanceDef::VtableShim(..) |
425427
InstanceDef::FnPtrShim(..) |
426428
InstanceDef::Virtual(..) |
427429
InstanceDef::Intrinsic(..) |
@@ -756,6 +758,7 @@ fn characteristic_def_id_of_mono_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
756758
MonoItem::Fn(instance) => {
757759
let def_id = match instance.def {
758760
ty::InstanceDef::Item(def_id) => def_id,
761+
ty::InstanceDef::VtableShim(..) |
759762
ty::InstanceDef::FnPtrShim(..) |
760763
ty::InstanceDef::ClosureOnceShim { .. } |
761764
ty::InstanceDef::Intrinsic(..) |

src/librustc_mir/shim.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ fn make_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
4343
let mut result = match instance {
4444
ty::InstanceDef::Item(..) =>
4545
bug!("item {:?} passed to make_shim", instance),
46+
ty::InstanceDef::VtableShim(..) => {
47+
unimplemented!("make_shim({:?})", instance);
48+
}
4649
ty::InstanceDef::FnPtrShim(def_id, ty) => {
4750
let trait_ = tcx.trait_of_item(def_id).unwrap();
4851
let adjustment = match tcx.lang_items().fn_trait_kind(trait_) {

0 commit comments

Comments
 (0)