summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2018-02-07 10:28:31 -0800
committerManish Goregaokar <manishsmail@gmail.com>2018-02-07 16:17:48 -0800
commitea86482489ffdca96f915319b2dad8a09a43050a (patch)
treefe7ce23d95b9217e1754ba69ca34942e337f9159
parent453f508d9c1dfd9869e5121c4dc3b95cb8b529d7 (diff)
downloadrust-ea86482489ffdca96f915319b2dad8a09a43050a.tar.gz
Remove ty from CloneCopyShim so that it creates a single shim for all monomorphizations
-rw-r--r--src/librustc/ich/impls_ty.rs4
-rw-r--r--src/librustc/ty/instance.rs10
-rw-r--r--src/librustc_mir/shim.rs10
3 files changed, 16 insertions, 8 deletions
diff --git a/src/librustc/ich/impls_ty.rs b/src/librustc/ich/impls_ty.rs
index b8e71f2caf6..8f33dde4229 100644
--- a/src/librustc/ich/impls_ty.rs
+++ b/src/librustc/ich/impls_ty.rs
@@ -758,7 +758,9 @@ impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::InstanceDef<'gcx> {
def_id.hash_stable(hcx, hasher);
t.hash_stable(hcx, hasher);
}
- ty::InstanceDef::CloneCopyShim(def_id, t) |
+ ty::InstanceDef::CloneCopyShim(def_id) => {
+ def_id.hash_stable(hcx, hasher);
+ }
ty::InstanceDef::CloneStructuralShim(def_id, t) |
ty::InstanceDef::CloneNominalShim(def_id, t) => {
def_id.hash_stable(hcx, hasher);
diff --git a/src/librustc/ty/instance.rs b/src/librustc/ty/instance.rs
index 82074221e14..3812ba16347 100644
--- a/src/librustc/ty/instance.rs
+++ b/src/librustc/ty/instance.rs
@@ -43,7 +43,7 @@ pub enum InstanceDef<'tcx> {
DropGlue(DefId, Option<Ty<'tcx>>),
///`<T as Clone>::clone` shim for Copy types
- CloneCopyShim(DefId, Ty<'tcx>),
+ CloneCopyShim(DefId),
///`<T as Clone>::clone` shim for arrays and tuples
CloneStructuralShim(DefId, Ty<'tcx>),
///`<T as Clone>::clone` shim for closures
@@ -70,7 +70,7 @@ impl<'tcx> InstanceDef<'tcx> {
InstanceDef::Intrinsic(def_id, ) |
InstanceDef::ClosureOnceShim { call_once: def_id } |
InstanceDef::DropGlue(def_id, _) |
- InstanceDef::CloneCopyShim(def_id, _) |
+ InstanceDef::CloneCopyShim(def_id) |
InstanceDef::CloneStructuralShim(def_id, _) |
InstanceDef::CloneNominalShim(def_id, _) => def_id
}
@@ -138,7 +138,9 @@ impl<'tcx> fmt::Display for Instance<'tcx> {
InstanceDef::DropGlue(_, ty) => {
write!(f, " - shim({:?})", ty)
}
- InstanceDef::CloneCopyShim(_, ty) |
+ InstanceDef::CloneCopyShim(def) => {
+ write!(f, " - shim({:?})", def)
+ }
InstanceDef::CloneStructuralShim(_, ty) |
InstanceDef::CloneNominalShim(_, ty) => {
write!(f, " - shim({:?})", ty)
@@ -303,7 +305,7 @@ fn resolve_associated_item<'a, 'tcx>(
let self_ty = trait_ref.self_ty();
match self_ty.sty {
_ if !self_ty.moves_by_default(tcx, param_env, DUMMY_SP) => {
- ty::InstanceDef::CloneCopyShim(def_id, self_ty)
+ ty::InstanceDef::CloneCopyShim(def_id)
}
ty::TyArray(..) => ty::InstanceDef::CloneStructuralShim(def_id, self_ty),
ty::TyTuple(..) => ty::InstanceDef::CloneStructuralShim(def_id, self_ty),
diff --git a/src/librustc_mir/shim.rs b/src/librustc_mir/shim.rs
index 46481a5c11e..98889c1047c 100644
--- a/src/librustc_mir/shim.rs
+++ b/src/librustc_mir/shim.rs
@@ -99,7 +99,13 @@ fn make_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
ty::InstanceDef::DropGlue(def_id, ty) => {
build_drop_shim(tcx, def_id, ty)
}
- ty::InstanceDef::CloneCopyShim(def_id, ty) |
+ ty::InstanceDef::CloneCopyShim(def_id) => {
+ let substs = Substs::identity_for_item(tcx, def_id);
+ let self_ty = substs.type_at(0);
+ let mut builder = CloneShimBuilder::new(tcx, def_id, self_ty);
+ builder.copy_shim();
+ builder.into_mir()
+ }
ty::InstanceDef::CloneNominalShim(def_id, ty) |
ty::InstanceDef::CloneStructuralShim(def_id, ty) => {
build_clone_shim(tcx, def_id, ty)
@@ -289,13 +295,11 @@ fn build_clone_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
debug!("build_clone_shim(def_id={:?})", def_id);
let mut builder = CloneShimBuilder::new(tcx, def_id, self_ty);
- let is_copy = !self_ty.moves_by_default(tcx, tcx.param_env(def_id), builder.span);
let dest = Place::Local(RETURN_PLACE);
let src = Place::Local(Local::new(1+0)).deref();
match self_ty.sty {
- _ if is_copy => builder.copy_shim(),
ty::TyArray(ty, len) => {
let len = len.val.to_const_int().unwrap().to_u64().unwrap();
builder.array_shim(dest, src, ty, len)