Merge pull request #1520 from messense/clippy
Fix clippy warnings in Rust 1.51.0
This commit is contained in:
commit
d9fe4ec6cc
|
@ -10,12 +10,16 @@ use std::os::raw::{c_int, c_void};
|
|||
pub struct PyTraverseError(c_int);
|
||||
|
||||
/// GC support
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
pub trait PyGCProtocol<'p>: PyClass {
|
||||
fn __traverse__(&'p self, visit: PyVisit) -> Result<(), PyTraverseError>;
|
||||
fn __clear__(&'p mut self);
|
||||
}
|
||||
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
pub trait PyGCTraverseProtocol<'p>: PyGCProtocol<'p> {}
|
||||
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
pub trait PyGCClearProtocol<'p>: PyGCProtocol<'p> {}
|
||||
|
||||
#[doc(hidden)]
|
||||
|
|
|
@ -140,6 +140,7 @@ methods_trait!(PyMethods, py_methods);
|
|||
|
||||
macro_rules! slots_trait {
|
||||
($name:ident, $function_name: ident) => {
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
pub trait $name<T> {
|
||||
fn $function_name(self) -> &'static [ffi::PyType_Slot];
|
||||
}
|
||||
|
|
|
@ -162,6 +162,7 @@ macro_rules! py_binary_self_func {
|
|||
$crate::callback_body!(py, {
|
||||
let slf_ = py.from_borrowed_ptr::<$crate::PyCell<T>>(slf);
|
||||
let arg = py.from_borrowed_ptr::<$crate::PyAny>(arg);
|
||||
#[allow(clippy::needless_question_mark)]
|
||||
call_operator_mut!(py, slf_, $f, arg).convert(py)?;
|
||||
ffi::Py_INCREF(slf);
|
||||
Ok::<_, $crate::err::PyErr>(slf)
|
||||
|
|
|
@ -446,11 +446,13 @@ pub trait PyNumberRPowProtocol<'p>: PyNumberProtocol<'p> {
|
|||
type Result: IntoPyCallbackOutput<PyObject>;
|
||||
}
|
||||
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
pub trait PyNumberRLShiftProtocol<'p>: PyNumberProtocol<'p> {
|
||||
type Other: FromPyObject<'p>;
|
||||
type Result: IntoPyCallbackOutput<PyObject>;
|
||||
}
|
||||
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
pub trait PyNumberRRShiftProtocol<'p>: PyNumberProtocol<'p> {
|
||||
type Other: FromPyObject<'p>;
|
||||
type Result: IntoPyCallbackOutput<PyObject>;
|
||||
|
@ -516,11 +518,13 @@ pub trait PyNumberIPowProtocol<'p>: PyNumberProtocol<'p> {
|
|||
type Result: IntoPyCallbackOutput<()>;
|
||||
}
|
||||
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
pub trait PyNumberILShiftProtocol<'p>: PyNumberProtocol<'p> {
|
||||
type Other: FromPyObject<'p>;
|
||||
type Result: IntoPyCallbackOutput<()>;
|
||||
}
|
||||
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
pub trait PyNumberIRShiftProtocol<'p>: PyNumberProtocol<'p> {
|
||||
type Other: FromPyObject<'p>;
|
||||
type Result: IntoPyCallbackOutput<()>;
|
||||
|
@ -738,6 +742,7 @@ where
|
|||
crate::callback_body!(py, {
|
||||
let slf_cell = py.from_borrowed_ptr::<crate::PyCell<T>>(slf);
|
||||
let other = py.from_borrowed_ptr::<crate::PyAny>(other);
|
||||
#[allow(clippy::needless_question_mark)]
|
||||
call_operator_mut!(py, slf_cell, __ipow__, other).convert(py)?;
|
||||
ffi::Py_INCREF(slf);
|
||||
Ok::<_, PyErr>(slf)
|
||||
|
|
|
@ -197,6 +197,7 @@ macro_rules! create_exception_type_object {
|
|||
|
||||
macro_rules! impl_native_exception (
|
||||
($name:ident, $exc_name:ident, $layout:path) => (
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
pub struct $name($crate::PyAny);
|
||||
|
||||
$crate::impl_exception_boilerplate!($name);
|
||||
|
|
|
@ -365,14 +365,12 @@ pub struct PyDateTime_CAPI {
|
|||
pub TZInfoType: *mut PyTypeObject,
|
||||
#[cfg(all(Py_3_7, not(PyPy)))]
|
||||
pub TimeZone_UTC: *mut PyObject,
|
||||
#[cfg_attr(PyPy, link_name = "_PyPyDate_FromDate")]
|
||||
pub Date_FromDate: unsafe extern "C" fn(
|
||||
year: c_int,
|
||||
month: c_int,
|
||||
day: c_int,
|
||||
cls: *mut PyTypeObject,
|
||||
) -> *mut PyObject,
|
||||
#[cfg_attr(PyPy, link_name = "_PyPyDateTime_FromDateAndTime")]
|
||||
pub DateTime_FromDateAndTime: unsafe extern "C" fn(
|
||||
year: c_int,
|
||||
month: c_int,
|
||||
|
@ -384,7 +382,6 @@ pub struct PyDateTime_CAPI {
|
|||
tzinfo: *mut PyObject,
|
||||
cls: *mut PyTypeObject,
|
||||
) -> *mut PyObject,
|
||||
#[cfg_attr(PyPy, link_name = "_PyPyTime_FromTime")]
|
||||
pub Time_FromTime: unsafe extern "C" fn(
|
||||
hour: c_int,
|
||||
minute: c_int,
|
||||
|
@ -393,7 +390,6 @@ pub struct PyDateTime_CAPI {
|
|||
tzinfo: *mut PyObject,
|
||||
cls: *mut PyTypeObject,
|
||||
) -> *mut PyObject,
|
||||
#[cfg_attr(PyPy, link_name = "_PyPyDelta_FromDelta")]
|
||||
pub Delta_FromDelta: unsafe extern "C" fn(
|
||||
days: c_int,
|
||||
seconds: c_int,
|
||||
|
|
|
@ -193,6 +193,7 @@ where
|
|||
/// let py = gil_guard.python();
|
||||
/// } // GIL is released when gil_guard is dropped
|
||||
/// ```
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
#[must_use]
|
||||
pub struct GILGuard {
|
||||
gstate: ffi::PyGILState_STATE,
|
||||
|
@ -367,6 +368,7 @@ unsafe impl Sync for ReferencePool {}
|
|||
static POOL: ReferencePool = ReferencePool::new();
|
||||
|
||||
/// A RAII pool which PyO3 uses to store owned Python references.
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
pub struct GILPool {
|
||||
/// Initial length of owned objects and anys.
|
||||
/// `Option` is used since TSL can be broken when `new` is called from `atexit`.
|
||||
|
@ -495,6 +497,7 @@ pub(crate) fn ensure_gil() -> EnsureGIL {
|
|||
}
|
||||
|
||||
/// Struct used internally which avoids acquiring the GIL where it's not necessary.
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
pub(crate) struct EnsureGIL(Option<GILGuard>);
|
||||
|
||||
impl EnsureGIL {
|
||||
|
|
|
@ -191,7 +191,7 @@ pub mod derive_utils;
|
|||
mod err;
|
||||
pub mod exceptions;
|
||||
/// Raw ffi declarations for the c interface of python
|
||||
#[allow(clippy::unknown_clippy_lints)]
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
#[allow(clippy::missing_safety_doc)]
|
||||
pub mod ffi;
|
||||
pub mod freelist;
|
||||
|
|
|
@ -27,6 +27,7 @@ use std::cell::UnsafeCell;
|
|||
/// }
|
||||
/// # Python::with_gil(|py| assert_eq!(get_shared_list(py).len(), 0));
|
||||
/// ```
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
pub struct GILOnceCell<T>(UnsafeCell<Option<T>>);
|
||||
|
||||
// T: Send is needed for Sync because the thread which drops the GILOnceCell can be different
|
||||
|
|
|
@ -82,13 +82,13 @@ fn data_is_dropped() {
|
|||
|
||||
#[allow(dead_code)]
|
||||
#[pyclass]
|
||||
struct GCIntegration {
|
||||
struct GcIntegration {
|
||||
self_ref: PyObject,
|
||||
dropped: TestDropCall,
|
||||
}
|
||||
|
||||
#[pyproto]
|
||||
impl PyGCProtocol for GCIntegration {
|
||||
impl PyGCProtocol for GcIntegration {
|
||||
fn __traverse__(&self, visit: PyVisit) -> Result<(), PyTraverseError> {
|
||||
visit.call(&self.self_ref)
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ fn gc_integration() {
|
|||
let py = gil.python();
|
||||
let inst = PyCell::new(
|
||||
py,
|
||||
GCIntegration {
|
||||
GcIntegration {
|
||||
self_ref: py.None(),
|
||||
dropped: TestDropCall {
|
||||
drop_called: Arc::clone(&drop_called),
|
||||
|
@ -128,10 +128,10 @@ fn gc_integration() {
|
|||
}
|
||||
|
||||
#[pyclass(gc)]
|
||||
struct GCIntegration2 {}
|
||||
struct GcIntegration2 {}
|
||||
|
||||
#[pyproto]
|
||||
impl PyGCProtocol for GCIntegration2 {
|
||||
impl PyGCProtocol for GcIntegration2 {
|
||||
fn __traverse__(&self, _visit: PyVisit) -> Result<(), PyTraverseError> {
|
||||
Ok(())
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ impl PyGCProtocol for GCIntegration2 {
|
|||
fn gc_integration2() {
|
||||
let gil = Python::acquire_gil();
|
||||
let py = gil.python();
|
||||
let inst = PyCell::new(py, GCIntegration2 {}).unwrap();
|
||||
let inst = PyCell::new(py, GcIntegration2 {}).unwrap();
|
||||
py_run!(py, inst, "import gc; assert inst in gc.get_objects()");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue