Fix clippy errors
This commit is contained in:
parent
43eb5fa490
commit
28d6c9986c
|
@ -91,7 +91,7 @@ impl<T> PyGCTraverseProtocolImpl for T where T: for<'p> PyGCTraverseProtocol<'p>
|
|||
let py = Python::assume_gil_acquired();
|
||||
let slf = py.mut_from_borrowed_ptr::<T>(slf);
|
||||
|
||||
let visit = PyVisit { visit: visit, arg: arg, _py: py };
|
||||
let visit = PyVisit { visit, arg, _py: py };
|
||||
match slf.__traverse__(visit) {
|
||||
Ok(()) => 0,
|
||||
Err(PyTraverseError(code)) => code
|
||||
|
|
|
@ -26,7 +26,6 @@ pub trait ToBorrowedObject: ToPyObject {
|
|||
///
|
||||
/// May be more efficient than `to_object` because it does not need
|
||||
/// to touch any reference counts when the input object already is a Python object.
|
||||
#[inline]
|
||||
fn with_borrowed_ptr<F, R>(&self, py: Python, f: F) -> R
|
||||
where F: FnOnce(*mut ffi::PyObject) -> R;
|
||||
}
|
||||
|
|
10
src/err.rs
10
src/err.rs
|
@ -286,13 +286,15 @@ impl PyErr {
|
|||
PyErrValue::None
|
||||
};
|
||||
|
||||
PyErr {
|
||||
ptype: if ptype.is_null() {
|
||||
let ptype = if ptype.is_null() {
|
||||
<exc::SystemError as PyTypeObject>::type_object()
|
||||
} else {
|
||||
Py::from_owned_ptr(ptype)
|
||||
},
|
||||
pvalue: pvalue,
|
||||
};
|
||||
|
||||
PyErr {
|
||||
ptype,
|
||||
pvalue,
|
||||
ptraceback: PyObject::from_owned_ptr_or_opt(Python::assume_gil_acquired(), ptraceback),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,9 +35,9 @@ impl<T> FreeList<T> {
|
|||
let entries = (0..capacity).map(|_| Slot::Empty).collect::<Vec<_>>();
|
||||
|
||||
FreeList {
|
||||
entries: entries,
|
||||
entries,
|
||||
split: 0,
|
||||
capacity: capacity,
|
||||
capacity,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ macro_rules! pyobject_downcast(
|
|||
{
|
||||
unsafe {
|
||||
if $crate::ffi::$checkfunction(ob.as_ptr()) != 0 {
|
||||
Ok($crate::std::mem::transmute(ob))
|
||||
Ok(&*(ob as *const $crate::objects::PyObjectRef as *const $name))
|
||||
} else {
|
||||
Err($crate::PyDowncastError.into())
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ macro_rules! pyobject_native_type_named(
|
|||
impl $crate::std::convert::AsRef<$crate::PyObjectRef> for $name {
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(useless_transmute))]
|
||||
fn as_ref(&self) -> &$crate::PyObjectRef {
|
||||
unsafe{$crate::std::mem::transmute(self)}
|
||||
unsafe{&*(self as *const $name as *const $crate::objects::PyObjectRef)}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ macro_rules! pyobject_native_type(
|
|||
|
||||
impl<'a> $crate::std::convert::From<&'a $name> for &'a $crate::PyObjectRef {
|
||||
fn from(ob: &'a $name) -> Self {
|
||||
unsafe{$crate::std::mem::transmute(ob)}
|
||||
unsafe{&*(ob as *const $name as *const $crate::objects::PyObjectRef)}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -28,9 +28,9 @@ pub struct PySliceIndices {
|
|||
impl PySliceIndices {
|
||||
pub fn new(start: isize, stop: isize, step: isize) -> PySliceIndices {
|
||||
PySliceIndices {
|
||||
start: start,
|
||||
stop: stop,
|
||||
step: step,
|
||||
start,
|
||||
stop,
|
||||
step,
|
||||
slicelength: 0,
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ impl PySlice {
|
|||
pub fn indices(&self, length: c_long) -> PyResult<PySliceIndices> {
|
||||
// non-negative Py_ssize_t should always fit into Rust usize
|
||||
unsafe {
|
||||
let slicelen: isize = 0;
|
||||
let slicelength: isize = 0;
|
||||
let start: isize = 0;
|
||||
let stop: isize = 0;
|
||||
let step: isize = 0;
|
||||
|
@ -63,13 +63,13 @@ impl PySlice {
|
|||
&start as *const _ as *mut _,
|
||||
&stop as *const _ as *mut _,
|
||||
&step as *const _ as *mut _,
|
||||
&slicelen as *const _ as *mut _);
|
||||
&slicelength as *const _ as *mut _);
|
||||
if r == 0{
|
||||
Ok(PySliceIndices {
|
||||
start: start,
|
||||
stop: stop,
|
||||
step: step,
|
||||
slicelength: slicelen,
|
||||
start,
|
||||
stop,
|
||||
step,
|
||||
slicelength,
|
||||
})
|
||||
} else {
|
||||
Err(PyErr::fetch(self.py()))
|
||||
|
|
|
@ -261,7 +261,7 @@ impl GILGuard {
|
|||
let pool: &'static mut ReleasePool = &mut *POOL;
|
||||
GILGuard { owned: pool.owned.len(),
|
||||
borrowed: pool.borrowed.len(),
|
||||
gstate: gstate,
|
||||
gstate,
|
||||
no_send: marker::PhantomData }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -141,9 +141,9 @@ impl PyRawObject {
|
|||
|
||||
if !ptr.is_null() {
|
||||
Ok(PyRawObject {
|
||||
ptr: ptr,
|
||||
tp_ptr: tp_ptr,
|
||||
curr_ptr: curr_ptr,
|
||||
ptr,
|
||||
tp_ptr,
|
||||
curr_ptr,
|
||||
// initialized: 0,
|
||||
})
|
||||
} else {
|
||||
|
@ -158,9 +158,9 @@ impl PyRawObject {
|
|||
curr_ptr: *mut ffi::PyTypeObject) -> PyResult<PyRawObject> {
|
||||
if !ptr.is_null() {
|
||||
Ok(PyRawObject {
|
||||
ptr: ptr,
|
||||
tp_ptr: tp_ptr,
|
||||
curr_ptr: curr_ptr,
|
||||
ptr,
|
||||
tp_ptr,
|
||||
curr_ptr,
|
||||
// initialized: 0,
|
||||
})
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue