Rollup merge of #100407 - RalfJung:no-int2ptr, r=Mark-Simulacrum

avoid some int2ptr casts in thread_local_key tests
This commit is contained in:
Michael Goulet 2022-08-13 14:10:05 -07:00 committed by GitHub
commit ea42f3cfd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 4 deletions

View File

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