@@ -53,9 +53,12 @@ pub enum InstanceDef<'tcx> {
53
53
/// The DefId is the DefId of the Clone::clone function
54
54
CloneStructuralShim ( DefId , Ty < ' tcx > ) ,
55
55
///`<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
+ } ,
59
62
}
60
63
61
64
impl < ' a , ' tcx > Instance < ' tcx > {
@@ -80,7 +83,7 @@ impl<'tcx> InstanceDef<'tcx> {
80
83
InstanceDef :: DropGlue ( def_id, _) |
81
84
InstanceDef :: CloneCopyShim ( def_id) |
82
85
InstanceDef :: CloneStructuralShim ( def_id, _) |
83
- InstanceDef :: CloneNominalShim ( def_id, _ ) => def_id
86
+ InstanceDef :: CloneNominalShim { clone : def_id, .. } => def_id
84
87
}
85
88
}
86
89
@@ -146,11 +149,11 @@ impl<'tcx> fmt::Display for Instance<'tcx> {
146
149
InstanceDef :: DropGlue ( _, ty) => {
147
150
write ! ( f, " - shim({:?})" , ty)
148
151
}
149
- InstanceDef :: CloneCopyShim ( def) => {
152
+ InstanceDef :: CloneCopyShim ( def) |
153
+ InstanceDef :: CloneNominalShim { ty : def, ..} => {
150
154
write ! ( f, " - shim({:?})" , def)
151
155
}
152
- InstanceDef :: CloneStructuralShim ( _, ty) |
153
- InstanceDef :: CloneNominalShim ( _, ty) => {
156
+ InstanceDef :: CloneStructuralShim ( _, ty) => {
154
157
write ! ( f, " - shim({:?})" , ty)
155
158
}
156
159
}
@@ -308,6 +311,7 @@ fn resolve_associated_item<'a, 'tcx>(
308
311
}
309
312
traits:: VtableBuiltin ( ..) => {
310
313
if let Some ( _) = tcx. lang_items ( ) . clone_trait ( ) {
314
+ let mut substs = rcvr_substs;
311
315
let name = tcx. item_name ( def_id) ;
312
316
let def = if name == "clone" {
313
317
let self_ty = trait_ref. self_ty ( ) ;
@@ -317,15 +321,21 @@ fn resolve_associated_item<'a, 'tcx>(
317
321
}
318
322
ty:: TyArray ( ..) => ty:: InstanceDef :: CloneStructuralShim ( def_id, self_ty) ,
319
323
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
+ }
321
331
_ => unreachable ! ( "Type {:?} does not have clone shims" , self_ty)
322
332
}
323
333
} else {
324
334
ty:: InstanceDef :: Item ( def_id)
325
335
} ;
326
336
Some ( Instance {
327
337
def,
328
- substs : rcvr_substs
338
+ substs
329
339
} )
330
340
} else {
331
341
None
0 commit comments