diff --git a/src/backtrace/dbghelp.rs b/src/backtrace/dbghelp.rs index d1b76e28..e0631100 100644 --- a/src/backtrace/dbghelp.rs +++ b/src/backtrace/dbghelp.rs @@ -162,7 +162,7 @@ pub unsafe fn trace(cb: &mut dyn FnMut(&super::Frame) -> bool) { context.ip(), fn_entry, &mut context.0, - &mut handler_data as *mut usize as *mut PVOID, + core::ptr::addr_of_mut!(handler_data) as *mut PVOID, &mut establisher_frame, ptr::null_mut(), ); @@ -215,7 +215,7 @@ pub unsafe fn trace(cb: &mut dyn FnMut(&super::Frame) -> bool) { process, thread, &mut stack_frame_ex, - &mut context.0 as *mut CONTEXT as PVOID, + core::ptr::addr_of_mut!(context.0) as PVOID, None, Some(function_table_access), Some(get_module_base), @@ -253,7 +253,7 @@ pub unsafe fn trace(cb: &mut dyn FnMut(&super::Frame) -> bool) { process, thread, &mut stack_frame64, - &mut context.0 as *mut CONTEXT as PVOID, + core::ptr::addr_of_mut!(context.0) as PVOID, None, Some(function_table_access), Some(get_module_base), diff --git a/src/backtrace/libunwind.rs b/src/backtrace/libunwind.rs index 0cf6365f..ee2a8bde 100644 --- a/src/backtrace/libunwind.rs +++ b/src/backtrace/libunwind.rs @@ -101,7 +101,7 @@ impl Clone for Frame { #[inline(always)] pub unsafe fn trace(mut cb: &mut dyn FnMut(&super::Frame) -> bool) { - uw::_Unwind_Backtrace(trace_fn, &mut cb as *mut _ as *mut _); + uw::_Unwind_Backtrace(trace_fn, core::ptr::addr_of_mut!(cb) as *mut _); extern "C" fn trace_fn( ctx: *mut uw::_Unwind_Context, @@ -242,7 +242,7 @@ mod uw { pub unsafe fn _Unwind_GetIP(ctx: *mut _Unwind_Context) -> libc::uintptr_t { let mut val: _Unwind_Word = 0; - let ptr = &mut val as *mut _Unwind_Word; + let ptr = core::ptr::addr_of_mut!(val); let _ = _Unwind_VRS_Get( ctx, _Unwind_VRS_RegClass::_UVRSC_CORE, @@ -258,7 +258,7 @@ mod uw { pub unsafe fn get_sp(ctx: *mut _Unwind_Context) -> libc::uintptr_t { let mut val: _Unwind_Word = 0; - let ptr = &mut val as *mut _Unwind_Word; + let ptr = core::ptr::addr_of_mut!(val); let _ = _Unwind_VRS_Get( ctx, _Unwind_VRS_RegClass::_UVRSC_CORE, diff --git a/src/symbolize/dbghelp.rs b/src/symbolize/dbghelp.rs index 8c47d58e..1e6295f3 100644 --- a/src/symbolize/dbghelp.rs +++ b/src/symbolize/dbghelp.rs @@ -222,7 +222,7 @@ unsafe fn do_resolve( } } } - let name = &name_buffer[..name_len] as *const [u8]; + let name = core::ptr::addr_of!(name_buffer[..name_len]); let mut line = mem::zeroed::(); line.SizeOfStruct = mem::size_of::() as DWORD; diff --git a/src/symbolize/gimli/libs_dl_iterate_phdr.rs b/src/symbolize/gimli/libs_dl_iterate_phdr.rs index 518512ff..9fcc8161 100644 --- a/src/symbolize/gimli/libs_dl_iterate_phdr.rs +++ b/src/symbolize/gimli/libs_dl_iterate_phdr.rs @@ -12,7 +12,7 @@ use core::slice; pub(super) fn native_libraries() -> Vec { let mut ret = Vec::new(); unsafe { - libc::dl_iterate_phdr(Some(callback), &mut ret as *mut Vec<_> as *mut _); + libc::dl_iterate_phdr(Some(callback), core::ptr::addr_of_mut!(ret) as *mut _); } return ret; } diff --git a/src/symbolize/gimli/libs_illumos.rs b/src/symbolize/gimli/libs_illumos.rs index e64975e0..7da16c6d 100644 --- a/src/symbolize/gimli/libs_illumos.rs +++ b/src/symbolize/gimli/libs_illumos.rs @@ -41,7 +41,7 @@ pub(super) fn native_libraries() -> Vec { if dlinfo( RTLD_SELF, RTLD_DI_LINKMAP, - (&mut map) as *mut *const LinkMap as *mut libc::c_void, + core::ptr::addr_of_mut!(map) as *mut libc::c_void, ) != 0 { return libs;