mirror of https://github.com/rust-lang/rust.git
Rollup merge of #100407 - RalfJung:no-int2ptr, r=Mark-Simulacrum
avoid some int2ptr casts in thread_local_key tests
This commit is contained in:
commit
ea42f3cfd7
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue