Skip to content

Commit 8bdb10d

Browse files
committed
Use InstanceDef::Item for clone_from shims
1 parent 29c8276 commit 8bdb10d

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/librustc/ty/instance.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,14 @@ fn resolve_associated_item<'a, 'tcx>(
289289
}
290290
traits::VtableBuiltin(..) => {
291291
if let Some(_) = tcx.lang_items().clone_trait() {
292+
let name = tcx.item_name(def_id);
293+
let def = if name == "clone" {
294+
ty::InstanceDef::CloneShim(def_id, trait_ref.self_ty())
295+
} else {
296+
ty::InstanceDef::Item(def_id)
297+
};
292298
Some(Instance {
293-
def: ty::InstanceDef::CloneShim(def_id, trait_ref.self_ty()),
299+
def,
294300
substs: rcvr_substs
295301
})
296302
} else {

src/librustc_mir/shim.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,7 @@ fn make_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
100100
build_drop_shim(tcx, def_id, ty)
101101
}
102102
ty::InstanceDef::CloneShim(def_id, ty) => {
103-
let name = tcx.item_name(def_id);
104-
if name == "clone" {
105-
build_clone_shim(tcx, def_id, ty)
106-
} else if name == "clone_from" {
107-
debug!("make_shim({:?}: using default trait implementation", instance);
108-
return tcx.optimized_mir(def_id);
109-
} else {
110-
bug!("builtin clone shim {:?} not supported", instance)
111-
}
103+
build_clone_shim(tcx, def_id, ty)
112104
}
113105
ty::InstanceDef::Intrinsic(_) => {
114106
bug!("creating shims from intrinsics ({:?}) is unsupported", instance)

0 commit comments

Comments
 (0)