@@ -12,7 +12,7 @@ use rustc_infer::infer::LateBoundRegionConversionTime;
12
12
use rustc_infer:: infer:: { InferOk , InferResult } ;
13
13
use rustc_middle:: ty:: fold:: TypeFoldable ;
14
14
use rustc_middle:: ty:: subst:: InternalSubsts ;
15
- use rustc_middle:: ty:: { self , EarlyBinder , Ty } ;
15
+ use rustc_middle:: ty:: { self , Ty } ;
16
16
use rustc_span:: source_map:: Span ;
17
17
use rustc_span:: DUMMY_SP ;
18
18
use rustc_target:: spec:: abi:: Abi ;
@@ -175,19 +175,25 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
175
175
) -> ( Option < ExpectedSig < ' tcx > > , Option < ty:: ClosureKind > ) {
176
176
match * expected_ty. kind ( ) {
177
177
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
+ } ) ;
187
192
188
193
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 ( ) {
191
197
ty:: PredicateKind :: Trait ( tp) => {
192
198
self . tcx . fn_trait_kind_from_lang_item ( tp. def_id ( ) )
193
199
}
@@ -668,25 +674,29 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
668
674
) ,
669
675
} ;
670
676
671
- let item_bounds = self . tcx . explicit_item_bounds ( def_id) ;
677
+ let item_bounds = self . tcx . bound_explicit_item_bounds ( def_id) ;
672
678
673
679
// Search for a pending obligation like
674
680
//
675
681
// `<R as Future>::Output = T`
676
682
//
677
683
// where R is the return type we are expecting. This type `T`
678
684
// 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
+ } ) ;
690
700
691
701
debug ! ( "deduce_future_output_from_obligations: output_ty={:?}" , output_ty) ;
692
702
output_ty
0 commit comments