@@ -2327,8 +2327,9 @@ fn confirm_fn_pointer_candidate<'cx, 'tcx>(
2327
2327
obligation : & ProjectionTyObligation < ' tcx > ,
2328
2328
nested : Vec < PredicateObligation < ' tcx > > ,
2329
2329
) -> Progress < ' tcx > {
2330
+ let tcx = selcx. tcx ( ) ;
2330
2331
let fn_type = selcx. infcx . shallow_resolve ( obligation. predicate . self_ty ( ) ) ;
2331
- let sig = fn_type. fn_sig ( selcx . tcx ( ) ) ;
2332
+ let sig = fn_type. fn_sig ( tcx) ;
2332
2333
let Normalized { value : sig, obligations } = normalize_with_depth (
2333
2334
selcx,
2334
2335
obligation. param_env ,
@@ -2337,9 +2338,24 @@ fn confirm_fn_pointer_candidate<'cx, 'tcx>(
2337
2338
sig,
2338
2339
) ;
2339
2340
2340
- confirm_callable_candidate ( selcx, obligation, sig, util:: TupleArgumentsFlag :: Yes )
2341
- . with_addl_obligations ( nested)
2342
- . with_addl_obligations ( obligations)
2341
+ let host_effect_param = match * fn_type. kind ( ) {
2342
+ ty:: FnDef ( def_id, args) => tcx
2343
+ . generics_of ( def_id)
2344
+ . host_effect_index
2345
+ . map_or ( tcx. consts . true_ , |idx| args. const_at ( idx) ) ,
2346
+ ty:: FnPtr ( _) => tcx. consts . true_ ,
2347
+ _ => unreachable ! ( "only expected FnPtr or FnDef in `confirm_fn_pointer_candidate`" ) ,
2348
+ } ;
2349
+
2350
+ confirm_callable_candidate (
2351
+ selcx,
2352
+ obligation,
2353
+ sig,
2354
+ util:: TupleArgumentsFlag :: Yes ,
2355
+ host_effect_param,
2356
+ )
2357
+ . with_addl_obligations ( nested)
2358
+ . with_addl_obligations ( obligations)
2343
2359
}
2344
2360
2345
2361
fn confirm_closure_candidate < ' cx , ' tcx > (
@@ -2362,16 +2378,24 @@ fn confirm_closure_candidate<'cx, 'tcx>(
2362
2378
2363
2379
debug ! ( ?obligation, ?closure_sig, ?obligations, "confirm_closure_candidate" ) ;
2364
2380
2365
- confirm_callable_candidate ( selcx, obligation, closure_sig, util:: TupleArgumentsFlag :: No )
2366
- . with_addl_obligations ( nested)
2367
- . with_addl_obligations ( obligations)
2381
+ confirm_callable_candidate (
2382
+ selcx,
2383
+ obligation,
2384
+ closure_sig,
2385
+ util:: TupleArgumentsFlag :: No ,
2386
+ // FIXME(effects): This doesn't handle const closures correctly!
2387
+ selcx. tcx ( ) . consts . true_ ,
2388
+ )
2389
+ . with_addl_obligations ( nested)
2390
+ . with_addl_obligations ( obligations)
2368
2391
}
2369
2392
2370
2393
fn confirm_callable_candidate < ' cx , ' tcx > (
2371
2394
selcx : & mut SelectionContext < ' cx , ' tcx > ,
2372
2395
obligation : & ProjectionTyObligation < ' tcx > ,
2373
2396
fn_sig : ty:: PolyFnSig < ' tcx > ,
2374
2397
flag : util:: TupleArgumentsFlag ,
2398
+ fn_host_effect : ty:: Const < ' tcx > ,
2375
2399
) -> Progress < ' tcx > {
2376
2400
let tcx = selcx. tcx ( ) ;
2377
2401
@@ -2386,6 +2410,7 @@ fn confirm_callable_candidate<'cx, 'tcx>(
2386
2410
obligation. predicate . self_ty ( ) ,
2387
2411
fn_sig,
2388
2412
flag,
2413
+ fn_host_effect,
2389
2414
)
2390
2415
. map_bound ( |( trait_ref, ret_type) | ty:: ProjectionPredicate {
2391
2416
projection_ty : ty:: AliasTy :: new ( tcx, fn_once_output_def_id, trait_ref. args ) ,
0 commit comments