@@ -124,9 +124,11 @@ static mut NUM: u8 = 6 * 7;
124124static NUM_REF : & ' static u8 = unsafe { & * & raw const NUM } ;
125125
126126unsafe fn zeroed < T > ( ) -> T {
127- let mut uninit = MaybeUninit { uninit : ( ) } ;
128- intrinsics:: write_bytes ( & mut uninit. value . value as * mut T , 0 , 1 ) ;
129- uninit. value . value
127+ unsafe {
128+ let mut uninit = MaybeUninit { uninit : ( ) } ;
129+ intrinsics:: write_bytes ( & mut uninit. value . value as * mut T , 0 , 1 ) ;
130+ uninit. value . value
131+ }
130132}
131133
132134fn take_f32 ( _f : f32 ) { }
@@ -236,7 +238,7 @@ fn main() {
236238 }
237239
238240 unsafe fn uninitialized < T > ( ) -> T {
239- MaybeUninit { uninit : ( ) } . value . value
241+ unsafe { MaybeUninit { uninit : ( ) } . value . value }
240242 }
241243
242244 zeroed :: < ( u8 , u8 ) > ( ) ;
@@ -269,20 +271,20 @@ fn main() {
269271 let x = & [ 0u32 , 42u32 ] as & [ u32 ] ;
270272 match x {
271273 [ ] => assert_eq ! ( 0u32 , 1 ) ,
272- [ _, ref y @ ..] => assert_eq ! ( & x[ 1 ] as * const u32 as usize , & y[ 0 ] as * const u32 as usize ) ,
274+ [ _, y @ ..] => assert_eq ! ( & x[ 1 ] as * const u32 as usize , & y[ 0 ] as * const u32 as usize ) ,
273275 }
274276
275277 assert_eq ! ( ( ( |( ) | 42u8 ) as fn ( ( ) ) -> u8 ) ( ( ) ) , 42 ) ;
276278
277279 #[ cfg( not( any( jit, windows) ) ) ]
278280 {
279- extern "C" {
281+ unsafe extern "C" {
280282 #[ linkage = "extern_weak" ]
281283 static ABC : * const u8 ;
282284 }
283285
284286 {
285- extern "C" {
287+ unsafe extern "C" {
286288 #[ linkage = "extern_weak" ]
287289 static ABC : * const u8 ;
288290 }
@@ -309,7 +311,7 @@ fn main() {
309311
310312 check_niche_behavior ( ) ;
311313
312- extern "C" {
314+ unsafe extern "C" {
313315 type ExternType ;
314316 }
315317
@@ -362,7 +364,7 @@ fn stack_val_align() {
362364}
363365
364366#[ cfg( all( not( jit) , target_arch = "x86_64" , any( target_os = "linux" , target_os = "macos" ) ) ) ]
365- extern "C" {
367+ unsafe extern "C" {
366368 fn global_asm_test ( ) ;
367369}
368370
@@ -412,7 +414,7 @@ struct pthread_attr_t {
412414
413415#[ link( name = "pthread" ) ]
414416#[ cfg( unix) ]
415- extern "C" {
417+ unsafe extern "C" {
416418 fn pthread_attr_init ( attr : * mut pthread_attr_t ) -> c_int ;
417419
418420 fn pthread_create (
@@ -433,7 +435,7 @@ type HANDLE = *mut c_void;
433435
434436#[ link( name = "msvcrt" ) ]
435437#[ cfg( windows) ]
436- extern "C" {
438+ unsafe extern "C" {
437439 fn WaitForSingleObject ( hHandle : LPVOID , dwMilliseconds : DWORD ) -> DWORD ;
438440
439441 fn CreateThread (
@@ -455,46 +457,51 @@ struct Thread {
455457
456458impl Thread {
457459 unsafe fn create ( f : extern "C" fn ( _: * mut c_void ) -> * mut c_void ) -> Self {
458- #[ cfg( unix) ]
459- {
460- let mut attr: pthread_attr_t = zeroed ( ) ;
461- let mut thread: pthread_t = 0 ;
460+ unsafe {
461+ #[ cfg( unix) ]
462+ {
463+ let mut attr: pthread_attr_t = zeroed ( ) ;
464+ let mut thread: pthread_t = 0 ;
462465
463- if pthread_attr_init ( & mut attr) != 0 {
464- assert ! ( false ) ;
465- }
466+ if pthread_attr_init ( & mut attr) != 0 {
467+ assert ! ( false ) ;
468+ }
469+
470+ if pthread_create ( & mut thread, & attr, f, 0 as * mut c_void ) != 0 {
471+ assert ! ( false ) ;
472+ }
466473
467- if pthread_create ( & mut thread, & attr, f, 0 as * mut c_void ) != 0 {
468- assert ! ( false ) ;
474+ Thread { handle : thread }
469475 }
470476
471- Thread { handle : thread }
472- }
477+ #[ cfg( windows) ]
478+ {
479+ let handle =
480+ CreateThread ( 0 as * mut c_void , 0 , f, 0 as * mut c_void , 0 , 0 as * mut u32 ) ;
473481
474- # [ cfg ( windows ) ]
475- {
476- let handle = CreateThread ( 0 as * mut c_void , 0 , f , 0 as * mut c_void , 0 , 0 as * mut u32 ) ;
482+ if ( handle as u64 ) == 0 {
483+ assert ! ( false ) ;
484+ }
477485
478- if ( handle as u64 ) == 0 {
479- assert ! ( false ) ;
486+ Thread { handle }
480487 }
481-
482- Thread { handle }
483488 }
484489 }
485490
486491 unsafe fn join ( self ) {
487- #[ cfg( unix) ]
488- {
489- let mut res = 0 as * mut c_void ;
490- pthread_join ( self . handle , & mut res) ;
491- }
492+ unsafe {
493+ #[ cfg( unix) ]
494+ {
495+ let mut res = 0 as * mut c_void ;
496+ pthread_join ( self . handle , & mut res) ;
497+ }
492498
493- #[ cfg( windows) ]
494- {
495- // The INFINITE macro is used to signal operations that do not timeout.
496- let infinite = 0xffffffff ;
497- assert ! ( WaitForSingleObject ( self . handle, infinite) == 0 ) ;
499+ #[ cfg( windows) ]
500+ {
501+ // The INFINITE macro is used to signal operations that do not timeout.
502+ let infinite = 0xffffffff ;
503+ assert ! ( WaitForSingleObject ( self . handle, infinite) == 0 ) ;
504+ }
498505 }
499506 }
500507}
0 commit comments