]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_hir_typeck/src/closure.rs
Rollup merge of #105237 - JohnTitor:issue-79450, r=oli-obk
[rust.git] / compiler / rustc_hir_typeck / src / closure.rs
index e584d413c4190688fe8559af7bd28987f6e478ba..429cb60ba2b6161692c9153041a068ce638e69d5 100644 (file)
@@ -79,16 +79,15 @@ fn check_closure(
 
         debug!(?bound_sig, ?liberated_sig);
 
+        let mut fcx = FnCtxt::new(self, self.param_env.without_const(), body.value.hir_id);
         let generator_types = check_fn(
-            self,
-            self.param_env.without_const(),
+            &mut fcx,
             liberated_sig,
             closure.fn_decl,
             expr_def_id,
             body,
             closure.movability,
-        )
-        .1;
+        );
 
         let parent_substs = InternalSubsts::identity_for_item(
             self.tcx,
@@ -214,7 +213,7 @@ fn deduce_signature_from_predicates(
             if expected_sig.is_none()
                 && let ty::PredicateKind::Clause(ty::Clause::Projection(proj_predicate)) = bound_predicate.skip_binder()
             {
-                expected_sig = self.normalize_associated_types_in(
+                expected_sig = self.normalize(
                     obligation.cause.span,
                     self.deduce_sig_from_projection(
                     Some(obligation.cause.span),
@@ -457,10 +456,11 @@ fn sig_of_closure_with_mismatched_number_of_arguments(
             .iter()
             .map(|ty| ArgKind::from_expected_ty(*ty, None))
             .collect();
-        let (closure_span, found_args) = match self.get_fn_like_arguments(expr_map_node) {
-            Some((sp, args)) => (Some(sp), args),
-            None => (None, Vec::new()),
-        };
+        let (closure_span, closure_arg_span, found_args) =
+            match self.get_fn_like_arguments(expr_map_node) {
+                Some((sp, arg_sp, args)) => (Some(sp), arg_sp, args),
+                None => (None, None, Vec::new()),
+            };
         let expected_span =
             expected_sig.cause_span.unwrap_or_else(|| self.tcx.def_span(expr_def_id));
         self.report_arg_count_mismatch(
@@ -469,6 +469,7 @@ fn sig_of_closure_with_mismatched_number_of_arguments(
             expected_args,
             found_args,
             true,
+            closure_arg_span,
         )
         .emit();
 
@@ -623,7 +624,7 @@ fn supplied_sig_of_closure(
         );
         // Astconv can't normalize inputs or outputs with escaping bound vars,
         // so normalize them here, after we've wrapped them in a binder.
-        let result = self.normalize_associated_types_in(self.tcx.hir().span(hir_id), result);
+        let result = self.normalize(self.tcx.hir().span(hir_id), result);
 
         let c_result = self.inh.infcx.canonicalize_response(result);
         self.typeck_results.borrow_mut().user_provided_sigs.insert(expr_def_id, c_result);
@@ -797,12 +798,7 @@ fn closure_sigs(
     ) -> ClosureSignatures<'tcx> {
         let liberated_sig =
             self.tcx().liberate_late_bound_regions(expr_def_id.to_def_id(), bound_sig);
-        let liberated_sig = self.inh.normalize_associated_types_in(
-            body.value.span,
-            self.tcx.hir().local_def_id_to_hir_id(expr_def_id),
-            self.param_env,
-            liberated_sig,
-        );
+        let liberated_sig = self.normalize(body.value.span, liberated_sig);
         ClosureSignatures { bound_sig, liberated_sig }
     }
 }