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