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 1
1
// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint
2
2
#![ allow( static_mut_refs) ]
3
3
4
+ use std:: cell:: Cell ;
4
5
use std:: panic:: { AssertUnwindSafe , catch_unwind} ;
5
6
use std:: thread;
6
7
@@ -1030,16 +1031,14 @@ fn extract_if_drop_panic_leak() {
1030
1031
#[ test]
1031
1032
#[ cfg_attr( not( panic = "unwind" ) , ignore = "test requires unwinding support" ) ]
1032
1033
fn extract_if_pred_panic_leak ( ) {
1033
- static mut DROPS : i32 = 0 ;
1034
+ thread_local ! { static DROPS : Cell < i32 > = Cell :: new ( 0 ) ; }
1034
1035
1035
1036
#[ derive( Debug ) ]
1036
1037
struct D ( u32 ) ;
1037
1038
1038
1039
impl Drop for D {
1039
1040
fn drop ( & mut self ) {
1040
- unsafe {
1041
- DROPS += 1 ;
1042
- }
1041
+ DROPS . with ( |drops| drops. update ( |v| v + 1 ) ) ;
1043
1042
}
1044
1043
}
1045
1044
@@ -1058,7 +1057,7 @@ fn extract_if_pred_panic_leak() {
1058
1057
} ) )
1059
1058
. ok ( ) ;
1060
1059
1061
- assert_eq ! ( unsafe { DROPS } , 2 ) ; // 0 and 1
1060
+ DROPS . with ( |drops| assert_eq ! ( drops . get ( ) , 2 ) ) ; // 0 and 1
1062
1061
assert_eq ! ( q. len( ) , 6 ) ;
1063
1062
}
1064
1063
You can’t perform that action at this time.
0 commit comments