@@ -69,7 +69,7 @@ use rustc_middle::ty::error::TypeError;
6969use rustc_middle:: ty:: {
7070 self ,
7171 subst:: { GenericArgKind , Subst , SubstsRef } ,
72- Region , Ty , TyCtxt , TypeFoldable ,
72+ Binder , Region , Ty , TyCtxt , TypeFoldable ,
7373} ;
7474use rustc_span:: { sym, BytePos , DesugaringKind , MultiSpan , Pos , Span } ;
7575use rustc_target:: spec:: abi;
@@ -1765,7 +1765,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
17651765 self . note_error_origin ( diag, cause, exp_found, terr) ;
17661766 }
17671767
1768- pub fn get_impl_future_output_ty ( & self , ty : Ty < ' tcx > ) -> Option < Ty < ' tcx > > {
1768+ pub fn get_impl_future_output_ty ( & self , ty : Ty < ' tcx > ) -> Option < Binder < ' tcx , Ty < ' tcx > > > {
17691769 if let ty:: Opaque ( def_id, substs) = ty. kind ( ) {
17701770 let future_trait = self . tcx . require_lang_item ( LangItem :: Future , None ) ;
17711771 // Future::Output
@@ -1775,13 +1775,20 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
17751775
17761776 for ( predicate, _) in bounds {
17771777 let predicate = predicate. subst ( self . tcx , substs) ;
1778- if let ty:: PredicateKind :: Projection ( projection_predicate) =
1779- predicate. kind ( ) . skip_binder ( )
1780- {
1781- if projection_predicate. projection_ty . item_def_id == item_def_id {
1782- // We don't account for multiple `Future::Output = Ty` contraints.
1783- return projection_predicate. term . ty ( ) ;
1784- }
1778+ let output = predicate
1779+ . kind ( )
1780+ . map_bound ( |kind| match kind {
1781+ ty:: PredicateKind :: Projection ( projection_predicate)
1782+ if projection_predicate. projection_ty . item_def_id == item_def_id =>
1783+ {
1784+ projection_predicate. term . ty ( )
1785+ }
1786+ _ => None ,
1787+ } )
1788+ . transpose ( ) ;
1789+ if output. is_some ( ) {
1790+ // We don't account for multiple `Future::Output = Ty` contraints.
1791+ return output;
17851792 }
17861793 }
17871794 }
@@ -1823,8 +1830,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
18231830 }
18241831
18251832 match (
1826- self . get_impl_future_output_ty ( exp_found. expected ) ,
1827- self . get_impl_future_output_ty ( exp_found. found ) ,
1833+ self . get_impl_future_output_ty ( exp_found. expected ) . map ( Binder :: skip_binder ) ,
1834+ self . get_impl_future_output_ty ( exp_found. found ) . map ( Binder :: skip_binder ) ,
18281835 ) {
18291836 ( Some ( exp) , Some ( found) ) if same_type_modulo_infer ( exp, found) => match cause. code ( ) {
18301837 ObligationCauseCode :: IfExpression ( box IfExpressionCause { then, .. } ) => {
0 commit comments