]> git.lizzy.rs Git - rust.git/commitdiff
Use the general type API instead of directly accessing register_hidden_type
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>
Fri, 7 Oct 2022 09:33:22 +0000 (09:33 +0000)
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>
Tue, 25 Oct 2022 13:27:06 +0000 (13:27 +0000)
compiler/rustc_borrowck/src/region_infer/opaque_types.rs

index 11a57ef26217476e2e712b0f1b58adaadcee486c..465f353aaa37f426bdc770213eadb5ea807abbba 100644 (file)
@@ -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,
                     )