12 files changed +26
-11
lines changed Original file line number Diff line number Diff line change @@ -227,8 +227,10 @@ pub fn set_file_information_by_handle<T: SetFileInformation>(
227
227
info : * const c_void ,
228
228
size : u32 ,
229
229
) -> Result < ( ) , WinError > {
230
- let result = c:: SetFileInformationByHandle ( handle, class, info, size) ;
231
- ( result != 0 ) . then_some ( ( ) ) . ok_or_else ( get_last_error)
230
+ unsafe {
231
+ let result = c:: SetFileInformationByHandle ( handle, class, info, size) ;
232
+ ( result != 0 ) . then_some ( ( ) ) . ok_or_else ( get_last_error)
233
+ }
232
234
}
233
235
// SAFETY: The `SetFileInformation` trait ensures that this is safe.
234
236
unsafe { set_info ( handle, T :: CLASS , info. as_ptr ( ) , info. size ( ) ) }
Original file line number Diff line number Diff line change 4
4
#![ cfg_attr( test, allow( dead_code) ) ]
5
5
#![ unstable( issue = "none" , feature = "windows_c" ) ]
6
6
#![ allow( clippy:: style) ]
7
+ #![ allow( unsafe_op_in_unsafe_fn) ]
7
8
8
9
use crate :: ffi:: CStr ;
9
10
use crate :: mem;
Original file line number Diff line number Diff line change @@ -111,9 +111,11 @@ impl Module {
111
111
/// This should only be use for modules that exist for the lifetime of std
112
112
/// (e.g. kernel32 and ntdll).
113
113
pub unsafe fn new ( name : & CStr ) -> Option < Self > {
114
- // SAFETY: A CStr is always null terminated.
115
- let module = c:: GetModuleHandleA ( name. as_ptr ( ) . cast :: < u8 > ( ) ) ;
116
- NonNull :: new ( module) . map ( Self )
114
+ unsafe {
115
+ // SAFETY: A CStr is always null terminated.
116
+ let module = c:: GetModuleHandleA ( name. as_ptr ( ) . cast :: < u8 > ( ) ) ;
117
+ NonNull :: new ( module) . map ( Self )
118
+ }
117
119
}
118
120
119
121
// Try to get the address of a function.
Original file line number Diff line number Diff line change
1
+ #![ allow( unsafe_op_in_unsafe_fn) ]
1
2
use core:: ptr:: addr_of;
2
3
3
4
use crate :: os:: windows:: prelude:: * ;
Original file line number Diff line number Diff line change 1
1
#![ unstable( issue = "none" , feature = "windows_handle" ) ]
2
+ #![ allow( unsafe_op_in_unsafe_fn) ]
2
3
3
4
#[ cfg( test) ]
4
5
mod tests;
Original file line number Diff line number Diff line change
1
+ #![ allow( unsafe_op_in_unsafe_fn) ]
1
2
use crate :: marker:: PhantomData ;
2
3
use crate :: mem:: size_of;
3
4
use crate :: os:: windows:: io:: { AsHandle , AsRawHandle , BorrowedHandle } ;
Original file line number Diff line number Diff line change 1
1
#![ allow( missing_docs, nonstandard_style) ]
2
+ #![ deny( unsafe_op_in_unsafe_fn) ]
2
3
3
4
use crate :: ffi:: { OsStr , OsString } ;
4
5
use crate :: io:: ErrorKind ;
@@ -54,11 +55,13 @@ impl<T> IoResult<T> for Result<T, api::WinError> {
54
55
// SAFETY: must be called only once during runtime initialization.
55
56
// NOTE: this is not guaranteed to run, for example when Rust code is called externally.
56
57
pub unsafe fn init ( _argc : isize , _argv : * const * const u8 , _sigpipe : u8 ) {
57
- stack_overflow:: init ( ) ;
58
+ unsafe {
59
+ stack_overflow:: init ( ) ;
58
60
59
- // Normally, `thread::spawn` will call `Thread::set_name` but since this thread already
60
- // exists, we have to call it ourselves.
61
- thread:: Thread :: set_name_wide ( wide_str ! ( "main" ) ) ;
61
+ // Normally, `thread::spawn` will call `Thread::set_name` but since this thread already
62
+ // exists, we have to call it ourselves.
63
+ thread:: Thread :: set_name_wide ( wide_str ! ( "main" ) ) ;
64
+ }
62
65
}
63
66
64
67
// SAFETY: must be called only once during runtime cleanup.
Original file line number Diff line number Diff line change @@ -436,7 +436,7 @@ impl Socket {
436
436
pub unsafe fn from_raw ( raw : c:: SOCKET ) -> Self {
437
437
debug_assert_eq ! ( mem:: size_of:: <c:: SOCKET >( ) , mem:: size_of:: <RawSocket >( ) ) ;
438
438
debug_assert_eq ! ( mem:: align_of:: <c:: SOCKET >( ) , mem:: align_of:: <RawSocket >( ) ) ;
439
- Self :: from_raw_socket ( raw as RawSocket )
439
+ unsafe { Self :: from_raw_socket ( raw as RawSocket ) }
440
440
}
441
441
}
442
442
@@ -486,6 +486,6 @@ impl IntoRawSocket for Socket {
486
486
487
487
impl FromRawSocket for Socket {
488
488
unsafe fn from_raw_socket ( raw_socket : RawSocket ) -> Self {
489
- Self ( FromRawSocket :: from_raw_socket ( raw_socket) )
489
+ unsafe { Self ( FromRawSocket :: from_raw_socket ( raw_socket) ) }
490
490
}
491
491
}
Original file line number Diff line number Diff line change 1
1
//! Implementation of `std::os` functionality for Windows.
2
2
3
3
#![ allow( nonstandard_style) ]
4
+ #![ allow( unsafe_op_in_unsafe_fn) ]
4
5
5
6
#[ cfg( test) ]
6
7
mod tests;
Original file line number Diff line number Diff line change
1
+ #![ allow( unsafe_op_in_unsafe_fn) ]
1
2
use crate :: os:: windows:: prelude:: * ;
2
3
3
4
use crate :: ffi:: OsStr ;
Original file line number Diff line number Diff line change 1
1
#![ cfg_attr( test, allow( dead_code) ) ]
2
+ #![ allow( unsafe_op_in_unsafe_fn) ]
2
3
3
4
use crate :: sys:: c;
4
5
use crate :: thread;
Original file line number Diff line number Diff line change
1
+ #![ allow( unsafe_op_in_unsafe_fn) ]
1
2
use crate :: ffi:: CStr ;
2
3
use crate :: io;
3
4
use crate :: num:: NonZero ;
0 commit comments