File tree Expand file tree Collapse file tree 3 files changed +14
-10
lines changed Expand file tree Collapse file tree 3 files changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -134,26 +134,26 @@ compat_fn_with_fallback! {
134134 // >= Win10 1607
135135 // https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-setthreaddescription
136136 pub fn SetThreadDescription ( hthread: HANDLE , lpthreaddescription: PCWSTR ) -> HRESULT {
137- SetLastError ( ERROR_CALL_NOT_IMPLEMENTED as u32 ) ; E_NOTIMPL
137+ unsafe { SetLastError ( ERROR_CALL_NOT_IMPLEMENTED as u32 ) ; E_NOTIMPL }
138138 }
139139
140140 // >= Win10 1607
141141 // https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getthreaddescription
142142 pub fn GetThreadDescription ( hthread: HANDLE , lpthreaddescription: * mut PWSTR ) -> HRESULT {
143- SetLastError ( ERROR_CALL_NOT_IMPLEMENTED as u32 ) ; E_NOTIMPL
143+ unsafe { SetLastError ( ERROR_CALL_NOT_IMPLEMENTED as u32 ) ; E_NOTIMPL }
144144 }
145145
146146 // >= Win8 / Server 2012
147147 // https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsystemtimepreciseasfiletime
148148 #[ cfg( target_vendor = "win7" ) ]
149149 pub fn GetSystemTimePreciseAsFileTime ( lpsystemtimeasfiletime: * mut FILETIME ) -> ( ) {
150- GetSystemTimeAsFileTime ( lpsystemtimeasfiletime)
150+ unsafe { GetSystemTimeAsFileTime ( lpsystemtimeasfiletime) }
151151 }
152152
153153 // >= Win11 / Server 2022
154154 // https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettemppath2a
155155 pub fn GetTempPath2W ( bufferlength: u32 , buffer: PWSTR ) -> u32 {
156- GetTempPathW ( bufferlength, buffer)
156+ unsafe { GetTempPathW ( bufferlength, buffer) }
157157 }
158158}
159159
Original file line number Diff line number Diff line change @@ -158,8 +158,10 @@ macro_rules! compat_fn_with_fallback {
158158 static PTR : AtomicPtr <c_void> = AtomicPtr :: new( load as * mut _) ;
159159
160160 unsafe extern "system" fn load( $( $argname: $argtype) ,* ) -> $rettype {
161- let func = load_from_module( Module :: new( $module) ) ;
162- func( $( $argname) ,* )
161+ unsafe {
162+ let func = load_from_module( Module :: new( $module) ) ;
163+ func( $( $argname) ,* )
164+ }
163165 }
164166
165167 fn load_from_module( module: Option <Module >) -> F {
@@ -182,8 +184,10 @@ macro_rules! compat_fn_with_fallback {
182184
183185 #[ inline( always) ]
184186 pub unsafe fn call( $( $argname: $argtype) ,* ) -> $rettype {
185- let func: F = mem:: transmute( PTR . load( Ordering :: Relaxed ) ) ;
186- func( $( $argname) ,* )
187+ unsafe {
188+ let func: F = mem:: transmute( PTR . load( Ordering :: Relaxed ) ) ;
189+ func( $( $argname) ,* )
190+ }
187191 }
188192 }
189193 #[ allow( unused) ]
@@ -225,7 +229,7 @@ macro_rules! compat_fn_optional {
225229 }
226230 #[ inline]
227231 pub unsafe extern "system" fn $symbol( $( $argname: $argtype) ,* ) $( -> $rettype) ? {
228- $symbol:: option( ) . unwrap( ) ( $( $argname) ,* )
232+ unsafe { $symbol:: option( ) . unwrap( ) ( $( $argname) ,* ) }
229233 }
230234 ) +
231235 )
Original file line number Diff line number Diff line change 11#![ allow( missing_docs, nonstandard_style) ]
2- #![ deny ( unsafe_op_in_unsafe_fn) ]
2+ #![ forbid ( unsafe_op_in_unsafe_fn) ]
33
44use crate :: ffi:: { OsStr , OsString } ;
55use crate :: io:: ErrorKind ;
You can’t perform that action at this time.
0 commit comments