Make Clippy happy again by removing supposedly unnecessary casts.

This commit is contained in:
Adam Reichold 2022-11-15 21:50:29 +01:00
parent d060a19303
commit 694ef1ea39
4 changed files with 10 additions and 16 deletions

View file

@ -24,14 +24,14 @@ pub struct PyListObject {
#[inline]
#[cfg(not(PyPy))]
pub unsafe fn PyList_GET_ITEM(op: *mut PyObject, i: Py_ssize_t) -> *mut PyObject {
*(*(op as *mut PyListObject)).ob_item.offset(i as isize)
*(*(op as *mut PyListObject)).ob_item.offset(i)
}
/// Macro, *only* to be used to fill in brand new lists
#[inline]
#[cfg(not(PyPy))]
pub unsafe fn PyList_SET_ITEM(op: *mut PyObject, i: Py_ssize_t, v: *mut PyObject) {
*(*(op as *mut PyListObject)).ob_item.offset(i as isize) = v;
*(*(op as *mut PyListObject)).ob_item.offset(i) = v;
}
#[inline]

View file

@ -24,20 +24,14 @@ pub unsafe fn PyTuple_GET_SIZE(op: *mut PyObject) -> Py_ssize_t {
#[inline]
#[cfg(not(PyPy))]
pub unsafe fn PyTuple_GET_ITEM(op: *mut PyObject, i: Py_ssize_t) -> *mut PyObject {
*(*(op as *mut PyTupleObject))
.ob_item
.as_ptr()
.offset(i as isize)
*(*(op as *mut PyTupleObject)).ob_item.as_ptr().offset(i)
}
/// Macro, *only* to be used to fill in brand new tuples
#[inline]
#[cfg(not(PyPy))]
pub unsafe fn PyTuple_SET_ITEM(op: *mut PyObject, i: Py_ssize_t, v: *mut PyObject) {
*(*(op as *mut PyTupleObject))
.ob_item
.as_mut_ptr()
.offset(i as isize) = v;
*(*(op as *mut PyTupleObject)).ob_item.as_mut_ptr().offset(i) = v;
}
// skipped _PyTuple_DebugMallocStats

View file

@ -107,6 +107,6 @@ pub unsafe fn PyType_SUPPORTS_WEAKREFS(t: *mut PyTypeObject) -> c_int {
#[inline]
#[cfg(not(Py_LIMITED_API))]
pub unsafe fn PyObject_GET_WEAKREFS_LISTPTR(o: *mut PyObject) -> *mut *mut PyObject {
let weaklistoffset = (*Py_TYPE(o)).tp_weaklistoffset as isize;
let weaklistoffset = (*Py_TYPE(o)).tp_weaklistoffset;
o.offset(weaklistoffset) as *mut *mut PyObject
}

View file

@ -210,7 +210,7 @@ impl PyDate {
impl PyDateAccess for PyDate {
fn get_year(&self) -> i32 {
unsafe { PyDateTime_GET_YEAR(self.as_ptr()) as i32 }
unsafe { PyDateTime_GET_YEAR(self.as_ptr()) }
}
fn get_month(&self) -> u8 {
@ -324,7 +324,7 @@ impl PyDateTime {
impl PyDateAccess for PyDateTime {
fn get_year(&self) -> i32 {
unsafe { PyDateTime_GET_YEAR(self.as_ptr()) as i32 }
unsafe { PyDateTime_GET_YEAR(self.as_ptr()) }
}
fn get_month(&self) -> u8 {
@ -523,15 +523,15 @@ impl PyDelta {
impl PyDeltaAccess for PyDelta {
fn get_days(&self) -> i32 {
unsafe { PyDateTime_DELTA_GET_DAYS(self.as_ptr()) as i32 }
unsafe { PyDateTime_DELTA_GET_DAYS(self.as_ptr()) }
}
fn get_seconds(&self) -> i32 {
unsafe { PyDateTime_DELTA_GET_SECONDS(self.as_ptr()) as i32 }
unsafe { PyDateTime_DELTA_GET_SECONDS(self.as_ptr()) }
}
fn get_microseconds(&self) -> i32 {
unsafe { PyDateTime_DELTA_GET_MICROSECONDS(self.as_ptr()) as i32 }
unsafe { PyDateTime_DELTA_GET_MICROSECONDS(self.as_ptr()) }
}
}