@@ -15,6 +15,7 @@ use rustc_middle::ty::visit::TypeVisitable;
1515use rustc_middle:: ty:: { self , Ty } ;
1616use rustc_span:: source_map:: Span ;
1717use rustc_target:: spec:: abi:: Abi ;
18+ use rustc_trait_selection:: traits;
1819use rustc_trait_selection:: traits:: error_reporting:: ArgKind ;
1920use rustc_trait_selection:: traits:: error_reporting:: InferCtxtExt as _;
2021use std:: cmp;
@@ -226,27 +227,30 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
226227 expected_vid : ty:: TyVid ,
227228 ) -> ( Option < ExpectedSig < ' tcx > > , Option < ty:: ClosureKind > ) {
228229 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.
233230 let mut expected_kind = None ;
234231
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+ ) {
236236 debug ! ( ?obligation. predicate) ;
237237 let bound_predicate = obligation. predicate . kind ( ) ;
238238
239+ // Given a Projection predicate, we can potentially infer
240+ // the complete signature.
239241 if expected_sig. is_none ( )
240242 && let ty:: PredicateKind :: Projection ( proj_predicate) = bound_predicate. skip_binder ( )
241243 {
242- // Given a Projection predicate, we can potentially infer
243- // the complete signature.
244244 expected_sig = self . deduce_sig_from_projection (
245245 Some ( obligation. cause . span ) ,
246246 bound_predicate. rebind ( proj_predicate) ,
247247 ) ;
248248 }
249249
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.
250254 let trait_def_id = match bound_predicate. skip_binder ( ) {
251255 ty:: PredicateKind :: Projection ( data) => {
252256 Some ( data. projection_ty . trait_def_id ( self . tcx ) )
0 commit comments