]> git.lizzy.rs Git - rust.git/commitdiff
add method_substs to CallKind
authorKyle Matsuda <kyle.yoshio.matsuda@gmail.com>
Fri, 20 Jan 2023 22:17:01 +0000 (15:17 -0700)
committerKyle Matsuda <kyle.yoshio.matsuda@gmail.com>
Fri, 27 Jan 2023 03:28:31 +0000 (20:28 -0700)
compiler/rustc_borrowck/src/diagnostics/mod.rs
compiler/rustc_const_eval/src/util/call_kind.rs

index 18d2caa149bfbabc1b889c1f7fb0aad390b3b4ba..1011794d7b3b2995671c2946070a4f59df385fcb 100644 (file)
@@ -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 {
@@ -1136,9 +1136,7 @@ fn explain_captures(
                             && let self_ty = infcx.replace_bound_vars_with_fresh_vars(
                                 fn_call_span,
                                 LateBoundRegionConversionTime::FnCall,
-                                // FIXME: should use `subst` with the method substs.
-                                // Probably need to add `method_substs` to `CallKind`
-                                tcx.fn_sig(method_did).skip_binder().input(0),
+                                tcx.fn_sig(method_did).subst(tcx, method_substs).input(0),
                             )
                             && infcx.can_eq(self.param_env, ty, self_ty).is_ok()
                         {
index 38d9b044981cd723687c8962d06345fc226aa39a..995363c0edd92e3e4849b045328b1650ec1225d1 100644 (file)
@@ -40,6 +40,7 @@ pub enum CallKind<'tcx> {
         self_arg: Option<Ident>,
         desugaring: Option<(CallDesugaringKind, Ty<'tcx>)>,
         method_did: DefId,
+        method_substs: SubstsRef<'tcx>,
     },
     /// A call to `Fn(..)::call(..)`, desugared from `my_closure(a, b, c)`
     FnCall { fn_trait_id: DefId, self_ty: Ty<'tcx> },
@@ -131,6 +132,6 @@ pub fn call_kind<'tcx>(
         } else {
             None
         };
-        CallKind::Normal { self_arg, desugaring, method_did }
+        CallKind::Normal { self_arg, desugaring, method_did, method_substs }
     })
 }