@@ -74,7 +74,7 @@ use rustc_middle::dep_graph::DepContext;
7474use rustc_middle:: ty:: print:: with_no_trimmed_paths;
7575use rustc_middle:: ty:: relate:: { self , RelateResult , TypeRelation } ;
7676use rustc_middle:: ty:: {
77- self , error:: TypeError , Binder , List , Region , Ty , TyCtxt , TypeFoldable , TypeSuperVisitable ,
77+ self , error:: TypeError , List , Region , Ty , TyCtxt , TypeFoldable , TypeSuperVisitable ,
7878 TypeVisitable ,
7979} ;
8080use rustc_span:: { sym, symbol:: kw, BytePos , DesugaringKind , Pos , Span } ;
@@ -339,16 +339,15 @@ pub fn unexpected_hidden_region_diagnostic<'tcx>(
339339}
340340
341341impl < ' tcx > InferCtxt < ' tcx > {
342- pub fn get_impl_future_output_ty ( & self , ty : Ty < ' tcx > ) -> Option < Binder < ' tcx , Ty < ' tcx > > > {
343- if let ty:: Opaque ( def_id, substs) = ty. kind ( ) {
344- let future_trait = self . tcx . require_lang_item ( LangItem :: Future , None ) ;
345- // Future::Output
346- let item_def_id = self . tcx . associated_item_def_ids ( future_trait) [ 0 ] ;
342+ pub fn get_impl_future_output_ty ( & self , ty : Ty < ' tcx > ) -> Option < Ty < ' tcx > > {
343+ let ty:: Opaque ( def_id, substs) = * ty. kind ( ) else { return None ; } ;
347344
348- let bounds = self . tcx . bound_explicit_item_bounds ( * def_id) ;
345+ let future_trait = self . tcx . require_lang_item ( LangItem :: Future , None ) ;
346+ let item_def_id = self . tcx . associated_item_def_ids ( future_trait) [ 0 ] ;
349347
350- for ( predicate, _) in bounds. subst_iter_copied ( self . tcx , substs) {
351- let output = predicate
348+ self . tcx . bound_explicit_item_bounds ( def_id) . subst_iter_copied ( self . tcx , substs) . find_map (
349+ |( predicate, _) | {
350+ predicate
352351 . kind ( )
353352 . map_bound ( |kind| match kind {
354353 ty:: PredicateKind :: Clause ( ty:: Clause :: Projection ( projection_predicate) )
@@ -358,14 +357,10 @@ impl<'tcx> InferCtxt<'tcx> {
358357 }
359358 _ => None ,
360359 } )
361- . transpose ( ) ;
362- if output. is_some ( ) {
363- // We don't account for multiple `Future::Output = Ty` constraints.
364- return output;
365- }
366- }
367- }
368- None
360+ . no_bound_vars ( )
361+ . flatten ( )
362+ } ,
363+ )
369364 }
370365}
371366
@@ -2055,8 +2050,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
20552050 }
20562051
20572052 match (
2058- self . get_impl_future_output_ty ( exp_found. expected ) . map ( Binder :: skip_binder ) ,
2059- self . get_impl_future_output_ty ( exp_found. found ) . map ( Binder :: skip_binder ) ,
2053+ self . get_impl_future_output_ty ( exp_found. expected ) ,
2054+ self . get_impl_future_output_ty ( exp_found. found ) ,
20602055 ) {
20612056 ( Some ( exp) , Some ( found) ) if self . same_type_modulo_infer ( exp, found) => match cause
20622057 . code ( )
0 commit comments