From: Oli Scherer Date: Fri, 7 Oct 2022 09:33:22 +0000 (+0000) Subject: Use the general type API instead of directly accessing register_hidden_type X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=196a429a671209531422a3895140fc16745ac4ea;p=rust.git Use the general type API instead of directly accessing register_hidden_type --- diff --git a/compiler/rustc_borrowck/src/region_infer/opaque_types.rs b/compiler/rustc_borrowck/src/region_infer/opaque_types.rs index 11a57ef2621..465f353aaa3 100644 --- a/compiler/rustc_borrowck/src/region_infer/opaque_types.rs +++ b/compiler/rustc_borrowck/src/region_infer/opaque_types.rs @@ -263,13 +263,11 @@ fn infer_opaque_definition_from_instantiation( // Require that the hidden type actually fulfills all the bounds of the opaque type, even without // the bounds that the function supplies. - match infcx.register_hidden_type( - OpaqueTypeKey { def_id, substs: id_substs }, - ObligationCause::misc(instantiated_ty.span, body_id), - param_env, - definition_ty, - origin, - ) { + let opaque_ty = self.tcx.mk_opaque(def_id.to_def_id(), id_substs); + match infcx + .at(&ObligationCause::misc(instantiated_ty.span, body_id), param_env) + .eq(opaque_ty, definition_ty) + { Ok(infer_ok) => { for obligation in infer_ok.obligations { fulfillment_cx.register_predicate_obligation(&infcx, obligation); @@ -280,7 +278,7 @@ fn infer_opaque_definition_from_instantiation( .err_ctxt() .report_mismatched_types( &ObligationCause::misc(instantiated_ty.span, body_id), - self.tcx.mk_opaque(def_id.to_def_id(), id_substs), + opaque_ty, definition_ty, err, )