avoid some int2ptr casts in thread_local_key tests

This commit is contained in:
Ralf Jung 2022-08-11 09:39:25 -04:00
parent 187654481f
commit b5786dcae6

View File

@ -1,4 +1,5 @@
use super::{Key, StaticKey};
use core::ptr;
fn assert_sync<T: Sync>() {}
fn assert_send<T: Send>() {}
@ -12,8 +13,8 @@ fn smoke() {
let k2 = Key::new(None);
assert!(k1.get().is_null());
assert!(k2.get().is_null());
k1.set(1 as *mut _);
k2.set(2 as *mut _);
k1.set(ptr::invalid_mut(1));
k2.set(ptr::invalid_mut(2));
assert_eq!(k1.get() as usize, 1);
assert_eq!(k2.get() as usize, 2);
}
@ -26,8 +27,8 @@ fn statik() {
unsafe {
assert!(K1.get().is_null());
assert!(K2.get().is_null());
K1.set(1 as *mut _);
K2.set(2 as *mut _);
K1.set(ptr::invalid_mut(1));
K2.set(ptr::invalid_mut(2));
assert_eq!(K1.get() as usize, 1);
assert_eq!(K2.get() as usize, 2);
}