@@ -11,8 +11,8 @@ use crate::{errors::LlvmError, llvm};
11
11
12
12
#[ repr( transparent) ]
13
13
pub 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 > ,
16
16
}
17
17
18
18
impl TargetMachineWrapper {
@@ -74,7 +74,7 @@ impl TargetMachineWrapper {
74
74
} ;
75
75
76
76
NonNull :: new ( tm_ptr)
77
- . map ( |tm | Self { tm , phantom : PhantomData } )
77
+ . map ( |tm_unique | Self { tm_unique , phantom : PhantomData } )
78
78
. ok_or_else ( || LlvmError :: CreateTargetMachine { triple : SmallCStr :: from ( triple) } )
79
79
}
80
80
}
@@ -84,7 +84,7 @@ impl Deref for TargetMachineWrapper {
84
84
85
85
fn deref ( & self ) -> & Self :: Target {
86
86
// 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 ( ) }
88
88
}
89
89
}
90
90
@@ -93,7 +93,7 @@ impl Drop for TargetMachineWrapper {
93
93
// SAFETY: constructing ensures we have a valid pointer created by llvm::LLVMRustCreateTargetMachine
94
94
// TargetMachineWrapper is not copyable so there is no double free or use after free
95
95
unsafe {
96
- llvm:: LLVMRustDisposeTargetMachine ( self . tm . as_mut ( ) ) ;
96
+ llvm:: LLVMRustDisposeTargetMachine ( self . tm_unique . as_mut ( ) ) ;
97
97
}
98
98
}
99
99
}
0 commit comments