@@ -143,11 +143,11 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
143143    fn  unify ( & self ,  a :  Ty < ' tcx > ,  b :  Ty < ' tcx > )  -> InferResult < ' tcx ,  Ty < ' tcx > >  { 
144144        debug ! ( "unify(a: {:?}, b: {:?}, use_lub: {})" ,  a,  b,  self . use_lub) ; 
145145        self . commit_if_ok ( |_| { 
146+             let  at = self . at ( & self . cause ,  self . fcx . param_env ) . define_opaque_types ( true ) ; 
146147            if  self . use_lub  { 
147-                 self . at ( & self . cause ,   self . fcx . param_env ) . lub ( b,  a) 
148+                 at . lub ( b,  a) 
148149            }  else  { 
149-                 self . at ( & self . cause ,  self . fcx . param_env ) 
150-                     . sup ( b,  a) 
150+                 at. sup ( b,  a) 
151151                    . map ( |InferOk  {  value :  ( ) ,  obligations } | InferOk  {  value :  a,  obligations } ) 
152152            } 
153153        } ) 
@@ -174,7 +174,9 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
174174            // Best-effort try to unify these types -- we're already on the error path, 
175175            // so this will have the side-effect of making sure we have no ambiguities 
176176            // due to `[type error]` and `_` not coercing together. 
177-             let  _ = self . commit_if_ok ( |_| self . at ( & self . cause ,  self . param_env ) . eq ( a,  b) ) ; 
177+             let  _ = self . commit_if_ok ( |_| { 
178+                 self . at ( & self . cause ,  self . param_env ) . define_opaque_types ( true ) . eq ( a,  b) 
179+             } ) ; 
178180            return  success ( vec ! [ ] ,  self . fcx . tcx . ty_error ( ) ,  vec ! [ ] ) ; 
179181        } 
180182
@@ -1484,6 +1486,8 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
14841486            // Another example is `break` with no argument expression. 
14851487            assert ! ( expression_ty. is_unit( ) ,  "if let hack without unit type" ) ; 
14861488            fcx. at ( cause,  fcx. param_env ) 
1489+                 // needed for tests/ui/type-alias-impl-trait/issue-65679-inst-opaque-ty-from-val-twice.rs 
1490+                 . define_opaque_types ( true ) 
14871491                . eq_exp ( label_expression_as_expected,  expression_ty,  self . merged_ty ( ) ) 
14881492                . map ( |infer_ok| { 
14891493                    fcx. register_infer_ok_obligations ( infer_ok) ; 
0 commit comments