@@ -74,7 +74,7 @@ use rustc_middle::dep_graph::DepContext;
74
74
use rustc_middle:: ty:: print:: with_no_trimmed_paths;
75
75
use rustc_middle:: ty:: relate:: { self , RelateResult , TypeRelation } ;
76
76
use rustc_middle:: ty:: {
77
- self , error:: TypeError , Binder , List , Region , Ty , TyCtxt , TypeFoldable , TypeSuperVisitable ,
77
+ self , error:: TypeError , List , Region , Ty , TyCtxt , TypeFoldable , TypeSuperVisitable ,
78
78
TypeVisitable ,
79
79
} ;
80
80
use rustc_span:: { sym, symbol:: kw, BytePos , DesugaringKind , Pos , Span } ;
@@ -339,16 +339,15 @@ pub fn unexpected_hidden_region_diagnostic<'tcx>(
339
339
}
340
340
341
341
impl < ' 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 ; } ;
347
344
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 ] ;
349
347
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
352
351
. kind ( )
353
352
. map_bound ( |kind| match kind {
354
353
ty:: PredicateKind :: Clause ( ty:: Clause :: Projection ( projection_predicate) )
@@ -358,14 +357,10 @@ impl<'tcx> InferCtxt<'tcx> {
358
357
}
359
358
_ => None ,
360
359
} )
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
+ )
369
364
}
370
365
}
371
366
@@ -2055,8 +2050,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
2055
2050
}
2056
2051
2057
2052
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 ) ,
2060
2055
) {
2061
2056
( Some ( exp) , Some ( found) ) if self . same_type_modulo_infer ( exp, found) => match cause
2062
2057
. code ( )
0 commit comments