X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_borrowck%2Fsrc%2Fdiagnostics%2Fmod.rs;h=8c579bac7e8eb471c8dc8690eb7f7c3a7c62c5d1;hb=a29efccb1eff324c63454677688b5d7e08b5f40f;hp=1b40b7143cbb6b671ba2faec06326c362a669de8;hpb=002eccc7527c07a0aa89d58d5ef3c981f667b3f4;p=rust.git diff --git a/compiler/rustc_borrowck/src/diagnostics/mod.rs b/compiler/rustc_borrowck/src/diagnostics/mod.rs index 1b40b7143cb..8c579bac7e8 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mod.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mod.rs @@ -1064,7 +1064,7 @@ fn explain_captures( ); } } - CallKind::Normal { self_arg, desugaring, method_did } => { + CallKind::Normal { self_arg, desugaring, method_did, method_substs } => { let self_arg = self_arg.unwrap(); let tcx = self.infcx.tcx; if let Some((CallDesugaringKind::ForLoopIntoIter, _)) = desugaring { @@ -1128,15 +1128,19 @@ fn explain_captures( "{place_name} {partially_str}moved due to this method call{loop_message}", ), ); + let infcx = tcx.infer_ctxt().build(); + // Erase and shadow everything that could be passed to the new infcx. let ty = tcx.erase_regions(moved_place.ty(self.body, tcx).ty); + let method_substs = tcx.erase_regions(method_substs); + if let ty::Adt(def, substs) = ty.kind() && Some(def.did()) == tcx.lang_items().pin_type() && let ty::Ref(_, _, hir::Mutability::Mut) = substs.type_at(0).kind() && let self_ty = infcx.replace_bound_vars_with_fresh_vars( fn_call_span, LateBoundRegionConversionTime::FnCall, - tcx.fn_sig(method_did).input(0), + tcx.fn_sig(method_did).subst(tcx, method_substs).input(0), ) && infcx.can_eq(self.param_env, ty, self_ty).is_ok() {