@@ -69,7 +69,7 @@ use rustc_middle::ty::error::TypeError;
69
69
use rustc_middle:: ty:: {
70
70
self ,
71
71
subst:: { GenericArgKind , Subst , SubstsRef } ,
72
- Region , Ty , TyCtxt , TypeFoldable ,
72
+ Binder , Region , Ty , TyCtxt , TypeFoldable ,
73
73
} ;
74
74
use rustc_span:: { sym, BytePos , DesugaringKind , MultiSpan , Pos , Span } ;
75
75
use rustc_target:: spec:: abi;
@@ -1774,7 +1774,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
1774
1774
self . note_error_origin ( diag, cause, exp_found, terr) ;
1775
1775
}
1776
1776
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 > > > {
1778
1778
if let ty:: Opaque ( def_id, substs) = ty. kind ( ) {
1779
1779
let future_trait = self . tcx . require_lang_item ( LangItem :: Future , None ) ;
1780
1780
// Future::Output
@@ -1784,13 +1784,20 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
1784
1784
1785
1785
for ( predicate, _) in bounds {
1786
1786
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;
1794
1801
}
1795
1802
}
1796
1803
}
@@ -1832,8 +1839,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
1832
1839
}
1833
1840
1834
1841
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 ) ,
1837
1844
) {
1838
1845
( Some ( exp) , Some ( found) ) if same_type_modulo_infer ( exp, found) => match cause. code ( ) {
1839
1846
ObligationCauseCode :: IfExpression ( box IfExpressionCause { then, .. } ) => {
0 commit comments