Skip to content

Commit ea42f3c

Browse files
Rollup merge of #100407 - RalfJung:no-int2ptr, r=Mark-Simulacrum
avoid some int2ptr casts in thread_local_key tests
2 parents 4b51df3 + b5786dc commit ea42f3c

File tree

1 file changed

+5
-4
lines changed
  • library/std/src/sys_common/thread_local_key

1 file changed

+5
-4
lines changed

library/std/src/sys_common/thread_local_key/tests.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use super::{Key, StaticKey};
2+
use core::ptr;
23

34
fn assert_sync<T: Sync>() {}
45
fn assert_send<T: Send>() {}
@@ -12,8 +13,8 @@ fn smoke() {
1213
let k2 = Key::new(None);
1314
assert!(k1.get().is_null());
1415
assert!(k2.get().is_null());
15-
k1.set(1 as *mut _);
16-
k2.set(2 as *mut _);
16+
k1.set(ptr::invalid_mut(1));
17+
k2.set(ptr::invalid_mut(2));
1718
assert_eq!(k1.get() as usize, 1);
1819
assert_eq!(k2.get() as usize, 2);
1920
}
@@ -26,8 +27,8 @@ fn statik() {
2627
unsafe {
2728
assert!(K1.get().is_null());
2829
assert!(K2.get().is_null());
29-
K1.set(1 as *mut _);
30-
K2.set(2 as *mut _);
30+
K1.set(ptr::invalid_mut(1));
31+
K2.set(ptr::invalid_mut(2));
3132
assert_eq!(K1.get() as usize, 1);
3233
assert_eq!(K2.get() as usize, 2);
3334
}

0 commit comments

Comments
 (0)