Skip to content

Commit

Permalink
Stop using is_copy_modulo_regions when building clone shim
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Feb 7, 2024
1 parent eb7a0f8 commit 24d806c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
5 changes: 1 addition & 4 deletions compiler/rustc_mir_transform/src/shim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,16 +447,13 @@ fn build_thread_local_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: ty::InstanceDef<'t
fn build_clone_shim<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, self_ty: Ty<'tcx>) -> Body<'tcx> {
debug!("build_clone_shim(def_id={:?})", def_id);

let param_env = tcx.param_env_reveal_all_normalized(def_id);

let mut builder = CloneShimBuilder::new(tcx, def_id, self_ty);
let is_copy = self_ty.is_copy_modulo_regions(tcx, param_env);

let dest = Place::return_place();
let src = tcx.mk_place_deref(Place::from(Local::new(1 + 0)));

match self_ty.kind() {
_ if is_copy => builder.copy_shim(),
ty::FnDef(..) | ty::FnPtr(_) => builder.copy_shim(),
ty::Closure(_, args) => builder.tuple_like_shim(dest, src, args.as_closure().upvar_tys()),
ty::Tuple(..) => builder.tuple_like_shim(dest, src, self_ty.tuple_fields()),
ty::Coroutine(coroutine_def_id, args) => {
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_ty_utils/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,8 @@ fn resolve_associated_item<'tcx>(
let name = tcx.item_name(trait_item_id);
if name == sym::clone {
let self_ty = trait_ref.self_ty();

let is_copy = self_ty.is_copy_modulo_regions(tcx, param_env);
match self_ty.kind() {
_ if is_copy => (),
ty::FnDef(..) | ty::FnPtr(_) => (),
ty::Coroutine(..)
| ty::CoroutineWitness(..)
| ty::Closure(..)
Expand Down

0 comments on commit 24d806c

Please sign in to comment.