@@ -294,7 +294,7 @@ fn build_clone_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
294
294
{
295
295
debug ! ( "build_clone_shim(def_id={:?})" , def_id) ;
296
296
297
- let mut builder = CloneShimBuilder :: new ( tcx, def_id) ;
297
+ let mut builder = CloneShimBuilder :: new ( tcx, def_id, self_ty ) ;
298
298
let is_copy = !self_ty. moves_by_default ( tcx, tcx. param_env ( def_id) , builder. span ) ;
299
299
300
300
match self_ty. sty {
@@ -327,8 +327,14 @@ struct CloneShimBuilder<'a, 'tcx: 'a> {
327
327
}
328
328
329
329
impl < ' a , ' tcx > CloneShimBuilder < ' a , ' tcx > {
330
- fn new ( tcx : TyCtxt < ' a , ' tcx , ' tcx > , def_id : DefId ) -> Self {
331
- let sig = tcx. fn_sig ( def_id) ;
330
+ fn new ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
331
+ def_id : DefId ,
332
+ self_ty : Ty < ' tcx > ) -> Self {
333
+ // we must subst the self_ty because it's
334
+ // otherwise going to be TySelf and we can't index
335
+ // or access fields of a Place of type TySelf.
336
+ let substs = tcx. mk_substs_trait ( self_ty, & [ ] ) ;
337
+ let sig = tcx. fn_sig ( def_id) . subst ( tcx, substs) ;
332
338
let sig = tcx. erase_late_bound_regions ( & sig) ;
333
339
let span = tcx. def_span ( def_id) ;
334
340
0 commit comments