@@ -11,7 +11,6 @@ use std::rc::Rc;
11
11
use std:: ops:: Deref ;
12
12
use std:: ffi:: CString ;
13
13
use std:: fmt:: { self , Debug , Display , Formatter } ;
14
- use std:: marker:: PhantomData ;
15
14
use std:: mem:: { forget, zeroed, transmute_copy, size_of} ;
16
15
17
16
#[ derive( Debug , PartialEq , Eq ) ]
@@ -286,7 +285,7 @@ impl ExecutionEngine {
286
285
/// method *may* invalidate the function pointer.
287
286
///
288
287
/// [`UnsafeFunctionPointer`]: trait.UnsafeFunctionPointer.html
289
- pub unsafe fn get_function < ' engine , F > ( & ' engine self , fn_name : & str ) -> Result < JitFunction < ' engine , F > , FunctionLookupError >
288
+ pub unsafe fn get_function < F > ( & self , fn_name : & str ) -> Result < JitFunction < F > , FunctionLookupError >
290
289
where
291
290
F : UnsafeFunctionPointer ,
292
291
{
@@ -315,7 +314,7 @@ impl ExecutionEngine {
315
314
"The type `F` must have the same size as a function pointer" ) ;
316
315
317
316
Ok ( JitFunction {
318
- _execution_engine : PhantomData ,
317
+ _execution_engine : self . execution_engine . clone ( ) ,
319
318
inner : transmute_copy ( & address) ,
320
319
} )
321
320
}
@@ -436,12 +435,12 @@ impl Deref for ExecEngineInner {
436
435
/// A wrapper around a function pointer which ensures the function being pointed
437
436
/// to doesn't accidentally outlive its execution engine.
438
437
#[ derive( Clone ) ]
439
- pub struct JitFunction < ' engine , F > {
440
- _execution_engine : PhantomData < & ' engine ExecutionEngine > ,
438
+ pub struct JitFunction < F > {
439
+ _execution_engine : ExecEngineInner ,
441
440
inner : F ,
442
441
}
443
442
444
- impl < ' engine , F > Debug for JitFunction < ' engine , F > {
443
+ impl < F > Debug for JitFunction < F > {
445
444
fn fmt ( & self , f : & mut Formatter ) -> fmt:: Result {
446
445
f. debug_tuple ( "JitFunction" )
447
446
. field ( & "<unnamed>" )
@@ -470,9 +469,9 @@ macro_rules! impl_unsafe_fn {
470
469
( @recurse) => { } ;
471
470
472
471
( $( $param: ident ) ,* ) => {
473
- impl <' engine , Output , $( $param ) ,* > private:: SealedUnsafeFunctionPointer for unsafe extern "C" fn ( $( $param ) ,* ) -> Output { }
472
+ impl <Output , $( $param ) ,* > private:: SealedUnsafeFunctionPointer for unsafe extern "C" fn ( $( $param ) ,* ) -> Output { }
474
473
475
- impl <' engine , Output , $( $param ) ,* > JitFunction <' engine , unsafe extern "C" fn ( $( $param ) ,* ) -> Output > {
474
+ impl <Output , $( $param ) ,* > JitFunction <unsafe extern "C" fn ( $( $param ) ,* ) -> Output > {
476
475
/// This method allows you to call the underlying function while making
477
476
/// sure that the backing storage is not dropped too early and
478
477
/// preserves the `unsafe` marker for any calls.
0 commit comments