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] #[inline]
#[cfg(not(PyPy))] #[cfg(not(PyPy))]
pub unsafe fn PyList_GET_ITEM(op: *mut PyObject, i: Py_ssize_t) -> *mut PyObject { 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 /// Macro, *only* to be used to fill in brand new lists
#[inline] #[inline]
#[cfg(not(PyPy))] #[cfg(not(PyPy))]
pub unsafe fn PyList_SET_ITEM(op: *mut PyObject, i: Py_ssize_t, v: *mut PyObject) { 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] #[inline]

View File

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

View File

@ -107,6 +107,6 @@ pub unsafe fn PyType_SUPPORTS_WEAKREFS(t: *mut PyTypeObject) -> c_int {
#[inline] #[inline]
#[cfg(not(Py_LIMITED_API))] #[cfg(not(Py_LIMITED_API))]
pub unsafe fn PyObject_GET_WEAKREFS_LISTPTR(o: *mut PyObject) -> *mut *mut PyObject { 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 o.offset(weaklistoffset) as *mut *mut PyObject
} }

View File

@ -210,7 +210,7 @@ impl PyDate {
impl PyDateAccess for PyDate { impl PyDateAccess for PyDate {
fn get_year(&self) -> i32 { 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 { fn get_month(&self) -> u8 {
@ -324,7 +324,7 @@ impl PyDateTime {
impl PyDateAccess for PyDateTime { impl PyDateAccess for PyDateTime {
fn get_year(&self) -> i32 { 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 { fn get_month(&self) -> u8 {
@ -523,15 +523,15 @@ impl PyDelta {
impl PyDeltaAccess for PyDelta { impl PyDeltaAccess for PyDelta {
fn get_days(&self) -> i32 { 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 { 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 { fn get_microseconds(&self) -> i32 {
unsafe { PyDateTime_DELTA_GET_MICROSECONDS(self.as_ptr()) as i32 } unsafe { PyDateTime_DELTA_GET_MICROSECONDS(self.as_ptr()) }
} }
} }