@@ -1196,10 +1196,7 @@ macro_rules! impl_fn_bind {
1196
1196
{
1197
1197
type Output = Output ;
1198
1198
1199
- // This opaque type must be defined outside this trait to
1200
- // prevent the unintended capturing of `$BinderI`.
1201
- // [ref:opaque_type_extraneous_capture]
1202
- type BoundFn = BoundFn <T , Output , $( $RuntimeBinderI, ) * >;
1199
+ type BoundFn = BoundFn <T , $( $RuntimeBinderI, ) * >;
1203
1200
1204
1201
fn bind(
1205
1202
self ,
@@ -1209,42 +1206,50 @@ macro_rules! impl_fn_bind {
1209
1206
Binder :: register_dependency( & binder, ctx) ;
1210
1207
1211
1208
let intermediate = Binder :: into_runtime_binder( binder) ;
1212
- bind_inner( self , intermediate)
1209
+ BoundFn {
1210
+ func: self ,
1211
+ runtime_binders: intermediate,
1212
+ }
1213
1213
}
1214
1214
}
1215
1215
1216
- type BoundFn <T , Output , $( $RuntimeBinderI, ) * >
1217
- where
1218
- $( $RuntimeBinderI: RuntimeBinder , ) *
1219
- T : for <' call> FnOnce ( $( $RuntimeBinderI:: Target <' call>, ) * )
1220
- -> Output + Copy + Send + ' static ,
1221
- = impl FnOnce ( ) -> Output + Copy + Send + ' static ;
1222
-
1223
- const fn bind_inner<
1224
- T ,
1225
- Output ,
1226
- $( $RuntimeBinderI, ) *
1227
- >(
1216
+ // This opaque type must be defined outside the above `impl` to
1217
+ // prevent the unintended capturing of `$BinderI`.
1218
+ // [ref:opaque_type_extraneous_capture]
1219
+ // type BoundFn<T, Output, $( $RuntimeBinderI, )*>
1220
+ // where
1221
+ // $( $RuntimeBinderI: RuntimeBinder, )*
1222
+ // T: for<'call> FnOnce($( $RuntimeBinderI::Target<'call>, )*)
1223
+ // -> Output + Copy + Send + 'static,
1224
+ // = impl FnOnce() -> Output + Copy + Send + 'static;
1225
+
1226
+ // FIXME: This is supposed to be a TAIT like the one above, but
1227
+ // [ref:rust_99793_tait] prevents that
1228
+ #[ derive( Copy , Clone ) ]
1229
+ pub struct BoundFn <T , $( $RuntimeBinderI, ) * > {
1228
1230
func: T ,
1229
- runtime_binders: ( $( $RuntimeBinderI, ) * ) ,
1230
- ) -> BoundFn <T , Output , $( $RuntimeBinderI, ) * >
1231
+ runtime_binders: ( $( $RuntimeBinderI, ) * ) ,
1232
+ }
1233
+
1234
+ impl <T , Output , $( $RuntimeBinderI, ) * > FnOnce <( ) > for BoundFn <T , $( $RuntimeBinderI, ) * >
1231
1235
where
1232
1236
$( $RuntimeBinderI: RuntimeBinder , ) *
1233
- T : for <' call> FnOnce ( $( $RuntimeBinderI:: Target <' call>, ) * )
1234
- -> Output + Copy + Send + ' static ,
1237
+ T : for <' call> FnOnce ( $( $RuntimeBinderI:: Target <' call>, ) * ) -> Output ,
1235
1238
{
1239
+ type Output = Output ;
1240
+
1236
1241
#[ inline]
1237
- move || {
1242
+ extern "rust-call" fn call_once ( self , ( ) : ( ) ) -> Output {
1238
1243
// Safety: `runtime_binders` was created by the corresponding
1239
1244
// type's `into_runtime_binder` method.
1240
1245
// `CfgBindRegistry::finalize` checks that the borrowing
1241
1246
// rules regarding the materialization output are observed.
1242
1247
// If the check fails, so does the compilation, and this
1243
1248
// runtime code will never be executed.
1244
1249
let ( $( $fieldI, ) * ) = unsafe {
1245
- <( $( $RuntimeBinderI, ) * ) as RuntimeBinder >:: materialize( runtime_binders)
1250
+ <( $( $RuntimeBinderI, ) * ) as RuntimeBinder >:: materialize( self . runtime_binders)
1246
1251
} ;
1247
- func( $( $fieldI, ) * )
1252
+ ( self . func) ( $( $fieldI, ) * )
1248
1253
}
1249
1254
}
1250
1255
} ; // const _
0 commit comments