def_id.hash_stable(hcx, hasher);
t.hash_stable(hcx, hasher);
}
- ty::InstanceDef::BuiltinShim(def_id, t) => {
+ ty::InstanceDef::CloneShim(def_id, t) => {
def_id.hash_stable(hcx, hasher);
t.hash_stable(hcx, hasher);
}
DropGlue(DefId, Option<Ty<'tcx>>),
/// Builtin method implementation, e.g. `Clone::clone`.
- BuiltinShim(DefId, Ty<'tcx>),
+ CloneShim(DefId, Ty<'tcx>),
}
impl<'tcx> InstanceDef<'tcx> {
InstanceDef::Intrinsic(def_id, ) |
InstanceDef::ClosureOnceShim { call_once: def_id } |
InstanceDef::DropGlue(def_id, _) |
- InstanceDef::BuiltinShim(def_id, _) => def_id
+ InstanceDef::CloneShim(def_id, _) => def_id
}
}
InstanceDef::DropGlue(_, ty) => {
write!(f, " - shim({:?})", ty)
}
- InstanceDef::BuiltinShim(_, ty) => {
+ InstanceDef::CloneShim(_, ty) => {
write!(f, " - shim({:?})", ty)
}
}
ty::InstanceDef::Virtual(..) |
ty::InstanceDef::ClosureOnceShim { .. } |
ty::InstanceDef::DropGlue(..) |
- ty::InstanceDef::BuiltinShim(..) => {
+ ty::InstanceDef::CloneShim(..) => {
self.mir_shims(instance)
}
}
ty::InstanceDef::DropGlue(def_id, ty) => {
build_drop_shim(tcx, def_id, ty)
}
- ty::InstanceDef::BuiltinShim(def_id, ty) => {
+ ty::InstanceDef::CloneShim(def_id, ty) => {
let name = tcx.item_name(def_id).as_str();
- let trait_id = tcx.trait_of_item(def_id);
- if trait_id == tcx.lang_items.clone_trait() && name == "clone" {
+ if name == "clone" {
build_clone_shim(tcx, def_id, ty)
- } else if trait_id == tcx.lang_items.clone_trait() && name == "clone_from" {
+ } else if name == "clone_from" {
debug!("make_shim({:?}: using default trait implementation", instance);
return tcx.optimized_mir(def_id);
} else {
- bug!("builtin shim {:?} not supported", instance)
+ bug!("builtin clone shim {:?} not supported", instance)
}
}
ty::InstanceDef::Intrinsic(_) => {
}
}
-/// Build a `Clone::clone` shim for `recvr_ty`. Here, `def_id` is `Clone::clone`.
+/// Build a `Clone::clone` shim for `self_ty`. Here, `def_id` is `Clone::clone`.
fn build_clone_shim<'a, 'tcx>(tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
def_id: DefId,
- rcvr_ty: ty::Ty<'tcx>)
+ self_ty: ty::Ty<'tcx>)
-> Mir<'tcx>
{
let sig = tcx.fn_sig(def_id);
loc
};
- match rcvr_ty.sty {
+ match self_ty.sty {
ty::TyArray(ty, len) => {
let mut returns = Vec::new();
for i in 0..len {
ty::InstanceDef::ClosureOnceShim { .. } |
ty::InstanceDef::Item(..) |
ty::InstanceDef::FnPtrShim(..) |
- ty::InstanceDef::BuiltinShim(..) => {
+ ty::InstanceDef::CloneShim(..) => {
output.push(create_fn_trans_item(instance));
}
}
ty::InstanceDef::FnPtrShim(..) |
ty::InstanceDef::DropGlue(..) |
ty::InstanceDef::Intrinsic(_) |
- ty::InstanceDef::BuiltinShim(..) => return true
+ ty::InstanceDef::CloneShim(..) => return true
};
match tcx.hir.get_if_local(def_id) {
Some(hir_map::NodeForeignItem(..)) => {
substs: rcvr_substs
}
}
- traits::VtableBuiltin(..) => {
+ traits::VtableBuiltin(..) if Some(trait_id) == tcx.lang_items.clone_trait() => {
Instance {
- def: ty::InstanceDef::BuiltinShim(def_id, trait_ref.self_ty()),
+ def: ty::InstanceDef::CloneShim(def_id, trait_ref.self_ty()),
substs: rcvr_substs
}
}
InstanceDef::Intrinsic(..) |
InstanceDef::ClosureOnceShim { .. } |
InstanceDef::DropGlue(..) |
- InstanceDef::BuiltinShim(..) => {
+ InstanceDef::CloneShim(..) => {
bug!("partitioning: Encountered unexpected
root translation item: {:?}",
trans_item)
ty::InstanceDef::Intrinsic(..) |
ty::InstanceDef::DropGlue(..) |
ty::InstanceDef::Virtual(..) |
- ty::InstanceDef::BuiltinShim(..) => return None
+ ty::InstanceDef::CloneShim(..) => return None
};
// If this is a method, we want to put it into the same module as