1
Fork 0

compiler: use addr_of!

This commit is contained in:
Pavel Grigorenko 2024-02-24 16:47:34 +03:00
parent ff187a92d8
commit 613cb3262d
No known key found for this signature in database
GPG key ID: 52BFCC6ED389F777
7 changed files with 9 additions and 9 deletions

View file

@ -429,7 +429,7 @@ impl<T> RwLock<T> {
#[inline(always)]
pub fn leak(&self) -> &T {
let guard = self.read();
let ret = unsafe { &*(&*guard as *const T) };
let ret = unsafe { &*std::ptr::addr_of!(*guard) };
std::mem::forget(guard);
ret
}