@@ -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;
@@ -1765,7 +1765,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
1765
1765
self . note_error_origin ( diag, cause, exp_found, terr) ;
1766
1766
}
1767
1767
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 > > > {
1769
1769
if let ty:: Opaque ( def_id, substs) = ty. kind ( ) {
1770
1770
let future_trait = self . tcx . require_lang_item ( LangItem :: Future , None ) ;
1771
1771
// Future::Output
@@ -1775,13 +1775,20 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
1775
1775
1776
1776
for ( predicate, _) in bounds {
1777
1777
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;
1785
1792
}
1786
1793
}
1787
1794
}
@@ -1823,8 +1830,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
1823
1830
}
1824
1831
1825
1832
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 ) ,
1828
1835
) {
1829
1836
( Some ( exp) , Some ( found) ) if same_type_modulo_infer ( exp, found) => match cause. code ( ) {
1830
1837
ObligationCauseCode :: IfExpression ( box IfExpressionCause { then, .. } ) => {
0 commit comments