@@ -11,8 +11,8 @@ use crate::{errors::LlvmError, llvm};
1111
1212#[ repr( transparent) ]
1313pub struct TargetMachineWrapper {
14- tm : NonNull < llvm:: TargetMachine > ,
15- phantom : PhantomData < & ' static mut llvm:: TargetMachine > ,
14+ tm_unique : NonNull < llvm:: TargetMachine > ,
15+ phantom : PhantomData < llvm:: TargetMachine > ,
1616}
1717
1818impl TargetMachineWrapper {
@@ -74,7 +74,7 @@ impl TargetMachineWrapper {
7474 } ;
7575
7676 NonNull :: new ( tm_ptr)
77- . map ( |tm | Self { tm , phantom : PhantomData } )
77+ . map ( |tm_unique | Self { tm_unique , phantom : PhantomData } )
7878 . ok_or_else ( || LlvmError :: CreateTargetMachine { triple : SmallCStr :: from ( triple) } )
7979 }
8080}
@@ -84,7 +84,7 @@ impl Deref for TargetMachineWrapper {
8484
8585 fn deref ( & self ) -> & Self :: Target {
8686 // SAFETY: constructing ensures we have a valid pointer created by llvm::LLVMRustCreateTargetMachine
87- unsafe { self . tm . as_ref ( ) }
87+ unsafe { self . tm_unique . as_ref ( ) }
8888 }
8989}
9090
@@ -93,7 +93,7 @@ impl Drop for TargetMachineWrapper {
9393 // SAFETY: constructing ensures we have a valid pointer created by llvm::LLVMRustCreateTargetMachine
9494 // TargetMachineWrapper is not copyable so there is no double free or use after free
9595 unsafe {
96- llvm:: LLVMRustDisposeTargetMachine ( self . tm . as_mut ( ) ) ;
96+ llvm:: LLVMRustDisposeTargetMachine ( self . tm_unique . as_mut ( ) ) ;
9797 }
9898 }
9999}
0 commit comments