@@ -103,7 +103,7 @@ impl<'tcx> InferCtxt<'tcx> {
103
103
return Ok ( InferOk { value : ( ) , obligations : vec ! [ ] } ) ;
104
104
}
105
105
let ( a, b) = if a_is_expected { ( a, b) } else { ( b, a) } ;
106
- let process = |a : Ty < ' tcx > , b : Ty < ' tcx > | match * a. kind ( ) {
106
+ let process = |a : Ty < ' tcx > , b : Ty < ' tcx > , a_is_expected | match * a. kind ( ) {
107
107
ty:: Opaque ( def_id, substs) if def_id. is_local ( ) => {
108
108
let def_id = def_id. expect_local ( ) ;
109
109
let origin = match self . defining_use_anchor {
@@ -169,13 +169,14 @@ impl<'tcx> InferCtxt<'tcx> {
169
169
param_env,
170
170
b,
171
171
origin,
172
+ a_is_expected,
172
173
) )
173
174
}
174
175
_ => None ,
175
176
} ;
176
- if let Some ( res) = process ( a, b) {
177
+ if let Some ( res) = process ( a, b, true ) {
177
178
res
178
- } else if let Some ( res) = process ( b, a) {
179
+ } else if let Some ( res) = process ( b, a, false ) {
179
180
res
180
181
} else {
181
182
let ( a, b) = self . resolve_vars_if_possible ( ( a, b) ) ;
@@ -514,13 +515,14 @@ impl UseKind {
514
515
515
516
impl < ' tcx > InferCtxt < ' tcx > {
516
517
#[ instrument( skip( self ) , level = "debug" ) ]
517
- pub fn register_hidden_type (
518
+ fn register_hidden_type (
518
519
& self ,
519
520
opaque_type_key : OpaqueTypeKey < ' tcx > ,
520
521
cause : ObligationCause < ' tcx > ,
521
522
param_env : ty:: ParamEnv < ' tcx > ,
522
523
hidden_ty : Ty < ' tcx > ,
523
524
origin : hir:: OpaqueTyOrigin ,
525
+ a_is_expected : bool ,
524
526
) -> InferResult < ' tcx , ( ) > {
525
527
let tcx = self . tcx ;
526
528
let OpaqueTypeKey { def_id, substs } = opaque_type_key;
@@ -539,7 +541,8 @@ impl<'tcx> InferCtxt<'tcx> {
539
541
origin,
540
542
) ;
541
543
if let Some ( prev) = prev {
542
- obligations = self . at ( & cause, param_env) . eq ( prev, hidden_ty) ?. obligations ;
544
+ obligations =
545
+ self . at ( & cause, param_env) . eq_exp ( a_is_expected, prev, hidden_ty) ?. obligations ;
543
546
}
544
547
545
548
let item_bounds = tcx. bound_explicit_item_bounds ( def_id. to_def_id ( ) ) ;
0 commit comments