Skip to content

Commit 4e4e55a

Browse files
committed
Rename BuiltinShim -> CloneShim
1 parent 91aa996 commit 4e4e55a

File tree

7 files changed

+18
-19
lines changed

7 files changed

+18
-19
lines changed

src/librustc/ich/impls_ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ impl<'a, 'gcx, 'tcx> HashStable<StableHashingContext<'a, 'gcx, 'tcx>> for ty::In
721721
def_id.hash_stable(hcx, hasher);
722722
t.hash_stable(hcx, hasher);
723723
}
724-
ty::InstanceDef::BuiltinShim(def_id, t) => {
724+
ty::InstanceDef::CloneShim(def_id, t) => {
725725
def_id.hash_stable(hcx, hasher);
726726
t.hash_stable(hcx, hasher);
727727
}

src/librustc/ty/instance.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub enum InstanceDef<'tcx> {
3939
DropGlue(DefId, Option<Ty<'tcx>>),
4040

4141
/// Builtin method implementation, e.g. `Clone::clone`.
42-
BuiltinShim(DefId, Ty<'tcx>),
42+
CloneShim(DefId, Ty<'tcx>),
4343
}
4444

4545
impl<'tcx> InstanceDef<'tcx> {
@@ -52,7 +52,7 @@ impl<'tcx> InstanceDef<'tcx> {
5252
InstanceDef::Intrinsic(def_id, ) |
5353
InstanceDef::ClosureOnceShim { call_once: def_id } |
5454
InstanceDef::DropGlue(def_id, _) |
55-
InstanceDef::BuiltinShim(def_id, _) => def_id
55+
InstanceDef::CloneShim(def_id, _) => def_id
5656
}
5757
}
5858

@@ -87,7 +87,7 @@ impl<'tcx> fmt::Display for Instance<'tcx> {
8787
InstanceDef::DropGlue(_, ty) => {
8888
write!(f, " - shim({:?})", ty)
8989
}
90-
InstanceDef::BuiltinShim(_, ty) => {
90+
InstanceDef::CloneShim(_, ty) => {
9191
write!(f, " - shim({:?})", ty)
9292
}
9393
}

src/librustc/ty/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2228,7 +2228,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
22282228
ty::InstanceDef::Virtual(..) |
22292229
ty::InstanceDef::ClosureOnceShim { .. } |
22302230
ty::InstanceDef::DropGlue(..) |
2231-
ty::InstanceDef::BuiltinShim(..) => {
2231+
ty::InstanceDef::CloneShim(..) => {
22322232
self.mir_shims(instance)
22332233
}
22342234
}

src/librustc_mir/shim.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,15 @@ fn make_shim<'a, 'tcx>(tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
9999
ty::InstanceDef::DropGlue(def_id, ty) => {
100100
build_drop_shim(tcx, def_id, ty)
101101
}
102-
ty::InstanceDef::BuiltinShim(def_id, ty) => {
102+
ty::InstanceDef::CloneShim(def_id, ty) => {
103103
let name = tcx.item_name(def_id).as_str();
104-
let trait_id = tcx.trait_of_item(def_id);
105-
if trait_id == tcx.lang_items.clone_trait() && name == "clone" {
104+
if name == "clone" {
106105
build_clone_shim(tcx, def_id, ty)
107-
} else if trait_id == tcx.lang_items.clone_trait() && name == "clone_from" {
106+
} else if name == "clone_from" {
108107
debug!("make_shim({:?}: using default trait implementation", instance);
109108
return tcx.optimized_mir(def_id);
110109
} else {
111-
bug!("builtin shim {:?} not supported", instance)
110+
bug!("builtin clone shim {:?} not supported", instance)
112111
}
113112
}
114113
ty::InstanceDef::Intrinsic(_) => {
@@ -272,10 +271,10 @@ impl<'a, 'tcx> DropElaborator<'a, 'tcx> for DropShimElaborator<'a, 'tcx> {
272271
}
273272
}
274273

275-
/// Build a `Clone::clone` shim for `recvr_ty`. Here, `def_id` is `Clone::clone`.
274+
/// Build a `Clone::clone` shim for `self_ty`. Here, `def_id` is `Clone::clone`.
276275
fn build_clone_shim<'a, 'tcx>(tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
277276
def_id: DefId,
278-
rcvr_ty: ty::Ty<'tcx>)
277+
self_ty: ty::Ty<'tcx>)
279278
-> Mir<'tcx>
280279
{
281280
let sig = tcx.fn_sig(def_id);
@@ -348,7 +347,7 @@ fn build_clone_shim<'a, 'tcx>(tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
348347
loc
349348
};
350349

351-
match rcvr_ty.sty {
350+
match self_ty.sty {
352351
ty::TyArray(ty, len) => {
353352
let mut returns = Vec::new();
354353
for i in 0..len {

src/librustc_trans/collector.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ fn visit_instance_use<'a, 'tcx>(scx: &SharedCrateContext<'a, 'tcx>,
700700
ty::InstanceDef::ClosureOnceShim { .. } |
701701
ty::InstanceDef::Item(..) |
702702
ty::InstanceDef::FnPtrShim(..) |
703-
ty::InstanceDef::BuiltinShim(..) => {
703+
ty::InstanceDef::CloneShim(..) => {
704704
output.push(create_fn_trans_item(instance));
705705
}
706706
}
@@ -718,7 +718,7 @@ fn should_trans_locally<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: &Instan
718718
ty::InstanceDef::FnPtrShim(..) |
719719
ty::InstanceDef::DropGlue(..) |
720720
ty::InstanceDef::Intrinsic(_) |
721-
ty::InstanceDef::BuiltinShim(..) => return true
721+
ty::InstanceDef::CloneShim(..) => return true
722722
};
723723
match tcx.hir.get_if_local(def_id) {
724724
Some(hir_map::NodeForeignItem(..)) => {

src/librustc_trans/monomorphize.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ fn resolve_associated_item<'a, 'tcx>(
143143
substs: rcvr_substs
144144
}
145145
}
146-
traits::VtableBuiltin(..) => {
146+
traits::VtableBuiltin(..) if Some(trait_id) == tcx.lang_items.clone_trait() => {
147147
Instance {
148-
def: ty::InstanceDef::BuiltinShim(def_id, trait_ref.self_ty()),
148+
def: ty::InstanceDef::CloneShim(def_id, trait_ref.self_ty()),
149149
substs: rcvr_substs
150150
}
151151
}

src/librustc_trans/partitioning.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ fn place_root_translation_items<'a, 'tcx, I>(scx: &SharedCrateContext<'a, 'tcx>,
362362
InstanceDef::Intrinsic(..) |
363363
InstanceDef::ClosureOnceShim { .. } |
364364
InstanceDef::DropGlue(..) |
365-
InstanceDef::BuiltinShim(..) => {
365+
InstanceDef::CloneShim(..) => {
366366
bug!("partitioning: Encountered unexpected
367367
root translation item: {:?}",
368368
trans_item)
@@ -605,7 +605,7 @@ fn characteristic_def_id_of_trans_item<'a, 'tcx>(scx: &SharedCrateContext<'a, 't
605605
ty::InstanceDef::Intrinsic(..) |
606606
ty::InstanceDef::DropGlue(..) |
607607
ty::InstanceDef::Virtual(..) |
608-
ty::InstanceDef::BuiltinShim(..) => return None
608+
ty::InstanceDef::CloneShim(..) => return None
609609
};
610610

611611
// If this is a method, we want to put it into the same module as

0 commit comments

Comments
 (0)