Skip to content

Commit

Permalink
Rename BuiltinShim -> CloneShim
Browse files Browse the repository at this point in the history
  • Loading branch information
scalexm committed Aug 14, 2017
1 parent 91aa996 commit 4e4e55a
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/librustc/ich/impls_ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ impl<'a, 'gcx, 'tcx> HashStable<StableHashingContext<'a, 'gcx, 'tcx>> for ty::In
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);
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/ty/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub enum InstanceDef<'tcx> {
DropGlue(DefId, Option<Ty<'tcx>>),

/// Builtin method implementation, e.g. `Clone::clone`.
BuiltinShim(DefId, Ty<'tcx>),
CloneShim(DefId, Ty<'tcx>),
}

impl<'tcx> InstanceDef<'tcx> {
Expand All @@ -52,7 +52,7 @@ 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
}
}

Expand Down Expand Up @@ -87,7 +87,7 @@ impl<'tcx> fmt::Display for Instance<'tcx> {
InstanceDef::DropGlue(_, ty) => {
write!(f, " - shim({:?})", ty)
}
InstanceDef::BuiltinShim(_, ty) => {
InstanceDef::CloneShim(_, ty) => {
write!(f, " - shim({:?})", ty)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2228,7 +2228,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
ty::InstanceDef::Virtual(..) |
ty::InstanceDef::ClosureOnceShim { .. } |
ty::InstanceDef::DropGlue(..) |
ty::InstanceDef::BuiltinShim(..) => {
ty::InstanceDef::CloneShim(..) => {
self.mir_shims(instance)
}
}
Expand Down
15 changes: 7 additions & 8 deletions src/librustc_mir/shim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,15 @@ fn make_shim<'a, 'tcx>(tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
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(_) => {
Expand Down Expand Up @@ -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>,
def_id: DefId,
rcvr_ty: ty::Ty<'tcx>)
self_ty: ty::Ty<'tcx>)
-> Mir<'tcx>
{
let sig = tcx.fn_sig(def_id);
Expand Down Expand Up @@ -348,7 +347,7 @@ fn build_clone_shim<'a, 'tcx>(tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
loc
};

match rcvr_ty.sty {
match self_ty.sty {
ty::TyArray(ty, len) => {
let mut returns = Vec::new();
for i in 0..len {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_trans/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ fn visit_instance_use<'a, 'tcx>(scx: &SharedCrateContext<'a, 'tcx>,
ty::InstanceDef::ClosureOnceShim { .. } |
ty::InstanceDef::Item(..) |
ty::InstanceDef::FnPtrShim(..) |
ty::InstanceDef::BuiltinShim(..) => {
ty::InstanceDef::CloneShim(..) => {
output.push(create_fn_trans_item(instance));
}
}
Expand All @@ -718,7 +718,7 @@ fn should_trans_locally<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: &Instan
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(..)) => {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_trans/monomorphize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ fn resolve_associated_item<'a, 'tcx>(
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
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_trans/partitioning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ fn place_root_translation_items<'a, 'tcx, I>(scx: &SharedCrateContext<'a, 'tcx>,
InstanceDef::Intrinsic(..) |
InstanceDef::ClosureOnceShim { .. } |
InstanceDef::DropGlue(..) |
InstanceDef::BuiltinShim(..) => {
InstanceDef::CloneShim(..) => {
bug!("partitioning: Encountered unexpected
root translation item: {:?}",
trans_item)
Expand Down Expand Up @@ -605,7 +605,7 @@ fn characteristic_def_id_of_trans_item<'a, 'tcx>(scx: &SharedCrateContext<'a, 't
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
Expand Down

0 comments on commit 4e4e55a

Please sign in to comment.