diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2018-01-30 14:47:25 +0530 |
|---|---|---|
| committer | Manish Goregaokar <manishsmail@gmail.com> | 2018-02-01 08:05:37 +0530 |
| commit | f97629160fe944cd9185ba180221d19f66126e2f (patch) | |
| tree | 24f53db3dc478d971a1065f54f895b09d10fd970 | |
| parent | ef4f4864f166e4f148d5b903bc928a1bcb63ead5 (diff) | |
| download | rust-f97629160fe944cd9185ba180221d19f66126e2f.tar.gz rust-f97629160fe944cd9185ba180221d19f66126e2f.zip | |
Correctly subst the fn_sig so that we get the correct types
Otherwise we get random TySelfs there, which means operations on RETURN_PLACE end up breaking down badly.
| -rw-r--r-- | src/librustc_mir/shim.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/librustc_mir/shim.rs b/src/librustc_mir/shim.rs index 36dd359b20c..54aed69a315 100644 --- a/src/librustc_mir/shim.rs +++ b/src/librustc_mir/shim.rs @@ -294,7 +294,7 @@ fn build_clone_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, { debug!("build_clone_shim(def_id={:?})", def_id); - let mut builder = CloneShimBuilder::new(tcx, def_id); + let mut builder = CloneShimBuilder::new(tcx, def_id, self_ty); let is_copy = !self_ty.moves_by_default(tcx, tcx.param_env(def_id), builder.span); match self_ty.sty { @@ -327,8 +327,14 @@ struct CloneShimBuilder<'a, 'tcx: 'a> { } impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> { - fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Self { - let sig = tcx.fn_sig(def_id); + fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>, + def_id: DefId, + self_ty: Ty<'tcx>) -> Self { + // we must subst the self_ty because it's + // otherwise going to be TySelf and we can't index + // or access fields of a Place of type TySelf. + let substs = tcx.mk_substs_trait(self_ty, &[]); + let sig = tcx.fn_sig(def_id).subst(tcx, substs); let sig = tcx.erase_late_bound_regions(&sig); let span = tcx.def_span(def_id); |
