mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-25 00:00:18 +02:00
util: use <ptr>::addr instead of unsafe impl (#7725)
This commit is contained in:
@@ -30,9 +30,7 @@ impl<T> PtrExposeDomain<T> {
|
||||
pub(crate) fn expose_provenance(&self, ptr: *const T) -> usize {
|
||||
#[cfg(miri)]
|
||||
{
|
||||
// FIXME: Use `pointer:addr` when it is stable.
|
||||
// SAFETY: Equivalent to `pointer::addr` which is safe.
|
||||
let addr: usize = unsafe { std::mem::transmute(ptr) };
|
||||
let addr: usize = ptr.addr();
|
||||
self.map.lock().insert(addr, ptr);
|
||||
addr
|
||||
}
|
||||
@@ -65,8 +63,7 @@ impl<T> PtrExposeDomain<T> {
|
||||
pub(crate) fn unexpose_provenance(&self, _ptr: *const T) {
|
||||
#[cfg(miri)]
|
||||
{
|
||||
// SAFETY: Equivalent to `pointer::addr` which is safe.
|
||||
let addr: usize = unsafe { std::mem::transmute(_ptr) };
|
||||
let addr: usize = _ptr.addr();
|
||||
let maybe_ptr = self.map.lock().remove(&addr);
|
||||
|
||||
// SAFETY: Intentionally trigger a miri failure if the provenance we want is not
|
||||
|
||||
Reference in New Issue
Block a user