@@ -15,6 +15,7 @@ use rustc_middle::ty::visit::TypeVisitable;
15
15
use rustc_middle:: ty:: { self , Ty } ;
16
16
use rustc_span:: source_map:: Span ;
17
17
use rustc_target:: spec:: abi:: Abi ;
18
+ use rustc_trait_selection:: traits;
18
19
use rustc_trait_selection:: traits:: error_reporting:: ArgKind ;
19
20
use rustc_trait_selection:: traits:: error_reporting:: InferCtxtExt as _;
20
21
use std:: cmp;
@@ -226,27 +227,30 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
226
227
expected_vid : ty:: TyVid ,
227
228
) -> ( Option < ExpectedSig < ' tcx > > , Option < ty:: ClosureKind > ) {
228
229
let mut expected_sig = None ;
229
- // Even if we can't infer the full signature, we may be able to
230
- // infer the kind. This can occur when we elaborate a predicate
231
- // like `F : Fn<A>`. Note that due to subtyping we could encounter
232
- // many viable options, so pick the most restrictive.
233
230
let mut expected_kind = None ;
234
231
235
- for obligation in self . obligations_for_self_ty ( expected_vid) {
232
+ for obligation in traits:: elaborate_obligations (
233
+ self . tcx ,
234
+ self . obligations_for_self_ty ( expected_vid) . collect ( ) ,
235
+ ) {
236
236
debug ! ( ?obligation. predicate) ;
237
237
let bound_predicate = obligation. predicate . kind ( ) ;
238
238
239
+ // Given a Projection predicate, we can potentially infer
240
+ // the complete signature.
239
241
if expected_sig. is_none ( )
240
242
&& let ty:: PredicateKind :: Projection ( proj_predicate) = bound_predicate. skip_binder ( )
241
243
{
242
- // Given a Projection predicate, we can potentially infer
243
- // the complete signature.
244
244
expected_sig = self . deduce_sig_from_projection (
245
245
Some ( obligation. cause . span ) ,
246
246
bound_predicate. rebind ( proj_predicate) ,
247
247
) ;
248
248
}
249
249
250
+ // Even if we can't infer the full signature, we may be able to
251
+ // infer the kind. This can occur when we elaborate a predicate
252
+ // like `F : Fn<A>`. Note that due to subtyping we could encounter
253
+ // many viable options, so pick the most restrictive.
250
254
let trait_def_id = match bound_predicate. skip_binder ( ) {
251
255
ty:: PredicateKind :: Projection ( data) => {
252
256
Some ( data. projection_ty . trait_def_id ( self . tcx ) )
0 commit comments