Make clippy happy

This commit is contained in:
konstin 2018-11-14 16:49:48 +01:00
parent 0890f24391
commit 5f175a41cf
11 changed files with 17 additions and 13 deletions

View File

@ -54,6 +54,7 @@ where
T: PyBufferProtocol<'p>,
{
#[inline]
#[allow(clippy::needless_update)] // For python 2 it's not useless
fn tp_as_buffer() -> Option<ffi::PyBufferProcs> {
Some(ffi::PyBufferProcs {
bf_getbuffer: Self::cb_bf_getbuffer(),

View File

@ -1,4 +1,4 @@
#![cfg_attr(feature = "cargo-clippy", allow(type_complexity))]
#![cfg_attr(feature = "cargo-clippy", allow(clippy::type_complexity))]
//! FFI bindings to the functions and structs defined in `datetime.h`
//!

View File

@ -5,10 +5,10 @@ use std::os::raw::{
c_char, c_double, c_int, c_long, c_longlong, c_uchar, c_ulong, c_ulonglong, c_void,
};
/// In the python doc this opaque, but we know we can cast, so we make clippy happy by telling
/// it that it actually looks like a PyObject
#[repr(C)]
pub struct PyLongObject {
_private: [u8; 0],
}
pub struct PyLongObject(PyObject);
#[cfg_attr(windows, link(name = "pythonXY"))]
extern "C" {

View File

@ -1,7 +1,7 @@
//! Rust FFI declarations for Python 3
#![allow(non_camel_case_types, non_snake_case, non_upper_case_globals)]
#![cfg_attr(Py_LIMITED_API, allow(unused_imports))]
#![cfg_attr(feature="cargo-clippy", allow(inline_always))]
#![cfg_attr(feature="cargo-clippy", allow(clippy::inline_always))]
pub use self::pymem::*;
pub use self::pyport::*;

View File

@ -176,7 +176,7 @@ impl PyObject {
/// Calls the object.
/// This is equivalent to the Python expression: 'self(*args, **kwargs)'
pub fn call<A>(&self, py: Python, args: A, kwargs: Option<PyDict>) -> PyResult<PyObject>
pub fn call<A>(&self, py: Python, args: A, kwargs: Option<&PyDict>) -> PyResult<PyObject>
where
A: IntoPyTuple,
{

View File

@ -85,7 +85,7 @@ pub const PY_TYPE_FLAG_DICT: usize = 1 << 3;
/// impl MyClass {
/// #[new]
/// fn __new__(obj: &PyRawObject) -> PyResult<()> {
/// obj.init(|| MyClass { })
/// obj.init(|| MyClass { })
/// }
/// }
/// ```
@ -149,7 +149,7 @@ impl PyRawObject {
let value = f();
unsafe {
let ptr = (self.ptr as *mut u8).offset(T::OFFSET) as *mut T;
let ptr = self.ptr.offset(T::OFFSET) as *mut T;
std::ptr::write(ptr, value);
}
Ok(())

View File

@ -14,7 +14,7 @@ pyobject_native_type!(PyComplex, ffi::PyComplex_Type, ffi::PyComplex_Check);
impl PyComplex {
/// Creates a new Python `PyComplex` object, from its real and imaginary values.
pub fn from_doubles<'p>(py: Python<'p>, real: c_double, imag: c_double) -> &'p PyComplex {
pub fn from_doubles(py: Python, real: c_double, imag: c_double) -> &PyComplex {
unsafe {
let ptr = ffi::PyComplex_FromDoubles(real, imag);
py.from_owned_ptr(ptr)

View File

@ -2,6 +2,9 @@
//!
//! For more details about these types, see the [Python
//! documentation](https://docs.python.org/3/library/datetime.html)
#![allow(clippy::too_many_arguments)]
use crate::conversion::ToPyObject;
use crate::err::PyResult;
use crate::ffi;

View File

@ -51,7 +51,7 @@ impl IntoPyObject for f64 {
impl<'source> FromPyObject<'source> for f64 {
// PyFloat_AsDouble returns -1.0 upon failure
#![cfg_attr(feature = "cargo-clippy", allow(float_cmp))]
#![cfg_attr(feature = "cargo-clippy", allow(clippy::float_cmp))]
fn extract(obj: &'source PyObjectRef) -> PyResult<Self> {
let v = unsafe { ffi::PyFloat_AsDouble(obj.as_ptr()) };

View File

@ -30,7 +30,7 @@ pyobject_native_type!(PyLong, ffi::PyLong_Type, ffi::PyLong_Check);
macro_rules! int_fits_c_long (
($rust_type:ty) => (
impl ToPyObject for $rust_type {
#![cfg_attr(feature="cargo-clippy", allow(cast_lossless))]
#![cfg_attr(feature="cargo-clippy", allow(clippy::cast_lossless))]
fn to_object(&self, py: Python) -> PyObject {
unsafe {
PyObject::from_owned_ptr_or_panic(py, ffi::PyLong_FromLong(*self as c_long))
@ -38,7 +38,7 @@ macro_rules! int_fits_c_long (
}
}
impl IntoPyObject for $rust_type {
#![cfg_attr(feature="cargo-clippy", allow(cast_lossless))]
#![cfg_attr(feature="cargo-clippy", allow(clippy::cast_lossless))]
fn into_object(self, py: Python) -> PyObject {
unsafe {
PyObject::from_owned_ptr_or_panic(py, ffi::PyLong_FromLong(self as c_long))

View File

@ -5,7 +5,7 @@ use std::os::raw::c_int;
use crate::err::{PyErr, PyResult};
use crate::python::Python;
pub(super) fn err_if_invalid_value<T: PartialEq>(
pub(super) fn err_if_invalid_value<T: PartialEq + Copy>(
py: Python,
invalid_value: T,
actual_value: T,