This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +14
-26
lines changed Expand file tree Collapse file tree 6 files changed +14
-26
lines changed Original file line number Diff line number Diff line change @@ -261,9 +261,6 @@ cfg_if::cfg_if! {
261261 }
262262}
263263
264- // FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_refs` lint
265- #[ cfg_attr( bootstrap, allow( static_mut_ref) ) ]
266- #[ cfg_attr( not( bootstrap) , allow( static_mut_refs) ) ]
267264pub unsafe fn panic ( data : Box < dyn Any + Send > ) -> u32 {
268265 use core:: intrinsics:: atomic_store_seqcst;
269266
@@ -325,9 +322,6 @@ pub unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
325322 _CxxThrowException ( throw_ptr, & mut THROW_INFO as * mut _ as * mut _ ) ;
326323}
327324
328- // FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_refs` lint
329- #[ cfg_attr( bootstrap, allow( static_mut_ref) ) ]
330- #[ cfg_attr( not( bootstrap) , allow( static_mut_refs) ) ]
331325pub unsafe fn cleanup ( payload : * mut u8 ) -> Box < dyn Any + Send > {
332326 // A null payload here means that we got here from the catch (...) of
333327 // __rust_try. This happens when a non-Rust foreign exception is caught.
Original file line number Diff line number Diff line change @@ -337,9 +337,6 @@ pub mod panic_count {
337337#[ doc( hidden) ]
338338#[ cfg( not( feature = "panic_immediate_abort" ) ) ]
339339#[ unstable( feature = "update_panic_count" , issue = "none" ) ]
340- // FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_refs` lint
341- #[ cfg_attr( bootstrap, allow( static_mut_ref) ) ]
342- #[ cfg_attr( not( bootstrap) , allow( static_mut_refs) ) ]
343340pub mod panic_count {
344341 use crate :: cell:: Cell ;
345342 use crate :: sync:: atomic:: { AtomicUsize , Ordering } ;
Original file line number Diff line number Diff line change @@ -180,8 +180,6 @@ impl<T: 'static> fmt::Debug for LocalKey<T> {
180180#[ stable( feature = "rust1" , since = "1.0.0" ) ]
181181#[ cfg_attr( not( test) , rustc_diagnostic_item = "thread_local_macro" ) ]
182182#[ allow_internal_unstable( thread_local_internals) ]
183- // FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_refs` lint
184- #[ cfg_attr( not( bootstrap) , allow( static_mut_refs) ) ]
185183macro_rules! thread_local {
186184 // empty (base case for the recursion)
187185 ( ) => { } ;
Original file line number Diff line number Diff line change 11//! Ensure that thread-local statics get deallocated when the thread dies.
22
33#![ feature( thread_local) ]
4- // FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_refs` lint
5- #! [ allow ( static_mut_refs ) ]
4+
5+ use std :: ptr :: addr_of ;
66
77#[ thread_local]
88static mut TLS : u8 = 0 ;
@@ -12,7 +12,7 @@ unsafe impl Send for SendRaw {}
1212
1313fn main ( ) {
1414 unsafe {
15- let dangling_ptr = std:: thread:: spawn ( || SendRaw ( & TLS as * const u8 ) ) . join ( ) . unwrap ( ) ;
15+ let dangling_ptr = std:: thread:: spawn ( || SendRaw ( addr_of ! ( TLS ) ) ) . join ( ) . unwrap ( ) ;
1616 let _val = * dangling_ptr. 0 ; //~ ERROR: has been freed
1717 }
1818}
Original file line number Diff line number Diff line change 1+ use std:: ptr:: addr_of;
2+
13static mut FOO : i32 = 42 ;
24
3- // FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_refs` lint
4- #[ allow( static_mut_refs) ]
5- static BAR : Foo = Foo ( unsafe { & FOO as * const _ } ) ;
5+ static BAR : Foo = Foo ( unsafe { addr_of ! ( FOO ) } ) ;
66
77#[ allow( dead_code) ]
88struct Foo ( * const i32 ) ;
Original file line number Diff line number Diff line change 88//! test, we also check that thread-locals act as per-thread statics.
99
1010#![ feature( thread_local) ]
11- // FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_refs` lint
12- #![ allow( static_mut_refs) ]
1311
12+ use std:: ptr:: addr_of_mut;
1413use std:: thread;
1514
1615#[ thread_local]
@@ -23,8 +22,8 @@ static mut C: u8 = 0;
2322#[ thread_local]
2423static READ_ONLY : u8 = 42 ;
2524
26- unsafe fn get_a_ref ( ) -> * mut u8 {
27- & mut A
25+ unsafe fn get_a_ptr ( ) -> * mut u8 {
26+ addr_of_mut ! ( A )
2827}
2928
3029struct Sender ( * mut u8 ) ;
@@ -35,12 +34,12 @@ fn main() {
3534 let _val = READ_ONLY ;
3635
3736 let ptr = unsafe {
38- let x = get_a_ref ( ) ;
37+ let x = get_a_ptr ( ) ;
3938 * x = 5 ;
4039 assert_eq ! ( A , 5 ) ;
4140 B = 15 ;
4241 C = 25 ;
43- Sender ( & mut A )
42+ Sender ( addr_of_mut ! ( A ) )
4443 } ;
4544
4645 thread:: spawn ( move || unsafe {
@@ -51,18 +50,18 @@ fn main() {
5150 assert_eq ! ( C , 25 ) ;
5251 B = 14 ;
5352 C = 24 ;
54- let y = get_a_ref ( ) ;
53+ let y = get_a_ptr ( ) ;
5554 assert_eq ! ( * y, 0 ) ;
5655 * y = 4 ;
5756 assert_eq ! ( * ptr. 0 , 5 ) ;
5857 assert_eq ! ( A , 4 ) ;
59- assert_eq ! ( * get_a_ref ( ) , 4 ) ;
58+ assert_eq ! ( * get_a_ptr ( ) , 4 ) ;
6059 } )
6160 . join ( )
6261 . unwrap ( ) ;
6362
6463 unsafe {
65- assert_eq ! ( * get_a_ref ( ) , 5 ) ;
64+ assert_eq ! ( * get_a_ptr ( ) , 5 ) ;
6665 assert_eq ! ( A , 5 ) ;
6766 assert_eq ! ( B , 15 ) ;
6867 assert_eq ! ( C , 24 ) ;
You can’t perform that action at this time.
0 commit comments