Don't create an extra infcx in report_closure_arg_mismatch

This commit is contained in:
Michael Goulet 2022-08-13 00:56:29 +00:00
parent 7480389611
commit c655d4b233

View File

@ -20,7 +20,6 @@ use rustc_hir::def_id::DefId;
use rustc_hir::intravisit::Visitor;
use rustc_hir::lang_items::LangItem;
use rustc_hir::{AsyncGeneratorKind, GeneratorKind, Node};
use rustc_infer::infer::TyCtxtInferExt;
use rustc_middle::hir::map;
use rustc_middle::ty::{
self, suggest_arbitrary_trait_bound, suggest_constraining_type_param, AdtKind, DefIdTree,
@ -1633,8 +1632,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
let expected = build_fn_sig_ty(self.tcx, expected);
let found = build_fn_sig_ty(self.tcx, found);
let (expected_str, found_str) =
self.tcx.infer_ctxt().enter(|infcx| infcx.cmp(expected, found));
let (expected_str, found_str) = self.cmp(expected, found);
let signature_kind = format!("{argument_kind} signature");
err.note_expected_found(&signature_kind, expected_str, &signature_kind, found_str);