rust: enable clippy::ptr_cast_constness

Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Paolo Bonzini 2025-02-14 11:34:44 +01:00
parent 3a1c694d74
commit 5df3fe062f
7 changed files with 7 additions and 9 deletions

View file

@ -1016,7 +1016,7 @@ impl<T> Opaque<T> {
/// Returns a raw pointer to the opaque data.
pub const fn as_ptr(&self) -> *const T {
self.as_mut_ptr() as *const _
self.as_mut_ptr().cast_const()
}
/// Returns a raw pointer to the opaque data that can be passed to a

View file

@ -160,7 +160,7 @@ impl CharBackend {
receive_cb,
event_cb,
None,
(owner as *const T as *mut T).cast::<c_void>(),
(owner as *const T).cast_mut().cast::<c_void>(),
core::ptr::null_mut(),
true,
);

View file

@ -388,7 +388,7 @@ where
{
#[allow(clippy::as_ptr_cast_mut)]
{
self.as_ptr::<U>() as *mut _
self.as_ptr::<U>().cast_mut()
}
}
}
@ -638,7 +638,7 @@ impl<T: ObjectType> Owned<T> {
// SAFETY NOTE: while NonNull requires a mutable pointer, only
// Deref is implemented so the pointer passed to from_raw
// remains const
Owned(NonNull::new(ptr as *mut T).unwrap())
Owned(NonNull::new(ptr.cast_mut()).unwrap())
}
/// Obtain a raw C pointer from a reference. `src` is consumed

View file

@ -81,7 +81,7 @@ impl Timer {
scale as c_int,
attributes as c_int,
Some(timer_cb),
(opaque as *const T).cast::<c_void>() as *mut c_void,
(opaque as *const T).cast::<c_void>().cast_mut(),
)
}
}