Skip to content

Commit

Permalink
Fix clippy unnecessary-cast warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Emanuele Giaquinta <[email protected]>
  • Loading branch information
exg committed Sep 24, 2023
1 parent 6447cf9 commit b01be5d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/serialize/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ impl Serialize for DefaultSerializer {
if unlikely!(self.default_calls == RECURSION_LIMIT) {
err!("default serializer exceeds recursion limit")
}
#[allow(clippy::unnecessary_cast)]
let default_obj = ffi!(PyObject_CallFunctionObjArgs(
callable.as_ptr(),
self.ptr,
Expand Down
8 changes: 4 additions & 4 deletions src/serialize/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl BytesWriter {
self.cap = len;
unsafe {
_PyBytes_Resize(
std::ptr::addr_of_mut!(self.bytes) as *mut *mut PyBytesObject as *mut *mut PyObject,
std::ptr::addr_of_mut!(self.bytes) as *mut *mut PyObject,
len as isize,
);
}
Expand Down Expand Up @@ -82,7 +82,7 @@ impl std::io::Write for BytesWriter {
self.grow(end_length);
}
unsafe {
std::ptr::copy_nonoverlapping(buf.as_ptr() as *const u8, self.buffer_ptr(), to_write);
std::ptr::copy_nonoverlapping(buf.as_ptr(), self.buffer_ptr(), to_write);
};
self.len = end_length;
Ok(())
Expand Down Expand Up @@ -174,7 +174,7 @@ impl WriteExt for &mut BytesWriter {
unsafe {
let ptr = self.buffer_ptr();
std::ptr::write(ptr, b'"');
std::ptr::copy_nonoverlapping(val.as_ptr() as *const u8, ptr.add(1), to_write);
std::ptr::copy_nonoverlapping(val.as_ptr(), ptr.add(1), to_write);
std::ptr::write(ptr.add(to_write + 1), b'"');
};
self.len = end_length;
Expand All @@ -187,7 +187,7 @@ impl WriteExt for &mut BytesWriter {
) -> std::result::Result<(), std::io::Error> {
let to_write = val.len();
unsafe {
std::ptr::copy_nonoverlapping(val.as_ptr() as *const u8, self.buffer_ptr(), to_write);
std::ptr::copy_nonoverlapping(val.as_ptr(), self.buffer_ptr(), to_write);
};
self.len += to_write;
Ok(())
Expand Down

0 comments on commit b01be5d

Please sign in to comment.