@@ -1402,19 +1402,15 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
14021402 }
14031403
14041404 // provide an impl, but only for suitable `fn` pointers
1405- ty:: TyFnDef ( .., ty:: Binder ( ty:: FnSig {
1406- unsafety : hir:: Unsafety :: Normal ,
1407- abi : Abi :: Rust ,
1408- variadic : false ,
1409- ..
1410- } ) ) |
1411- ty:: TyFnPtr ( ty:: Binder ( ty:: FnSig {
1412- unsafety : hir:: Unsafety :: Normal ,
1413- abi : Abi :: Rust ,
1414- variadic : false ,
1415- ..
1416- } ) ) => {
1417- candidates. vec . push ( FnPointerCandidate ) ;
1405+ ty:: TyFnDef ( ..) | ty:: TyFnPtr ( _) => {
1406+ if let ty:: Binder ( ty:: FnSig {
1407+ unsafety : hir:: Unsafety :: Normal ,
1408+ abi : Abi :: Rust ,
1409+ variadic : false ,
1410+ ..
1411+ } ) = self_ty. fn_sig ( self . tcx ( ) ) {
1412+ candidates. vec . push ( FnPointerCandidate ) ;
1413+ }
14181414 }
14191415
14201416 _ => { }
@@ -2346,19 +2342,26 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
23462342
23472343 // ok to skip binder; it is reintroduced below
23482344 let self_ty = self . infcx . shallow_resolve ( * obligation. self_ty ( ) . skip_binder ( ) ) ;
2349- let sig = self_ty. fn_sig ( ) ;
2345+ let sig = self_ty. fn_sig ( self . tcx ( ) ) ;
23502346 let trait_ref =
23512347 self . tcx ( ) . closure_trait_ref_and_return_type ( obligation. predicate . def_id ( ) ,
23522348 self_ty,
23532349 sig,
23542350 util:: TupleArgumentsFlag :: Yes )
23552351 . map_bound ( |( trait_ref, _) | trait_ref) ;
23562352
2353+ let Normalized { value : trait_ref, obligations } =
2354+ project:: normalize_with_depth ( self ,
2355+ obligation. param_env ,
2356+ obligation. cause . clone ( ) ,
2357+ obligation. recursion_depth + 1 ,
2358+ & trait_ref) ;
2359+
23572360 self . confirm_poly_trait_refs ( obligation. cause . clone ( ) ,
23582361 obligation. param_env ,
23592362 obligation. predicate . to_poly_trait_ref ( ) ,
23602363 trait_ref) ?;
2361- Ok ( VtableFnPointerData { fn_ty : self_ty, nested : vec ! [ ] } )
2364+ Ok ( VtableFnPointerData { fn_ty : self_ty, nested : obligations } )
23622365 }
23632366
23642367 fn confirm_closure_candidate ( & mut self ,
@@ -2797,7 +2800,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
27972800 substs : ty:: ClosureSubsts < ' tcx > )
27982801 -> ty:: PolyTraitRef < ' tcx >
27992802 {
2800- let closure_type = self . infcx . closure_type ( closure_def_id)
2803+ let closure_type = self . infcx . fn_sig ( closure_def_id)
28012804 . subst ( self . tcx ( ) , substs. substs ) ;
28022805 let ty:: Binder ( ( trait_ref, _) ) =
28032806 self . tcx ( ) . closure_trait_ref_and_return_type ( obligation. predicate . def_id ( ) ,
0 commit comments