@@ -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;
@@ -1774,7 +1774,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
17741774 self . note_error_origin ( diag, cause, exp_found, terr) ;
17751775 }
17761776
1777- pub fn get_impl_future_output_ty ( & self , ty : Ty < ' tcx > ) -> Option < Ty < ' tcx > > {
1777+ pub fn get_impl_future_output_ty ( & self , ty : Ty < ' tcx > ) -> Option < Binder < ' tcx , Ty < ' tcx > > > {
17781778 if let ty:: Opaque ( def_id, substs) = ty. kind ( ) {
17791779 let future_trait = self . tcx . require_lang_item ( LangItem :: Future , None ) ;
17801780 // Future::Output
@@ -1784,13 +1784,20 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
17841784
17851785 for ( predicate, _) in bounds {
17861786 let predicate = predicate. subst ( self . tcx , substs) ;
1787- if let ty:: PredicateKind :: Projection ( projection_predicate) =
1788- predicate. kind ( ) . skip_binder ( )
1789- {
1790- if projection_predicate. projection_ty . item_def_id == item_def_id {
1791- // We don't account for multiple `Future::Output = Ty` contraints.
1792- return Some ( projection_predicate. ty ) ;
1793- }
1787+ let output = predicate
1788+ . kind ( )
1789+ . map_bound ( |kind| match kind {
1790+ ty:: PredicateKind :: Projection ( projection_predicate)
1791+ if projection_predicate. projection_ty . item_def_id == item_def_id =>
1792+ {
1793+ Some ( projection_predicate. ty )
1794+ }
1795+ _ => None ,
1796+ } )
1797+ . transpose ( ) ;
1798+ if output. is_some ( ) {
1799+ // We don't account for multiple `Future::Output = Ty` contraints.
1800+ return output;
17941801 }
17951802 }
17961803 }
@@ -1832,8 +1839,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
18321839 }
18331840
18341841 match (
1835- self . get_impl_future_output_ty ( exp_found. expected ) ,
1836- self . get_impl_future_output_ty ( exp_found. found ) ,
1842+ self . get_impl_future_output_ty ( exp_found. expected ) . map ( Binder :: skip_binder ) ,
1843+ self . get_impl_future_output_ty ( exp_found. found ) . map ( Binder :: skip_binder ) ,
18371844 ) {
18381845 ( Some ( exp) , Some ( found) ) if same_type_modulo_infer ( exp, found) => match cause. code ( ) {
18391846 ObligationCauseCode :: IfExpression ( box IfExpressionCause { then, .. } ) => {
0 commit comments