@@ -103,7 +103,7 @@ impl<'tcx> InferCtxt<'tcx> {
103103 return Ok ( InferOk { value : ( ) , obligations : vec ! [ ] } ) ;
104104 }
105105 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 ( ) {
107107 ty:: Opaque ( def_id, substs) if def_id. is_local ( ) => {
108108 let def_id = def_id. expect_local ( ) ;
109109 let origin = match self . defining_use_anchor {
@@ -169,13 +169,14 @@ impl<'tcx> InferCtxt<'tcx> {
169169 param_env,
170170 b,
171171 origin,
172+ a_is_expected,
172173 ) )
173174 }
174175 _ => None ,
175176 } ;
176- if let Some ( res) = process ( a, b) {
177+ if let Some ( res) = process ( a, b, true ) {
177178 res
178- } else if let Some ( res) = process ( b, a) {
179+ } else if let Some ( res) = process ( b, a, false ) {
179180 res
180181 } else {
181182 let ( a, b) = self . resolve_vars_if_possible ( ( a, b) ) ;
@@ -514,13 +515,14 @@ impl UseKind {
514515
515516impl < ' tcx > InferCtxt < ' tcx > {
516517 #[ instrument( skip( self ) , level = "debug" ) ]
517- pub fn register_hidden_type (
518+ fn register_hidden_type (
518519 & self ,
519520 opaque_type_key : OpaqueTypeKey < ' tcx > ,
520521 cause : ObligationCause < ' tcx > ,
521522 param_env : ty:: ParamEnv < ' tcx > ,
522523 hidden_ty : Ty < ' tcx > ,
523524 origin : hir:: OpaqueTyOrigin ,
525+ a_is_expected : bool ,
524526 ) -> InferResult < ' tcx , ( ) > {
525527 let tcx = self . tcx ;
526528 let OpaqueTypeKey { def_id, substs } = opaque_type_key;
@@ -539,7 +541,8 @@ impl<'tcx> InferCtxt<'tcx> {
539541 origin,
540542 ) ;
541543 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 ;
543546 }
544547
545548 let item_bounds = tcx. bound_explicit_item_bounds ( def_id. to_def_id ( ) ) ;
0 commit comments