@@ -45,7 +45,7 @@ use rustc_hir::intravisit::{self, Visitor};
45
45
use rustc_hir:: Expr ;
46
46
use rustc_hir_analysis:: astconv:: AstConv ;
47
47
use rustc_infer:: infer:: type_variable:: { TypeVariableOrigin , TypeVariableOriginKind } ;
48
- use rustc_infer:: infer:: { Coercion , InferOk , InferResult } ;
48
+ use rustc_infer:: infer:: { Coercion , DefineOpaqueTypes , InferOk , InferResult } ;
49
49
use rustc_infer:: traits:: Obligation ;
50
50
use rustc_middle:: lint:: in_external_macro;
51
51
use rustc_middle:: ty:: adjustment:: {
@@ -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
+ let at = self . at ( & self . cause , self . fcx . param_env ) ;
147
147
if self . use_lub {
148
- at. lub ( b, a)
148
+ at. lub ( DefineOpaqueTypes :: Yes , b, a)
149
149
} else {
150
- at. sup ( b, a)
150
+ at. sup ( DefineOpaqueTypes :: Yes , b, a)
151
151
. map ( |InferOk { value : ( ) , obligations } | InferOk { value : a, obligations } )
152
152
}
153
153
} )
@@ -175,7 +175,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
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
177
let _ = self . commit_if_ok ( |_| {
178
- self . at ( & self . cause , self . param_env ) . define_opaque_types ( true ) . eq ( a, b)
178
+ self . at ( & self . cause , self . param_env ) . eq ( DefineOpaqueTypes :: Yes , a, b)
179
179
} ) ;
180
180
return success ( vec ! [ ] , self . fcx . tcx . ty_error ( guar) , vec ! [ ] ) ;
181
181
}
@@ -1101,9 +1101,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1101
1101
( ty:: FnDef ( ..) , ty:: FnDef ( ..) ) => {
1102
1102
// Don't reify if the function types have a LUB, i.e., they
1103
1103
// are the same function and their parameters have a LUB.
1104
- match self
1105
- . commit_if_ok ( |_| self . at ( cause, self . param_env ) . lub ( prev_ty, new_ty) )
1106
- {
1104
+ match self . commit_if_ok ( |_| {
1105
+ self . at ( cause, self . param_env ) . lub (
1106
+ DefineOpaqueTypes :: No ,
1107
+ prev_ty,
1108
+ new_ty,
1109
+ )
1110
+ } ) {
1107
1111
// We have a LUB of prev_ty and new_ty, just return it.
1108
1112
Ok ( ok) => return Ok ( self . register_infer_ok_obligations ( ok) ) ,
1109
1113
Err ( _) => {
@@ -1153,7 +1157,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1153
1157
let sig = self
1154
1158
. at ( cause, self . param_env )
1155
1159
. trace ( prev_ty, new_ty)
1156
- . lub ( a_sig, b_sig)
1160
+ . lub ( DefineOpaqueTypes :: No , a_sig, b_sig)
1157
1161
. map ( |ok| self . register_infer_ok_obligations ( ok) ) ?;
1158
1162
1159
1163
// Reify both sides and return the reified fn pointer type.
@@ -1237,7 +1241,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1237
1241
) ;
1238
1242
1239
1243
return self
1240
- . commit_if_ok ( |_| self . at ( cause, self . param_env ) . lub ( prev_ty, new_ty) )
1244
+ . commit_if_ok ( |_| {
1245
+ self . at ( cause, self . param_env ) . lub ( DefineOpaqueTypes :: No , prev_ty, new_ty)
1246
+ } )
1241
1247
. map ( |ok| self . register_infer_ok_obligations ( ok) ) ;
1242
1248
}
1243
1249
}
@@ -1248,8 +1254,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1248
1254
if let Some ( e) = first_error {
1249
1255
Err ( e)
1250
1256
} else {
1251
- self . commit_if_ok ( |_| self . at ( cause, self . param_env ) . lub ( prev_ty, new_ty) )
1252
- . map ( |ok| self . register_infer_ok_obligations ( ok) )
1257
+ self . commit_if_ok ( |_| {
1258
+ self . at ( cause, self . param_env ) . lub ( DefineOpaqueTypes :: No , prev_ty, new_ty)
1259
+ } )
1260
+ . map ( |ok| self . register_infer_ok_obligations ( ok) )
1253
1261
}
1254
1262
}
1255
1263
Ok ( ok) => {
@@ -1487,8 +1495,12 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
1487
1495
assert ! ( expression_ty. is_unit( ) , "if let hack without unit type" ) ;
1488
1496
fcx. at ( cause, fcx. param_env )
1489
1497
// needed for tests/ui/type-alias-impl-trait/issue-65679-inst-opaque-ty-from-val-twice.rs
1490
- . define_opaque_types ( true )
1491
- . eq_exp ( label_expression_as_expected, expression_ty, self . merged_ty ( ) )
1498
+ . eq_exp (
1499
+ DefineOpaqueTypes :: Yes ,
1500
+ label_expression_as_expected,
1501
+ expression_ty,
1502
+ self . merged_ty ( ) ,
1503
+ )
1492
1504
. map ( |infer_ok| {
1493
1505
fcx. register_infer_ok_obligations ( infer_ok) ;
1494
1506
expression_ty
0 commit comments