@@ -115,9 +115,11 @@ static mut NUM: u8 = 6 * 7;
115115static NUM_REF : & ' static u8 = unsafe { & * & raw const NUM } ;
116116
117117unsafe fn zeroed < T > ( ) -> T {
118- let mut uninit = MaybeUninit { uninit : ( ) } ;
119- intrinsics:: write_bytes ( & mut uninit. value . value as * mut T , 0 , 1 ) ;
120- uninit. value . value
118+ unsafe {
119+ let mut uninit = MaybeUninit { uninit : ( ) } ;
120+ intrinsics:: write_bytes ( & mut uninit. value . value as * mut T , 0 , 1 ) ;
121+ uninit. value . value
122+ }
121123}
122124
123125fn take_f32 ( _f : f32 ) { }
@@ -228,7 +230,7 @@ fn main() {
228230 }
229231
230232 unsafe fn uninitialized < T > ( ) -> T {
231- MaybeUninit { uninit : ( ) } . value . value
233+ unsafe { MaybeUninit { uninit : ( ) } . value . value }
232234 }
233235
234236 zeroed :: < ( u8 , u8 ) > ( ) ;
@@ -261,20 +263,20 @@ fn main() {
261263 let x = & [ 0u32 , 42u32 ] as & [ u32 ] ;
262264 match x {
263265 [ ] => assert_eq ! ( 0u32 , 1 ) ,
264- [ _, ref y @ ..] => assert_eq ! ( & x[ 1 ] as * const u32 as usize , & y[ 0 ] as * const u32 as usize ) ,
266+ [ _, y @ ..] => assert_eq ! ( & x[ 1 ] as * const u32 as usize , & y[ 0 ] as * const u32 as usize ) ,
265267 }
266268
267269 assert_eq ! ( ( ( |( ) | 42u8 ) as fn ( ( ) ) -> u8 ) ( ( ) ) , 42 ) ;
268270
269271 #[ cfg( not( any( jit, target_vendor = "apple" , windows) ) ) ]
270272 {
271- extern "C" {
273+ unsafe extern "C" {
272274 #[ linkage = "extern_weak" ]
273275 static ABC : * const u8 ;
274276 }
275277
276278 {
277- extern "C" {
279+ unsafe extern "C" {
278280 #[ linkage = "extern_weak" ]
279281 static ABC : * const u8 ;
280282 }
@@ -301,7 +303,7 @@ fn main() {
301303
302304 check_niche_behavior ( ) ;
303305
304- extern "C" {
306+ unsafe extern "C" {
305307 type ExternType ;
306308 }
307309
@@ -354,7 +356,7 @@ fn stack_val_align() {
354356}
355357
356358#[ cfg( all( not( jit) , target_arch = "x86_64" , any( target_os = "linux" , target_os = "macos" ) ) ) ]
357- extern "C" {
359+ unsafe extern "C" {
358360 fn global_asm_test ( ) ;
359361}
360362
@@ -402,7 +404,7 @@ struct pthread_attr_t {
402404
403405#[ link( name = "pthread" ) ]
404406#[ cfg( unix) ]
405- extern "C" {
407+ unsafe extern "C" {
406408 fn pthread_attr_init ( attr : * mut pthread_attr_t ) -> c_int ;
407409
408410 fn pthread_create (
@@ -423,7 +425,7 @@ type HANDLE = *mut c_void;
423425
424426#[ link( name = "msvcrt" ) ]
425427#[ cfg( windows) ]
426- extern "C" {
428+ unsafe extern "C" {
427429 fn WaitForSingleObject ( hHandle : LPVOID , dwMilliseconds : DWORD ) -> DWORD ;
428430
429431 fn CreateThread (
@@ -445,46 +447,51 @@ struct Thread {
445447
446448impl Thread {
447449 unsafe fn create ( f : extern "C" fn ( _: * mut c_void ) -> * mut c_void ) -> Self {
448- #[ cfg( unix) ]
449- {
450- let mut attr: pthread_attr_t = zeroed ( ) ;
451- let mut thread: pthread_t = 0 ;
450+ unsafe {
451+ #[ cfg( unix) ]
452+ {
453+ let mut attr: pthread_attr_t = zeroed ( ) ;
454+ let mut thread: pthread_t = 0 ;
452455
453- if pthread_attr_init ( & mut attr) != 0 {
454- assert ! ( false ) ;
455- }
456+ if pthread_attr_init ( & mut attr) != 0 {
457+ assert ! ( false ) ;
458+ }
459+
460+ if pthread_create ( & mut thread, & attr, f, 0 as * mut c_void ) != 0 {
461+ assert ! ( false ) ;
462+ }
456463
457- if pthread_create ( & mut thread, & attr, f, 0 as * mut c_void ) != 0 {
458- assert ! ( false ) ;
464+ Thread { handle : thread }
459465 }
460466
461- Thread { handle : thread }
462- }
467+ #[ cfg( windows) ]
468+ {
469+ let handle =
470+ CreateThread ( 0 as * mut c_void , 0 , f, 0 as * mut c_void , 0 , 0 as * mut u32 ) ;
463471
464- # [ cfg ( windows ) ]
465- {
466- let handle = CreateThread ( 0 as * mut c_void , 0 , f , 0 as * mut c_void , 0 , 0 as * mut u32 ) ;
472+ if ( handle as u64 ) == 0 {
473+ assert ! ( false ) ;
474+ }
467475
468- if ( handle as u64 ) == 0 {
469- assert ! ( false ) ;
476+ Thread { handle }
470477 }
471-
472- Thread { handle }
473478 }
474479 }
475480
476481 unsafe fn join ( self ) {
477- #[ cfg( unix) ]
478- {
479- let mut res = 0 as * mut c_void ;
480- pthread_join ( self . handle , & mut res) ;
481- }
482+ unsafe {
483+ #[ cfg( unix) ]
484+ {
485+ let mut res = 0 as * mut c_void ;
486+ pthread_join ( self . handle , & mut res) ;
487+ }
482488
483- #[ cfg( windows) ]
484- {
485- // The INFINITE macro is used to signal operations that do not timeout.
486- let infinite = 0xffffffff ;
487- assert ! ( WaitForSingleObject ( self . handle, infinite) == 0 ) ;
489+ #[ cfg( windows) ]
490+ {
491+ // The INFINITE macro is used to signal operations that do not timeout.
492+ let infinite = 0xffffffff ;
493+ assert ! ( WaitForSingleObject ( self . handle, infinite) == 0 ) ;
494+ }
488495 }
489496 }
490497}
0 commit comments