File tree Expand file tree Collapse file tree 1 file changed +4
-5
lines changed
library/alloc/src/collections/linked_list Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change 11// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint
22#![ allow( static_mut_refs) ]
33
4+ use std:: cell:: Cell ;
45use std:: panic:: { AssertUnwindSafe , catch_unwind} ;
56use std:: thread;
67
@@ -1030,16 +1031,14 @@ fn extract_if_drop_panic_leak() {
10301031#[ test]
10311032#[ cfg_attr( not( panic = "unwind" ) , ignore = "test requires unwinding support" ) ]
10321033fn extract_if_pred_panic_leak ( ) {
1033- static mut DROPS : i32 = 0 ;
1034+ thread_local ! { static DROPS : Cell < i32 > = Cell :: new ( 0 ) ; }
10341035
10351036 #[ derive( Debug ) ]
10361037 struct D ( u32 ) ;
10371038
10381039 impl Drop for D {
10391040 fn drop ( & mut self ) {
1040- unsafe {
1041- DROPS += 1 ;
1042- }
1041+ DROPS . with ( |drops| drops. update ( |v| v + 1 ) ) ;
10431042 }
10441043 }
10451044
@@ -1058,7 +1057,7 @@ fn extract_if_pred_panic_leak() {
10581057 } ) )
10591058 . ok ( ) ;
10601059
1061- assert_eq ! ( unsafe { DROPS } , 2 ) ; // 0 and 1
1060+ DROPS . with ( |drops| assert_eq ! ( drops . get ( ) , 2 ) ) ; // 0 and 1
10621061 assert_eq ! ( q. len( ) , 6 ) ;
10631062}
10641063
You can’t perform that action at this time.
0 commit comments