@@ -1199,7 +1199,7 @@ macro_rules! impl_fn_bind {
1199
1199
{
1200
1200
type Output = Output ;
1201
1201
1202
- type BoundFn = BoundFn < T , $ ( $RuntimeBinderI , ) * > ;
1202
+ type BoundFn = impl FnOnce ( ) -> Output + Copy + Send + ' static ;
1203
1203
1204
1204
fn bind(
1205
1205
self ,
@@ -1209,52 +1209,20 @@ macro_rules! impl_fn_bind {
1209
1209
Binder :: register_dependency( & binder, ctx) ;
1210
1210
1211
1211
let intermediate = Binder :: into_runtime_binder( binder) ;
1212
- BoundFn {
1213
- func: self ,
1214
- runtime_binders: intermediate,
1212
+ move || {
1213
+ // Safety: `runtime_binders` was created by the corresponding
1214
+ // type's `into_runtime_binder` method.
1215
+ // `CfgBindRegistry::finalize` checks that the borrowing
1216
+ // rules regarding the materialization output are observed.
1217
+ // If the check fails, so does the compilation, and this
1218
+ // runtime code will never be executed.
1219
+ let ( $( $fieldI, ) * ) = unsafe {
1220
+ <( $( $RuntimeBinderI, ) * ) as RuntimeBinder >:: materialize( intermediate)
1221
+ } ;
1222
+ self ( $( $fieldI, ) * )
1215
1223
}
1216
1224
}
1217
- }
1218
-
1219
- // This opaque type must be defined outside the above `impl` to
1220
- // prevent the unintended capturing of `$BinderI`.
1221
- // [ref:opaque_type_extraneous_capture]
1222
- // type BoundFn<T, Output, $( $RuntimeBinderI, )*>
1223
- // where
1224
- // $( $RuntimeBinderI: RuntimeBinder, )*
1225
- // T: for<'call> FnOnce($( $RuntimeBinderI::Target<'call>, )*)
1226
- // -> Output + Copy + Send + 'static,
1227
- // = impl FnOnce() -> Output + Copy + Send + 'static;
1228
-
1229
- // FIXME: This is supposed to be a TAIT like the one above, but
1230
- // [ref:rust_99793_tait] prevents that
1231
- #[ derive( Copy , Clone ) ]
1232
- pub struct BoundFn <T , $( $RuntimeBinderI, ) * > {
1233
- func: T ,
1234
- runtime_binders: ( $( $RuntimeBinderI, ) * ) ,
1235
- }
1236
-
1237
- impl <T , Output , $( $RuntimeBinderI, ) * > FnOnce <( ) > for BoundFn <T , $( $RuntimeBinderI, ) * >
1238
- where
1239
- $( $RuntimeBinderI: RuntimeBinder , ) *
1240
- T : for <' call> FnOnce ( $( $RuntimeBinderI:: Target <' call>, ) * ) -> Output ,
1241
- {
1242
- type Output = Output ;
1243
-
1244
- #[ inline]
1245
- extern "rust-call" fn call_once( self , ( ) : ( ) ) -> Output {
1246
- // Safety: `runtime_binders` was created by the corresponding
1247
- // type's `into_runtime_binder` method.
1248
- // `CfgBindRegistry::finalize` checks that the borrowing
1249
- // rules regarding the materialization output are observed.
1250
- // If the check fails, so does the compilation, and this
1251
- // runtime code will never be executed.
1252
- let ( $( $fieldI, ) * ) = unsafe {
1253
- <( $( $RuntimeBinderI, ) * ) as RuntimeBinder >:: materialize( self . runtime_binders)
1254
- } ;
1255
- ( self . func) ( $( $fieldI, ) * )
1256
- }
1257
- }
1225
+ } // impl
1258
1226
} ; // const _
1259
1227
} ; // end of macro arm
1260
1228
@@ -1342,44 +1310,11 @@ where
1342
1310
{
1343
1311
type Output = NewOutput ;
1344
1312
1345
- type BoundFn = MappedBoundFn < InnerBoundFn , Mapper > ;
1313
+ type BoundFn = impl FnOnce ( ) -> NewOutput + Copy + Send + ' static ;
1346
1314
1347
1315
fn bind ( self , binder : Binder , ctx : & mut CfgBindCtx < ' _ > ) -> Self :: BoundFn {
1348
- MappedBoundFn {
1349
- inner_bound_fn : self . inner . bind ( binder, ctx) ,
1350
- mapper : self . mapper ,
1351
- }
1352
- }
1353
- }
1354
-
1355
- // // This opaque type must be defined outside this trait to
1356
- // // prevent the unintended capturing of `Binder`.
1357
- // // [ref:opaque_type_extraneous_capture]
1358
- // type MappedBoundFn<InnerBoundFn, Output, Mapper, NewOutput>
1359
- // where
1360
- // InnerBoundFn: FnOnce() -> Output + Copy + Send + 'static,
1361
- // Mapper: FnOnce(Output) -> NewOutput + Copy + Send + 'static,
1362
- // = impl FnOnce() -> NewOutput + Copy + Send + 'static;
1363
-
1364
- // FIXME: This is supposed to be a TAIT like the one above, but
1365
- // [ref:rust_99793_tait] prevents that
1366
- #[ doc( hidden) ]
1367
- #[ derive( Copy , Clone ) ]
1368
- pub struct MappedBoundFn < InnerBoundFn , Mapper > {
1369
- inner_bound_fn : InnerBoundFn ,
1370
- mapper : Mapper ,
1371
- }
1372
-
1373
- impl < InnerBoundFn , Output , Mapper , NewOutput > FnOnce < ( ) > for MappedBoundFn < InnerBoundFn , Mapper >
1374
- where
1375
- InnerBoundFn : FnOnce ( ) -> Output + Copy + Send + ' static ,
1376
- Mapper : FnOnce ( Output ) -> NewOutput + Copy + Send + ' static ,
1377
- {
1378
- type Output = NewOutput ;
1379
-
1380
- #[ inline]
1381
- extern "rust-call" fn call_once ( self , ( ) : ( ) ) -> Self :: Output {
1382
- ( self . mapper ) ( ( self . inner_bound_fn ) ( ) )
1316
+ let inner_bound_fn = self . inner . bind ( binder, ctx) ;
1317
+ move || ( self . mapper ) ( inner_bound_fn ( ) )
1383
1318
}
1384
1319
}
1385
1320
0 commit comments