mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-04 19:29:07 +00:00
Rename BuiltinShim
-> CloneShim
This commit is contained in:
parent
91aa99607f
commit
4e4e55aa77
@ -721,7 +721,7 @@ impl<'a, 'gcx, 'tcx> HashStable<StableHashingContext<'a, 'gcx, 'tcx>> for ty::In
|
|||||||
def_id.hash_stable(hcx, hasher);
|
def_id.hash_stable(hcx, hasher);
|
||||||
t.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);
|
def_id.hash_stable(hcx, hasher);
|
||||||
t.hash_stable(hcx, hasher);
|
t.hash_stable(hcx, hasher);
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ pub enum InstanceDef<'tcx> {
|
|||||||
DropGlue(DefId, Option<Ty<'tcx>>),
|
DropGlue(DefId, Option<Ty<'tcx>>),
|
||||||
|
|
||||||
/// Builtin method implementation, e.g. `Clone::clone`.
|
/// Builtin method implementation, e.g. `Clone::clone`.
|
||||||
BuiltinShim(DefId, Ty<'tcx>),
|
CloneShim(DefId, Ty<'tcx>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> InstanceDef<'tcx> {
|
impl<'tcx> InstanceDef<'tcx> {
|
||||||
@ -52,7 +52,7 @@ impl<'tcx> InstanceDef<'tcx> {
|
|||||||
InstanceDef::Intrinsic(def_id, ) |
|
InstanceDef::Intrinsic(def_id, ) |
|
||||||
InstanceDef::ClosureOnceShim { call_once: def_id } |
|
InstanceDef::ClosureOnceShim { call_once: def_id } |
|
||||||
InstanceDef::DropGlue(def_id, _) |
|
InstanceDef::DropGlue(def_id, _) |
|
||||||
InstanceDef::BuiltinShim(def_id, _) => def_id
|
InstanceDef::CloneShim(def_id, _) => def_id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ impl<'tcx> fmt::Display for Instance<'tcx> {
|
|||||||
InstanceDef::DropGlue(_, ty) => {
|
InstanceDef::DropGlue(_, ty) => {
|
||||||
write!(f, " - shim({:?})", ty)
|
write!(f, " - shim({:?})", ty)
|
||||||
}
|
}
|
||||||
InstanceDef::BuiltinShim(_, ty) => {
|
InstanceDef::CloneShim(_, ty) => {
|
||||||
write!(f, " - shim({:?})", ty)
|
write!(f, " - shim({:?})", ty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2228,7 +2228,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||||||
ty::InstanceDef::Virtual(..) |
|
ty::InstanceDef::Virtual(..) |
|
||||||
ty::InstanceDef::ClosureOnceShim { .. } |
|
ty::InstanceDef::ClosureOnceShim { .. } |
|
||||||
ty::InstanceDef::DropGlue(..) |
|
ty::InstanceDef::DropGlue(..) |
|
||||||
ty::InstanceDef::BuiltinShim(..) => {
|
ty::InstanceDef::CloneShim(..) => {
|
||||||
self.mir_shims(instance)
|
self.mir_shims(instance)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,16 +99,15 @@ fn make_shim<'a, 'tcx>(tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
|
|||||||
ty::InstanceDef::DropGlue(def_id, ty) => {
|
ty::InstanceDef::DropGlue(def_id, ty) => {
|
||||||
build_drop_shim(tcx, 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 name = tcx.item_name(def_id).as_str();
|
||||||
let trait_id = tcx.trait_of_item(def_id);
|
if name == "clone" {
|
||||||
if trait_id == tcx.lang_items.clone_trait() && name == "clone" {
|
|
||||||
build_clone_shim(tcx, def_id, ty)
|
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);
|
debug!("make_shim({:?}: using default trait implementation", instance);
|
||||||
return tcx.optimized_mir(def_id);
|
return tcx.optimized_mir(def_id);
|
||||||
} else {
|
} else {
|
||||||
bug!("builtin shim {:?} not supported", instance)
|
bug!("builtin clone shim {:?} not supported", instance)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ty::InstanceDef::Intrinsic(_) => {
|
ty::InstanceDef::Intrinsic(_) => {
|
||||||
@ -272,10 +271,10 @@ impl<'a, 'tcx> DropElaborator<'a, 'tcx> for DropShimElaborator<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 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>,
|
fn build_clone_shim<'a, 'tcx>(tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
def_id: DefId,
|
def_id: DefId,
|
||||||
rcvr_ty: ty::Ty<'tcx>)
|
self_ty: ty::Ty<'tcx>)
|
||||||
-> Mir<'tcx>
|
-> Mir<'tcx>
|
||||||
{
|
{
|
||||||
let sig = tcx.fn_sig(def_id);
|
let sig = tcx.fn_sig(def_id);
|
||||||
@ -348,7 +347,7 @@ fn build_clone_shim<'a, 'tcx>(tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
|
|||||||
loc
|
loc
|
||||||
};
|
};
|
||||||
|
|
||||||
match rcvr_ty.sty {
|
match self_ty.sty {
|
||||||
ty::TyArray(ty, len) => {
|
ty::TyArray(ty, len) => {
|
||||||
let mut returns = Vec::new();
|
let mut returns = Vec::new();
|
||||||
for i in 0..len {
|
for i in 0..len {
|
||||||
|
@ -700,7 +700,7 @@ fn visit_instance_use<'a, 'tcx>(scx: &SharedCrateContext<'a, 'tcx>,
|
|||||||
ty::InstanceDef::ClosureOnceShim { .. } |
|
ty::InstanceDef::ClosureOnceShim { .. } |
|
||||||
ty::InstanceDef::Item(..) |
|
ty::InstanceDef::Item(..) |
|
||||||
ty::InstanceDef::FnPtrShim(..) |
|
ty::InstanceDef::FnPtrShim(..) |
|
||||||
ty::InstanceDef::BuiltinShim(..) => {
|
ty::InstanceDef::CloneShim(..) => {
|
||||||
output.push(create_fn_trans_item(instance));
|
output.push(create_fn_trans_item(instance));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -718,7 +718,7 @@ fn should_trans_locally<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: &Instan
|
|||||||
ty::InstanceDef::FnPtrShim(..) |
|
ty::InstanceDef::FnPtrShim(..) |
|
||||||
ty::InstanceDef::DropGlue(..) |
|
ty::InstanceDef::DropGlue(..) |
|
||||||
ty::InstanceDef::Intrinsic(_) |
|
ty::InstanceDef::Intrinsic(_) |
|
||||||
ty::InstanceDef::BuiltinShim(..) => return true
|
ty::InstanceDef::CloneShim(..) => return true
|
||||||
};
|
};
|
||||||
match tcx.hir.get_if_local(def_id) {
|
match tcx.hir.get_if_local(def_id) {
|
||||||
Some(hir_map::NodeForeignItem(..)) => {
|
Some(hir_map::NodeForeignItem(..)) => {
|
||||||
|
@ -143,9 +143,9 @@ fn resolve_associated_item<'a, 'tcx>(
|
|||||||
substs: rcvr_substs
|
substs: rcvr_substs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
traits::VtableBuiltin(..) => {
|
traits::VtableBuiltin(..) if Some(trait_id) == tcx.lang_items.clone_trait() => {
|
||||||
Instance {
|
Instance {
|
||||||
def: ty::InstanceDef::BuiltinShim(def_id, trait_ref.self_ty()),
|
def: ty::InstanceDef::CloneShim(def_id, trait_ref.self_ty()),
|
||||||
substs: rcvr_substs
|
substs: rcvr_substs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -362,7 +362,7 @@ fn place_root_translation_items<'a, 'tcx, I>(scx: &SharedCrateContext<'a, 'tcx>,
|
|||||||
InstanceDef::Intrinsic(..) |
|
InstanceDef::Intrinsic(..) |
|
||||||
InstanceDef::ClosureOnceShim { .. } |
|
InstanceDef::ClosureOnceShim { .. } |
|
||||||
InstanceDef::DropGlue(..) |
|
InstanceDef::DropGlue(..) |
|
||||||
InstanceDef::BuiltinShim(..) => {
|
InstanceDef::CloneShim(..) => {
|
||||||
bug!("partitioning: Encountered unexpected
|
bug!("partitioning: Encountered unexpected
|
||||||
root translation item: {:?}",
|
root translation item: {:?}",
|
||||||
trans_item)
|
trans_item)
|
||||||
@ -605,7 +605,7 @@ fn characteristic_def_id_of_trans_item<'a, 'tcx>(scx: &SharedCrateContext<'a, 't
|
|||||||
ty::InstanceDef::Intrinsic(..) |
|
ty::InstanceDef::Intrinsic(..) |
|
||||||
ty::InstanceDef::DropGlue(..) |
|
ty::InstanceDef::DropGlue(..) |
|
||||||
ty::InstanceDef::Virtual(..) |
|
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
|
// If this is a method, we want to put it into the same module as
|
||||||
|
Loading…
Reference in New Issue
Block a user