From faa21f48c7629a57cf0563d6f8a500acd9dd84d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Niederb=C3=BChl?= Date: Sun, 14 Jul 2019 22:02:01 +0200 Subject: [PATCH] Fix some clippy lints --- pyo3-derive-backend/src/pyproto.rs | 4 ++-- src/class/basic.rs | 4 ++-- src/types/tuple.rs | 7 ++----- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/pyo3-derive-backend/src/pyproto.rs b/pyo3-derive-backend/src/pyproto.rs index f33193e8..a80da75c 100644 --- a/pyo3-derive-backend/src/pyproto.rs +++ b/pyo3-derive-backend/src/pyproto.rs @@ -47,10 +47,10 @@ pub fn build_py_proto(ast: &mut syn::ItemImpl) -> syn::Result { Ok(tokens) } else { - return Err(syn::Error::new_spanned( + Err(syn::Error::new_spanned( ast, "#[pyproto] can only be used with protocol trait implementations", - )); + )) } } diff --git a/src/class/basic.rs b/src/class/basic.rs index a23c2718..cc300535 100644 --- a/src/class/basic.rs +++ b/src/class/basic.rs @@ -221,7 +221,7 @@ where // Behave like python's __getattr__ (as opposed to __getattribute__) and check // for existing fields and methods first let existing = ffi::PyObject_GenericGetAttr(slf, arg); - if existing == std::ptr::null_mut() { + if existing.is_null() { // PyObject_HasAttr also tries to get an object and clears the error if it fails ffi::PyErr_Clear(); } else { @@ -233,7 +233,7 @@ where let result = match arg.extract() { Ok(arg) => slf.__getattr__(arg).into(), - Err(e) => Err(e.into()), + Err(e) => Err(e), }; crate::callback::cb_convert(PyObjectCallbackConverter, py, result) } diff --git a/src/types/tuple.rs b/src/types/tuple.rs index 9e259d1a..26ac3c0f 100644 --- a/src/types/tuple.rs +++ b/src/types/tuple.rs @@ -21,10 +21,7 @@ pyobject_native_type!(PyTuple, ffi::PyTuple_Type, ffi::PyTuple_Check); impl PyTuple { /// Construct a new tuple with the given elements. - pub fn new<'p, T, U>( - py: Python<'p>, - elements: impl IntoIterator, - ) -> &'p PyTuple + pub fn new(py: Python, elements: impl IntoIterator) -> &PyTuple where T: ToPyObject, U: ExactSizeIterator, @@ -41,7 +38,7 @@ impl PyTuple { } /// Retrieves the empty tuple. - pub fn empty<'p>(py: Python<'p>) -> &'p PyTuple { + pub fn empty(py: Python) -> &PyTuple { unsafe { py.from_owned_ptr(ffi::PyTuple_New(0)) } }