@@ -12,7 +12,7 @@ use rustc_infer::infer::LateBoundRegionConversionTime;
1212use rustc_infer:: infer:: { InferOk , InferResult } ;
1313use rustc_middle:: ty:: fold:: TypeFoldable ;
1414use rustc_middle:: ty:: subst:: InternalSubsts ;
15- use rustc_middle:: ty:: { self , EarlyBinder , Ty } ;
15+ use rustc_middle:: ty:: { self , Ty } ;
1616use rustc_span:: source_map:: Span ;
1717use rustc_span:: DUMMY_SP ;
1818use rustc_target:: spec:: abi:: Abi ;
@@ -175,19 +175,25 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
175175 ) -> ( Option < ExpectedSig < ' tcx > > , Option < ty:: ClosureKind > ) {
176176 match * expected_ty. kind ( ) {
177177 ty:: Opaque ( def_id, substs) => {
178- let bounds = self . tcx . explicit_item_bounds ( def_id) ;
179- let sig = bounds. iter ( ) . find_map ( |( pred, span) | match pred. kind ( ) . skip_binder ( ) {
180- ty:: PredicateKind :: Projection ( proj_predicate) => self
181- . deduce_sig_from_projection (
182- Some ( * span) ,
183- pred. kind ( ) . rebind ( EarlyBinder ( proj_predicate) . subst ( self . tcx , substs) ) ,
184- ) ,
185- _ => None ,
186- } ) ;
178+ let bounds = self . tcx . bound_explicit_item_bounds ( def_id) ;
179+ let sig = bounds
180+ . transpose_iter ( )
181+ . map ( |e| e. map_bound ( |e| * e) . transpose_tuple2 ( ) )
182+ . find_map ( |( pred, span) | match pred. 0 . kind ( ) . skip_binder ( ) {
183+ ty:: PredicateKind :: Projection ( proj_predicate) => self
184+ . deduce_sig_from_projection (
185+ Some ( span. 0 ) ,
186+ pred. 0 . kind ( ) . rebind (
187+ pred. map_bound ( |_| proj_predicate) . subst ( self . tcx , substs) ,
188+ ) ,
189+ ) ,
190+ _ => None ,
191+ } ) ;
187192
188193 let kind = bounds
189- . iter ( )
190- . filter_map ( |( pred, _) | match pred. kind ( ) . skip_binder ( ) {
194+ . transpose_iter ( )
195+ . map ( |e| e. map_bound ( |e| * e) . transpose_tuple2 ( ) )
196+ . filter_map ( |( pred, _) | match pred. 0 . kind ( ) . skip_binder ( ) {
191197 ty:: PredicateKind :: Trait ( tp) => {
192198 self . tcx . fn_trait_kind_from_lang_item ( tp. def_id ( ) )
193199 }
@@ -668,25 +674,29 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
668674 ) ,
669675 } ;
670676
671- let item_bounds = self . tcx . explicit_item_bounds ( def_id) ;
677+ let item_bounds = self . tcx . bound_explicit_item_bounds ( def_id) ;
672678
673679 // Search for a pending obligation like
674680 //
675681 // `<R as Future>::Output = T`
676682 //
677683 // where R is the return type we are expecting. This type `T`
678684 // will be our output.
679- let output_ty = item_bounds. iter ( ) . find_map ( |& ( predicate, span) | {
680- let bound_predicate = EarlyBinder ( predicate) . subst ( self . tcx , substs) . kind ( ) ;
681- if let ty:: PredicateKind :: Projection ( proj_predicate) = bound_predicate. skip_binder ( ) {
682- self . deduce_future_output_from_projection (
683- span,
684- bound_predicate. rebind ( proj_predicate) ,
685- )
686- } else {
687- None
688- }
689- } ) ;
685+ let output_ty = item_bounds
686+ . transpose_iter ( )
687+ . map ( |e| e. map_bound ( |e| * e) . transpose_tuple2 ( ) )
688+ . find_map ( |( predicate, span) | {
689+ let bound_predicate = predicate. subst ( self . tcx , substs) . kind ( ) ;
690+ if let ty:: PredicateKind :: Projection ( proj_predicate) = bound_predicate. skip_binder ( )
691+ {
692+ self . deduce_future_output_from_projection (
693+ span. 0 ,
694+ bound_predicate. rebind ( proj_predicate) ,
695+ )
696+ } else {
697+ None
698+ }
699+ } ) ;
690700
691701 debug ! ( "deduce_future_output_from_obligations: output_ty={:?}" , output_ty) ;
692702 output_ty
0 commit comments