]> git.lizzy.rs Git - rust.git/commitdiff
Rename `BuiltinShim` -> `CloneShim`
authorscalexm <martin.alex32@hotmail.fr>
Mon, 7 Aug 2017 14:21:08 +0000 (16:21 +0200)
committerscalexm <martin.alex32@hotmail.fr>
Mon, 14 Aug 2017 13:07:21 +0000 (15:07 +0200)
src/librustc/ich/impls_ty.rs
src/librustc/ty/instance.rs
src/librustc/ty/mod.rs
src/librustc_mir/shim.rs
src/librustc_trans/collector.rs
src/librustc_trans/monomorphize.rs
src/librustc_trans/partitioning.rs

index 5b75ce7864f8d6fad964c52e0f434b3cc8aebf5c..ec957b427be339ec5e0e0eb68328708431518468 100644 (file)
@@ -721,7 +721,7 @@ fn hash_stable<W: StableHasherResult>(&self,
                 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);
             }
index e8daf7c09f4f2aa79a858274082d6e80ea0c9f3b..7d543f689c24d179283eaa80904b2906b4070bab 100644 (file)
@@ -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> {
@@ -52,7 +52,7 @@ pub fn def_id(&self) -> DefId {
             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
         }
     }
 
@@ -87,7 +87,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
             InstanceDef::DropGlue(_, ty) => {
                 write!(f, " - shim({:?})", ty)
             }
-            InstanceDef::BuiltinShim(_, ty) => {
+            InstanceDef::CloneShim(_, ty) => {
                 write!(f, " - shim({:?})", ty)
             }
         }
index 81a0af63942ed930dccff2a7cee8960ac660e4ee..8c77dde0d2564117dd125281cb3e778246576fcb 100644 (file)
@@ -2228,7 +2228,7 @@ pub fn instance_mir(self, instance: ty::InstanceDef<'gcx>)
             ty::InstanceDef::Virtual(..) |
             ty::InstanceDef::ClosureOnceShim { .. } |
             ty::InstanceDef::DropGlue(..) |
-            ty::InstanceDef::BuiltinShim(..) => {
+            ty::InstanceDef::CloneShim(..) => {
                 self.mir_shims(instance)
             }
         }
index 040d96b0dcc7c994c5b4d07e5485995d82c24b2e..818e713cf4850aef13a732f288cc80dcdfa7dfb6 100644 (file)
@@ -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(_) => {
@@ -272,10 +271,10 @@ fn downcast_subpath(&self, _path: Self::Path, _variant: usize) -> Option<Self::P
     }
 }
 
-/// 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);
@@ -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 {
index 4e02810b040cab696bb5e818f29fe6e5d71e9a07..a6f7e931a678e83a797a7f3facb5aa9c8bebf155 100644 (file)
@@ -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));
         }
     }
@@ -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(..)) => {
index 401ee8cfaa8c917341e540c233d25073398e55d3..b0d8be23b0d968358b9027204582a3f9d97fa649 100644 (file)
@@ -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
             }
         }
index 0149714d0b79935ba99545d4df4e873c0a60ddfa..26256fa78dd4d51706722669445697cd961fd070 100644 (file)
@@ -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)
@@ -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