@@ -143,11 +143,11 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
143
143
fn unify ( & self , a : Ty < ' tcx > , b : Ty < ' tcx > ) -> InferResult < ' tcx , Ty < ' tcx > > {
144
144
debug ! ( "unify(a: {:?}, b: {:?}, use_lub: {})" , a, b, self . use_lub) ;
145
145
self . commit_if_ok ( |_| {
146
+ let at = self . at ( & self . cause , self . fcx . param_env ) . define_opaque_types ( true ) ;
146
147
if self . use_lub {
147
- self . at ( & self . cause , self . fcx . param_env ) . lub ( b, a)
148
+ at . lub ( b, a)
148
149
} else {
149
- self . at ( & self . cause , self . fcx . param_env )
150
- . sup ( b, a)
150
+ at. sup ( b, a)
151
151
. map ( |InferOk { value : ( ) , obligations } | InferOk { value : a, obligations } )
152
152
}
153
153
} )
@@ -174,7 +174,9 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
174
174
// Best-effort try to unify these types -- we're already on the error path,
175
175
// so this will have the side-effect of making sure we have no ambiguities
176
176
// 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
+ } ) ;
178
180
return success ( vec ! [ ] , self . fcx . tcx . ty_error ( ) , vec ! [ ] ) ;
179
181
}
180
182
@@ -1484,6 +1486,8 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
1484
1486
// Another example is `break` with no argument expression.
1485
1487
assert ! ( expression_ty. is_unit( ) , "if let hack without unit type" ) ;
1486
1488
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 )
1487
1491
. eq_exp ( label_expression_as_expected, expression_ty, self . merged_ty ( ) )
1488
1492
. map ( |infer_ok| {
1489
1493
fcx. register_infer_ok_obligations ( infer_ok) ;
0 commit comments