@@ -53,9 +53,12 @@ pub enum InstanceDef<'tcx> {
5353 /// The DefId is the DefId of the Clone::clone function
5454 CloneStructuralShim ( DefId , Ty < ' tcx > ) ,
5555 ///`<T as Clone>::clone` shim for closures
56- ///
57- /// The DefId is the DefId of the Clone::clone function
58- CloneNominalShim ( DefId , Ty < ' tcx > ) ,
56+ CloneNominalShim {
57+ /// The DefId of the Clone::clone trait method def
58+ clone : DefId ,
59+ /// The DefId of the self type
60+ ty : DefId
61+ } ,
5962}
6063
6164impl < ' a , ' tcx > Instance < ' tcx > {
@@ -80,7 +83,7 @@ impl<'tcx> InstanceDef<'tcx> {
8083 InstanceDef :: DropGlue ( def_id, _) |
8184 InstanceDef :: CloneCopyShim ( def_id) |
8285 InstanceDef :: CloneStructuralShim ( def_id, _) |
83- InstanceDef :: CloneNominalShim ( def_id, _ ) => def_id
86+ InstanceDef :: CloneNominalShim { clone : def_id, .. } => def_id
8487 }
8588 }
8689
@@ -146,11 +149,11 @@ impl<'tcx> fmt::Display for Instance<'tcx> {
146149 InstanceDef :: DropGlue ( _, ty) => {
147150 write ! ( f, " - shim({:?})" , ty)
148151 }
149- InstanceDef :: CloneCopyShim ( def) => {
152+ InstanceDef :: CloneCopyShim ( def) |
153+ InstanceDef :: CloneNominalShim { ty : def, ..} => {
150154 write ! ( f, " - shim({:?})" , def)
151155 }
152- InstanceDef :: CloneStructuralShim ( _, ty) |
153- InstanceDef :: CloneNominalShim ( _, ty) => {
156+ InstanceDef :: CloneStructuralShim ( _, ty) => {
154157 write ! ( f, " - shim({:?})" , ty)
155158 }
156159 }
@@ -308,6 +311,7 @@ fn resolve_associated_item<'a, 'tcx>(
308311 }
309312 traits:: VtableBuiltin ( ..) => {
310313 if let Some ( _) = tcx. lang_items ( ) . clone_trait ( ) {
314+ let mut substs = rcvr_substs;
311315 let name = tcx. item_name ( def_id) ;
312316 let def = if name == "clone" {
313317 let self_ty = trait_ref. self_ty ( ) ;
@@ -317,15 +321,21 @@ fn resolve_associated_item<'a, 'tcx>(
317321 }
318322 ty:: TyArray ( ..) => ty:: InstanceDef :: CloneStructuralShim ( def_id, self_ty) ,
319323 ty:: TyTuple ( ..) => ty:: InstanceDef :: CloneStructuralShim ( def_id, self_ty) ,
320- ty:: TyClosure ( ..) => ty:: InstanceDef :: CloneNominalShim ( def_id, self_ty) ,
324+ ty:: TyClosure ( ty_did, closure_substs) => {
325+ substs = closure_substs. substs ;
326+ ty:: InstanceDef :: CloneNominalShim {
327+ clone : def_id,
328+ ty : ty_did
329+ }
330+ }
321331 _ => unreachable ! ( "Type {:?} does not have clone shims" , self_ty)
322332 }
323333 } else {
324334 ty:: InstanceDef :: Item ( def_id)
325335 } ;
326336 Some ( Instance {
327337 def,
328- substs : rcvr_substs
338+ substs
329339 } )
330340 } else {
331341 None
0 commit comments