ci: updates for Rust 1.78 (#4150)

* ci: updates for Rust 1.78

* ci: fix clippy

* restrict `invalid_pymethods_duplicates` to unlimited api with `full`
This commit is contained in:
Icxolu 2024-05-03 09:42:30 +02:00 committed by GitHub
parent 9a808c35c6
commit cd3f3ed67c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
26 changed files with 264 additions and 117 deletions

View File

@ -34,8 +34,8 @@ pub fn othermod(m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_class::<ModClass>()?;
m.add("USIZE_MIN", usize::min_value())?;
m.add("USIZE_MAX", usize::max_value())?;
m.add("USIZE_MIN", usize::MIN)?;
m.add("USIZE_MAX", usize::MAX)?;
Ok(())
}

View File

@ -145,12 +145,14 @@ impl PyTypeBuilder {
#[cfg(all(not(Py_3_9), not(Py_LIMITED_API)))]
ffi::Py_bf_getbuffer => {
// Safety: slot.pfunc is a valid function pointer
self.buffer_procs.bf_getbuffer = Some(std::mem::transmute(pfunc));
self.buffer_procs.bf_getbuffer =
Some(std::mem::transmute::<*mut T, ffi::getbufferproc>(pfunc));
}
#[cfg(all(not(Py_3_9), not(Py_LIMITED_API)))]
ffi::Py_bf_releasebuffer => {
// Safety: slot.pfunc is a valid function pointer
self.buffer_procs.bf_releasebuffer = Some(std::mem::transmute(pfunc));
self.buffer_procs.bf_releasebuffer =
Some(std::mem::transmute::<*mut T, ffi::releasebufferproc>(pfunc));
}
_ => {}
}

View File

@ -13,6 +13,8 @@ fn test_compile_errors() {
t.compile_fail("tests/ui/invalid_pyfunction_signatures.rs");
#[cfg(any(not(Py_LIMITED_API), Py_3_11))]
t.compile_fail("tests/ui/invalid_pymethods_buffer.rs");
// The output is not stable across abi3 / not abi3 and features
#[cfg(all(not(Py_LIMITED_API), feature = "full"))]
t.compile_fail("tests/ui/invalid_pymethods_duplicates.rs");
t.compile_fail("tests/ui/invalid_pymethod_enum.rs");
t.compile_fail("tests/ui/invalid_pymethod_names.rs");

View File

@ -1,12 +1,10 @@
error[E0277]: the trait bound `PyDict: PyClass` is not satisfied
error[E0277]: the trait bound `PyDict: PyClassBaseType` is not satisfied
--> tests/ui/abi3_nativetype_inheritance.rs:5:19
|
5 | #[pyclass(extends=PyDict)]
| ^^^^^^ the trait `PyClass` is not implemented for `PyDict`, which is required by `PyDict: PyClassBaseType`
|
= help: the following other types implement trait `PyClass`:
TestClass
pyo3::coroutine::Coroutine
= help: the trait `PyClassBaseType` is implemented for `PyAny`
= note: required for `PyDict` to implement `PyClassBaseType`
note: required by a bound in `PyClassImpl::BaseType`
--> src/impl_/pyclass.rs

View File

@ -1,18 +1,18 @@
use pyo3::prelude::*;
#[pyfunction]
fn invalid_attribute(#[pyo3(get)] param: String) {}
fn invalid_attribute(#[pyo3(get)] _param: String) {}
#[pyfunction]
fn from_py_with_no_value(#[pyo3(from_py_with)] param: String) {}
fn from_py_with_no_value(#[pyo3(from_py_with)] _param: String) {}
#[pyfunction]
fn from_py_with_string(#[pyo3("from_py_with")] param: String) {}
fn from_py_with_string(#[pyo3("from_py_with")] _param: String) {}
#[pyfunction]
fn from_py_with_value_not_a_string(#[pyo3(from_py_with = func)] param: String) {}
fn from_py_with_value_not_a_string(#[pyo3(from_py_with = func)] _param: String) {}
#[pyfunction]
fn from_py_with_repeated(#[pyo3(from_py_with = "func", from_py_with = "func")] param: String) {}
fn from_py_with_repeated(#[pyo3(from_py_with = "func", from_py_with = "func")] _param: String) {}
fn main() {}

View File

@ -1,29 +1,29 @@
error: expected `cancel_handle` or `from_py_with`
--> tests/ui/invalid_argument_attributes.rs:4:29
|
4 | fn invalid_attribute(#[pyo3(get)] param: String) {}
4 | fn invalid_attribute(#[pyo3(get)] _param: String) {}
| ^^^
error: expected `=`
--> tests/ui/invalid_argument_attributes.rs:7:45
|
7 | fn from_py_with_no_value(#[pyo3(from_py_with)] param: String) {}
7 | fn from_py_with_no_value(#[pyo3(from_py_with)] _param: String) {}
| ^
error: expected `cancel_handle` or `from_py_with`
--> tests/ui/invalid_argument_attributes.rs:10:31
|
10 | fn from_py_with_string(#[pyo3("from_py_with")] param: String) {}
10 | fn from_py_with_string(#[pyo3("from_py_with")] _param: String) {}
| ^^^^^^^^^^^^^^
error: expected string literal
--> tests/ui/invalid_argument_attributes.rs:13:58
|
13 | fn from_py_with_value_not_a_string(#[pyo3(from_py_with = func)] param: String) {}
13 | fn from_py_with_value_not_a_string(#[pyo3(from_py_with = func)] _param: String) {}
| ^^^^
error: `from_py_with` may only be specified once per argument
--> tests/ui/invalid_argument_attributes.rs:16:56
|
16 | fn from_py_with_repeated(#[pyo3(from_py_with = "func", from_py_with = "func")] param: String) {}
16 | fn from_py_with_repeated(#[pyo3(from_py_with = "func", from_py_with = "func")] _param: String) {}
| ^^^^^^^^^^^^

View File

@ -38,13 +38,17 @@ note: function defined here
| ^^^^^^^^^^^^^^^^^^^^^^^^ --------------
= note: this error originates in the attribute macro `pyfunction` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `CancelHandle: PyClass` is not satisfied
error[E0277]: the trait bound `CancelHandle: PyFunctionArgument<'_, '_>` is not satisfied
--> tests/ui/invalid_cancel_handle.rs:20:50
|
20 | async fn missing_cancel_handle_attribute(_param: pyo3::coroutine::CancelHandle) {}
| ^^^^ the trait `PyClass` is not implemented for `CancelHandle`, which is required by `CancelHandle: PyFunctionArgument<'_, '_>`
|
= help: the trait `PyClass` is implemented for `pyo3::coroutine::Coroutine`
= help: the following other types implement trait `PyFunctionArgument<'a, 'py>`:
Option<&'a pyo3::Bound<'py, T>>
&'a pyo3::Bound<'py, T>
&'a pyo3::coroutine::Coroutine
&'a mut pyo3::coroutine::Coroutine
= note: required for `CancelHandle` to implement `FromPyObject<'_>`
= note: required for `CancelHandle` to implement `FromPyObjectBound<'_, '_>`
= note: required for `CancelHandle` to implement `PyFunctionArgument<'_, '_>`
@ -57,7 +61,7 @@ note: required by a bound in `extract_argument`
| T: PyFunctionArgument<'a, 'py>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `extract_argument`
error[E0277]: the trait bound `CancelHandle: Clone` is not satisfied
error[E0277]: the trait bound `CancelHandle: PyFunctionArgument<'_, '_>` is not satisfied
--> tests/ui/invalid_cancel_handle.rs:20:50
|
20 | async fn missing_cancel_handle_attribute(_param: pyo3::coroutine::CancelHandle) {}

View File

@ -1,6 +1,6 @@
use pyo3::Python;
fn main() {
let foo = if true { "foo" } else { "bar" };
Python::with_gil(|py| py.import_bound(pyo3::intern!(py, foo)).unwrap());
let _foo = if true { "foo" } else { "bar" };
Python::with_gil(|py| py.import_bound(pyo3::intern!(py, _foo)).unwrap());
}

View File

@ -1,8 +1,17 @@
error[E0435]: attempt to use a non-constant value in a constant
--> tests/ui/invalid_intern_arg.rs:5:61
|
5 | Python::with_gil(|py| py.import_bound(pyo3::intern!(py, foo)).unwrap());
| ------------------^^^-
5 | Python::with_gil(|py| py.import_bound(pyo3::intern!(py, _foo)).unwrap());
| ------------------^^^^-
| | |
| | non-constant value
| help: consider using `let` instead of `static`: `let INTERNED`
error: lifetime may not live long enough
--> tests/ui/invalid_intern_arg.rs:5:27
|
5 | Python::with_gil(|py| py.import_bound(pyo3::intern!(py, _foo)).unwrap());
| --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'1` must outlive `'2`
| | |
| | return type of closure is pyo3::Bound<'2, pyo3::prelude::PyModule>
| has type `pyo3::Python<'1>`

View File

@ -6,7 +6,7 @@ struct ClassWithGetter {}
#[pymethods]
impl ClassWithGetter {
#[getter]
fn getter_with_arg(&self, py: Python<'_>, index: u32) {}
fn getter_with_arg(&self, _py: Python<'_>, _index: u32) {}
}
#[pyclass]
@ -15,13 +15,13 @@ struct ClassWithSetter {}
#[pymethods]
impl ClassWithSetter {
#[setter]
fn setter_with_no_arg(&mut self, py: Python<'_>) {}
fn setter_with_no_arg(&mut self, _py: Python<'_>) {}
}
#[pymethods]
impl ClassWithSetter {
#[setter]
fn setter_with_too_many_args(&mut self, py: Python<'_>, foo: u32, bar: u32) {}
fn setter_with_too_many_args(&mut self, _py: Python<'_>, _foo: u32, _bar: u32) {}
}
#[pyclass]

View File

@ -1,20 +1,20 @@
error: getter function can only have one argument (of type pyo3::Python)
--> tests/ui/invalid_property_args.rs:9:54
--> tests/ui/invalid_property_args.rs:9:56
|
9 | fn getter_with_arg(&self, py: Python<'_>, index: u32) {}
| ^^^
9 | fn getter_with_arg(&self, _py: Python<'_>, _index: u32) {}
| ^^^
error: setter function expected to have one argument
--> tests/ui/invalid_property_args.rs:18:8
|
18 | fn setter_with_no_arg(&mut self, py: Python<'_>) {}
18 | fn setter_with_no_arg(&mut self, _py: Python<'_>) {}
| ^^^^^^^^^^^^^^^^^^
error: setter function can have at most two arguments ([pyo3::Python,] and value)
--> tests/ui/invalid_property_args.rs:24:76
--> tests/ui/invalid_property_args.rs:24:79
|
24 | fn setter_with_too_many_args(&mut self, py: Python<'_>, foo: u32, bar: u32) {}
| ^^^
24 | fn setter_with_too_many_args(&mut self, _py: Python<'_>, _foo: u32, _bar: u32) {}
| ^^^
error: `get` and `set` with tuple struct fields require `name`
--> tests/ui/invalid_property_args.rs:28:50

View File

@ -54,11 +54,11 @@ struct EqAndRichcmp;
#[pymethods]
impl EqAndRichcmp {
fn __eq__(&self, other: &Self) -> bool {
fn __eq__(&self, _other: &Self) -> bool {
true
}
fn __richcmp__(&self, other: &Self, op: CompareOp) -> bool {
fn __richcmp__(&self, _other: &Self, _op: CompareOp) -> bool {
true
}
}

View File

@ -22,6 +22,24 @@ error: `text_signature` cannot be used with magic method `__bool__`
46 | #[pyo3(name = "__bool__", text_signature = "")]
| ^^^^^^^^^^^^^^
error[E0034]: multiple applicable items in scope
--> tests/ui/invalid_proto_pymethods.rs:55:1
|
55 | #[pymethods]
| ^^^^^^^^^^^^ multiple `__pymethod___richcmp____` found
|
note: candidate #1 is defined in an impl for the type `EqAndRichcmp`
--> tests/ui/invalid_proto_pymethods.rs:55:1
|
55 | #[pymethods]
| ^^^^^^^^^^^^
note: candidate #2 is defined in an impl for the type `EqAndRichcmp`
--> tests/ui/invalid_proto_pymethods.rs:55:1
|
55 | #[pymethods]
| ^^^^^^^^^^^^
= note: this error originates in the macro `::pyo3::impl_::pyclass::generate_pyclass_richcompare_slot` which comes from the expansion of the attribute macro `pymethods` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0592]: duplicate definitions with name `__pymethod___richcmp____`
--> tests/ui/invalid_proto_pymethods.rs:55:1
|
@ -32,3 +50,21 @@ error[E0592]: duplicate definitions with name `__pymethod___richcmp____`
| other definition for `__pymethod___richcmp____`
|
= note: this error originates in the macro `::pyo3::impl_::pyclass::generate_pyclass_richcompare_slot` which comes from the expansion of the attribute macro `pymethods` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0034]: multiple applicable items in scope
--> tests/ui/invalid_proto_pymethods.rs:55:1
|
55 | #[pymethods]
| ^^^^^^^^^^^^ multiple `__pymethod___richcmp____` found
|
note: candidate #1 is defined in an impl for the type `EqAndRichcmp`
--> tests/ui/invalid_proto_pymethods.rs:55:1
|
55 | #[pymethods]
| ^^^^^^^^^^^^
note: candidate #2 is defined in an impl for the type `EqAndRichcmp`
--> tests/ui/invalid_proto_pymethods.rs:55:1
|
55 | #[pymethods]
| ^^^^^^^^^^^^
= note: this error originates in the attribute macro `pymethods` (in Nightly builds, run with -Z macro-backtrace for more info)

View File

@ -35,6 +35,7 @@ fn function_with_args_sep_after_args_sep() {}
#[pyo3(signature = (**kwargs, *args))]
fn function_with_args_after_kwargs(kwargs: Option<&PyDict>, args: &PyTuple) {
let _ = args;
let _ = kwargs;
}
#[pyfunction]

View File

@ -41,19 +41,19 @@ error: `*args` not allowed after `**kwargs`
| ^
error: `**kwargs_b` not allowed after `**kwargs_a`
--> tests/ui/invalid_pyfunction_signatures.rs:41:33
--> tests/ui/invalid_pyfunction_signatures.rs:42:33
|
41 | #[pyo3(signature = (**kwargs_a, **kwargs_b))]
42 | #[pyo3(signature = (**kwargs_a, **kwargs_b))]
| ^
error: arguments of type `Python` must not be part of the signature
--> tests/ui/invalid_pyfunction_signatures.rs:47:27
--> tests/ui/invalid_pyfunction_signatures.rs:48:27
|
47 | #[pyfunction(signature = (py))]
48 | #[pyfunction(signature = (py))]
| ^^
error: cannot find attribute `args` in this scope
--> tests/ui/invalid_pyfunction_signatures.rs:57:7
--> tests/ui/invalid_pyfunction_signatures.rs:58:7
|
57 | #[args(x)]
58 | #[args(x)]
| ^^^^

View File

@ -2,35 +2,39 @@ use pyo3::prelude::*;
use pyo3::types::{PyDict, PyString, PyTuple};
#[pyfunction]
fn generic_function<T>(value: T) {}
fn generic_function<T>(_value: T) {}
#[pyfunction]
fn impl_trait_function(impl_trait: impl AsRef<PyAny>) {}
fn impl_trait_function(_impl_trait: impl AsRef<PyAny>) {}
#[pyfunction]
fn wildcard_argument(_: i32) {}
#[pyfunction]
fn destructured_argument((a, b): (i32, i32)) {}
fn destructured_argument((_a, _b): (i32, i32)) {}
#[pyfunction]
fn function_with_required_after_option(_opt: Option<i32>, _x: i32) {}
#[pyfunction]
#[pyo3(signature=(*args))]
fn function_with_optional_args(args: Option<Bound<'_, PyTuple>>) {}
fn function_with_optional_args(args: Option<Bound<'_, PyTuple>>) {
let _ = args;
}
#[pyfunction]
#[pyo3(signature=(**kwargs))]
fn function_with_required_kwargs(kwargs: Bound<'_, PyDict>) {}
fn function_with_required_kwargs(kwargs: Bound<'_, PyDict>) {
let _ = kwargs;
}
#[pyfunction(pass_module)]
fn pass_module_but_no_arguments<'py>() {}
#[pyfunction(pass_module)]
fn first_argument_not_module<'a, 'py>(
string: &str,
module: &'a Bound<'_, PyModule>,
_string: &str,
module: &'a Bound<'py, PyModule>,
) -> PyResult<Bound<'py, PyString>> {
module.name()
}

View File

@ -1,14 +1,14 @@
error: Python functions cannot have generic type parameters
--> tests/ui/invalid_pyfunctions.rs:5:21
|
5 | fn generic_function<T>(value: T) {}
5 | fn generic_function<T>(_value: T) {}
| ^
error: Python functions cannot have `impl Trait` arguments
--> tests/ui/invalid_pyfunctions.rs:8:36
--> tests/ui/invalid_pyfunctions.rs:8:37
|
8 | fn impl_trait_function(impl_trait: impl AsRef<PyAny>) {}
| ^^^^
8 | fn impl_trait_function(_impl_trait: impl AsRef<PyAny>) {}
| ^^^^
error: wildcard argument names are not supported
--> tests/ui/invalid_pyfunctions.rs:11:22
@ -19,8 +19,8 @@ error: wildcard argument names are not supported
error: destructuring in arguments is not supported
--> tests/ui/invalid_pyfunctions.rs:14:26
|
14 | fn destructured_argument((a, b): (i32, i32)) {}
| ^^^^^^
14 | fn destructured_argument((_a, _b): (i32, i32)) {}
| ^^^^^^^^
error: required arguments after an `Option<_>` argument are ambiguous
= help: add a `#[pyo3(signature)]` annotation on this function to unambiguously specify the default values for all optional parameters
@ -32,26 +32,26 @@ error: required arguments after an `Option<_>` argument are ambiguous
error: args cannot be optional
--> tests/ui/invalid_pyfunctions.rs:21:32
|
21 | fn function_with_optional_args(args: Option<Bound<'_, PyTuple>>) {}
21 | fn function_with_optional_args(args: Option<Bound<'_, PyTuple>>) {
| ^^^^
error: kwargs must be Option<_>
--> tests/ui/invalid_pyfunctions.rs:25:34
--> tests/ui/invalid_pyfunctions.rs:27:34
|
25 | fn function_with_required_kwargs(kwargs: Bound<'_, PyDict>) {}
27 | fn function_with_required_kwargs(kwargs: Bound<'_, PyDict>) {
| ^^^^^^
error: expected `&PyModule` or `Py<PyModule>` as first argument with `pass_module`
--> tests/ui/invalid_pyfunctions.rs:28:37
--> tests/ui/invalid_pyfunctions.rs:32:37
|
28 | fn pass_module_but_no_arguments<'py>() {}
32 | fn pass_module_but_no_arguments<'py>() {}
| ^^
error[E0277]: the trait bound `&str: From<BoundRef<'_, '_, pyo3::prelude::PyModule>>` is not satisfied
--> tests/ui/invalid_pyfunctions.rs:32:13
--> tests/ui/invalid_pyfunctions.rs:36:14
|
32 | string: &str,
| ^ the trait `From<BoundRef<'_, '_, pyo3::prelude::PyModule>>` is not implemented for `&str`, which is required by `BoundRef<'_, '_, pyo3::prelude::PyModule>: Into<_>`
36 | _string: &str,
| ^ the trait `From<BoundRef<'_, '_, pyo3::prelude::PyModule>>` is not implemented for `&str`, which is required by `BoundRef<'_, '_, pyo3::prelude::PyModule>: Into<_>`
|
= help: the following other types implement trait `From<T>`:
<String as From<char>>

View File

@ -5,7 +5,7 @@ struct MyClass {}
#[pymethods]
impl MyClass {
fn method_with_invalid_self_type(slf: i32, py: Python<'_>, index: u32) {}
fn method_with_invalid_self_type(_slf: i32, _py: Python<'_>, _index: u32) {}
}
fn main() {}

View File

@ -1,8 +1,8 @@
error[E0277]: the trait bound `i32: From<BoundRef<'_, '_, MyClass>>` is not satisfied
--> tests/ui/invalid_pymethod_receiver.rs:8:43
error[E0277]: the trait bound `i32: TryFrom<BoundRef<'_, '_, MyClass>>` is not satisfied
--> tests/ui/invalid_pymethod_receiver.rs:8:44
|
8 | fn method_with_invalid_self_type(slf: i32, py: Python<'_>, index: u32) {}
| ^^^ the trait `From<BoundRef<'_, '_, MyClass>>` is not implemented for `i32`, which is required by `i32: TryFrom<BoundRef<'_, '_, MyClass>>`
8 | fn method_with_invalid_self_type(_slf: i32, _py: Python<'_>, _index: u32) {}
| ^^^ the trait `From<BoundRef<'_, '_, MyClass>>` is not implemented for `i32`, which is required by `i32: TryFrom<BoundRef<'_, '_, MyClass>>`
|
= help: the following other types implement trait `From<T>`:
<i32 as From<bool>>
@ -10,6 +10,5 @@ error[E0277]: the trait bound `i32: From<BoundRef<'_, '_, MyClass>>` is not sati
<i32 as From<i16>>
<i32 as From<u8>>
<i32 as From<u16>>
<i32 as From<NonZero<i32>>>
= note: required for `BoundRef<'_, '_, MyClass>` to implement `Into<i32>`
= note: required for `i32` to implement `TryFrom<BoundRef<'_, '_, MyClass>>`

View File

@ -6,7 +6,7 @@ struct MyClass {}
#[pymethods]
impl MyClass {
#[classattr]
fn class_attr_with_args(foo: i32) {}
fn class_attr_with_args(_foo: i32) {}
}
#[pymethods]
@ -164,23 +164,23 @@ impl MyClass {
#[pymethods]
impl MyClass {
fn generic_method<T>(value: T) {}
fn generic_method<T>(_value: T) {}
}
#[pymethods]
impl MyClass {
fn impl_trait_method_first_arg(impl_trait: impl AsRef<PyAny>) {}
fn impl_trait_method_first_arg(_impl_trait: impl AsRef<PyAny>) {}
}
#[pymethods]
impl MyClass {
fn impl_trait_method_second_arg(&self, impl_trait: impl AsRef<PyAny>) {}
fn impl_trait_method_second_arg(&self, _impl_trait: impl AsRef<PyAny>) {}
}
#[pymethods]
impl MyClass {
#[pyo3(pass_module)]
fn method_cannot_pass_module(&self, m: &PyModule) {}
fn method_cannot_pass_module(&self, _m: &PyModule) {}
}
#[pymethods]

View File

@ -1,8 +1,8 @@
error: #[classattr] can only have one argument (of type pyo3::Python)
--> tests/ui/invalid_pymethods.rs:9:34
--> tests/ui/invalid_pymethods.rs:9:35
|
9 | fn class_attr_with_args(foo: i32) {}
| ^^^
9 | fn class_attr_with_args(_foo: i32) {}
| ^^^
error: `#[classattr]` does not take any arguments
--> tests/ui/invalid_pymethods.rs:14:5
@ -144,20 +144,20 @@ error: `#[classattr]` does not take any arguments
error: Python functions cannot have generic type parameters
--> tests/ui/invalid_pymethods.rs:167:23
|
167 | fn generic_method<T>(value: T) {}
167 | fn generic_method<T>(_value: T) {}
| ^
error: Python functions cannot have `impl Trait` arguments
--> tests/ui/invalid_pymethods.rs:172:48
--> tests/ui/invalid_pymethods.rs:172:49
|
172 | fn impl_trait_method_first_arg(impl_trait: impl AsRef<PyAny>) {}
| ^^^^
172 | fn impl_trait_method_first_arg(_impl_trait: impl AsRef<PyAny>) {}
| ^^^^
error: Python functions cannot have `impl Trait` arguments
--> tests/ui/invalid_pymethods.rs:177:56
--> tests/ui/invalid_pymethods.rs:177:57
|
177 | fn impl_trait_method_second_arg(&self, impl_trait: impl AsRef<PyAny>) {}
| ^^^^
177 | fn impl_trait_method_second_arg(&self, _impl_trait: impl AsRef<PyAny>) {}
| ^^^^
error: `pass_module` cannot be used on Python methods
--> tests/ui/invalid_pymethods.rs:182:12
@ -191,5 +191,4 @@ error[E0277]: the trait bound `i32: From<BoundRef<'_, '_, PyType>>` is not satis
<i32 as From<i16>>
<i32 as From<u8>>
<i32 as From<u16>>
<i32 as From<NonZero<i32>>>
= note: required for `BoundRef<'_, '_, PyType>` to implement `Into<i32>`

View File

@ -9,6 +9,40 @@ error[E0119]: conflicting implementations of trait `pyo3::impl_::pyclass::PyClas
|
= note: this error originates in the attribute macro `pymethods` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `TwoNew: PyTypeInfo` is not satisfied
--> tests/ui/invalid_pymethods_duplicates.rs:9:6
|
9 | impl TwoNew {
| ^^^^^^ the trait `PyTypeInfo` is not implemented for `TwoNew`
|
= help: the following other types implement trait `PyTypeInfo`:
PyAny
PyBool
PyByteArray
PyBytes
PyCapsule
PyCode
PyComplex
PyDate
and $N others
error[E0277]: the trait bound `TwoNew: HasPyGilRef` is not satisfied
--> tests/ui/invalid_pymethods_duplicates.rs:9:6
|
9 | impl TwoNew {
| ^^^^^^ the trait `PyNativeType` is not implemented for `TwoNew`, which is required by `TwoNew: HasPyGilRef`
|
= help: the trait `HasPyGilRef` is implemented for `pyo3::coroutine::Coroutine`
= note: required for `TwoNew` to implement `HasPyGilRef`
note: required by a bound in `pyo3::PyTypeInfo::NAME`
--> src/type_object.rs
|
| pub unsafe trait PyTypeInfo: Sized + HasPyGilRef {
| ^^^^^^^^^^^ required by this bound in `PyTypeInfo::NAME`
| /// Class name.
| const NAME: &'static str;
| ---- required by a bound in this associated constant
error[E0592]: duplicate definitions with name `__pymethod___new____`
--> tests/ui/invalid_pymethods_duplicates.rs:8:1
|
@ -30,3 +64,71 @@ error[E0592]: duplicate definitions with name `__pymethod_func__`
| other definition for `__pymethod_func__`
|
= note: this error originates in the attribute macro `pymethods` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `TwoNew: PyClass` is not satisfied
--> tests/ui/invalid_pymethods_duplicates.rs:8:1
|
8 | #[pymethods]
| ^^^^^^^^^^^^ the trait `PyClass` is not implemented for `TwoNew`
|
= help: the trait `PyClass` is implemented for `pyo3::coroutine::Coroutine`
note: required by a bound in `PyClassInitializer`
--> src/pyclass_init.rs
|
| pub struct PyClassInitializer<T: PyClass>(PyClassInitializerImpl<T>);
| ^^^^^^^ required by this bound in `PyClassInitializer`
= note: this error originates in the attribute macro `pymethods` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0599]: no method named `convert` found for struct `TwoNew` in the current scope
--> tests/ui/invalid_pymethods_duplicates.rs:8:1
|
6 | struct TwoNew {}
| ------------- method `convert` not found for this struct
7 |
8 | #[pymethods]
| ^^^^^^^^^^^^ method not found in `TwoNew`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `convert`, perhaps you need to implement it:
candidate #1: `IntoPyCallbackOutput`
= note: this error originates in the attribute macro `pymethods` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `DuplicateMethod: PyClass` is not satisfied
--> tests/ui/invalid_pymethods_duplicates.rs:26:15
|
26 | fn func_a(&self) {}
| ^ the trait `PyClass` is not implemented for `DuplicateMethod`
|
= help: the trait `PyClass` is implemented for `pyo3::coroutine::Coroutine`
note: required by a bound in `extract_pyclass_ref`
--> src/impl_/extract_argument.rs
|
| pub fn extract_pyclass_ref<'a, 'py: 'a, T: PyClass>(
| ^^^^^^^ required by this bound in `extract_pyclass_ref`
error[E0277]: the trait bound `DuplicateMethod: PyClass` is not satisfied
--> tests/ui/invalid_pymethods_duplicates.rs:23:1
|
23 | #[pymethods]
| ^^^^^^^^^^^^ the trait `PyClass` is not implemented for `DuplicateMethod`
|
= help: the trait `PyClass` is implemented for `pyo3::coroutine::Coroutine`
note: required by a bound in `PyRef`
--> src/pycell.rs
|
| pub struct PyRef<'p, T: PyClass> {
| ^^^^^^^ required by this bound in `PyRef`
= note: this error originates in the attribute macro `pymethods` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `DuplicateMethod: PyClass` is not satisfied
--> tests/ui/invalid_pymethods_duplicates.rs:29:15
|
29 | fn func_b(&self) {}
| ^ the trait `PyClass` is not implemented for `DuplicateMethod`
|
= help: the trait `PyClass` is implemented for `pyo3::coroutine::Coroutine`
note: required by a bound in `extract_pyclass_ref`
--> src/impl_/extract_argument.rs
|
| pub fn extract_pyclass_ref<'a, 'py: 'a, T: PyClass>(
| ^^^^^^^ required by this bound in `extract_pyclass_ref`

View File

@ -1,18 +1,9 @@
error[E0277]: the trait bound `Blah: IntoPy<Py<PyAny>>` is not satisfied
error[E0277]: the trait bound `Blah: OkWrap<Blah>` is not satisfied
--> tests/ui/missing_intopy.rs:3:1
|
3 | #[pyo3::pyfunction]
| ^^^^^^^^^^^^^^^^^^^ the trait `IntoPy<Py<PyAny>>` is not implemented for `Blah`, which is required by `Blah: OkWrap<_>`
|
= help: the following other types implement trait `IntoPy<T>`:
<bool as IntoPy<Py<PyAny>>>
<char as IntoPy<Py<PyAny>>>
<isize as IntoPy<Py<PyAny>>>
<i8 as IntoPy<Py<PyAny>>>
<i16 as IntoPy<Py<PyAny>>>
<i32 as IntoPy<Py<PyAny>>>
<i64 as IntoPy<Py<PyAny>>>
<i128 as IntoPy<Py<PyAny>>>
and $N others
= help: the trait `OkWrap<T>` is implemented for `Result<T, E>`
= note: required for `Blah` to implement `OkWrap<Blah>`
= note: this error originates in the attribute macro `pyo3::pyfunction` (in Nightly builds, run with -Z macro-backtrace for more info)

View File

@ -10,7 +10,7 @@ fn main() {
let obj = Python::with_gil(|py| {
Bound::new(py, NotThreadSafe { data: Rc::new(5) })
.unwrap()
.unbind(py)
.unbind()
});
std::thread::spawn(move || {

View File

@ -7,7 +7,7 @@ struct TraverseTriesToTakePyRef {}
#[pymethods]
impl TraverseTriesToTakePyRef {
fn __traverse__(slf: PyRef<Self>, visit: PyVisit) -> Result<(), PyTraverseError> {
fn __traverse__(_slf: PyRef<Self>, _visit: PyVisit) -> Result<(), PyTraverseError> {
Ok(())
}
}
@ -17,7 +17,7 @@ struct TraverseTriesToTakePyRefMut {}
#[pymethods]
impl TraverseTriesToTakePyRefMut {
fn __traverse__(slf: PyRefMut<Self>, visit: PyVisit) -> Result<(), PyTraverseError> {
fn __traverse__(_slf: PyRefMut<Self>, _visit: PyVisit) -> Result<(), PyTraverseError> {
Ok(())
}
}
@ -27,7 +27,7 @@ struct TraverseTriesToTakeBound {}
#[pymethods]
impl TraverseTriesToTakeBound {
fn __traverse__(slf: Bound<'_, Self>, visit: PyVisit) -> Result<(), PyTraverseError> {
fn __traverse__(_slf: Bound<'_, Self>, _visit: PyVisit) -> Result<(), PyTraverseError> {
Ok(())
}
}
@ -37,7 +37,7 @@ struct TraverseTriesToTakeMutSelf {}
#[pymethods]
impl TraverseTriesToTakeMutSelf {
fn __traverse__(&mut self, visit: PyVisit) -> Result<(), PyTraverseError> {
fn __traverse__(&mut self, _visit: PyVisit) -> Result<(), PyTraverseError> {
Ok(())
}
}
@ -47,7 +47,7 @@ struct TraverseTriesToTakeSelf {}
#[pymethods]
impl TraverseTriesToTakeSelf {
fn __traverse__(&self, visit: PyVisit) -> Result<(), PyTraverseError> {
fn __traverse__(&self, _visit: PyVisit) -> Result<(), PyTraverseError> {
Ok(())
}
}
@ -57,7 +57,7 @@ struct Class;
#[pymethods]
impl Class {
fn __traverse__(&self, py: Python<'_>, visit: PyVisit<'_>) -> Result<(), PyTraverseError> {
fn __traverse__(&self, _py: Python<'_>, _visit: PyVisit<'_>) -> Result<(), PyTraverseError> {
Ok(())
}

View File

@ -1,29 +1,29 @@
error: __traverse__ may not take a receiver other than `&self`. Usually, an implementation of `__traverse__(&self, visit: PyVisit<'_>) -> Result<(), PyTraverseError>` should do nothing but calls to `visit.call`. Most importantly, safe access to the GIL is prohibited inside implementations of `__traverse__`, i.e. `Python::with_gil` will panic.
--> tests/ui/traverse.rs:10:26
--> tests/ui/traverse.rs:10:27
|
10 | fn __traverse__(slf: PyRef<Self>, visit: PyVisit) -> Result<(), PyTraverseError> {
| ^^^^^
10 | fn __traverse__(_slf: PyRef<Self>, _visit: PyVisit) -> Result<(), PyTraverseError> {
| ^^^^^
error: __traverse__ may not take a receiver other than `&self`. Usually, an implementation of `__traverse__(&self, visit: PyVisit<'_>) -> Result<(), PyTraverseError>` should do nothing but calls to `visit.call`. Most importantly, safe access to the GIL is prohibited inside implementations of `__traverse__`, i.e. `Python::with_gil` will panic.
--> tests/ui/traverse.rs:20:26
--> tests/ui/traverse.rs:20:27
|
20 | fn __traverse__(slf: PyRefMut<Self>, visit: PyVisit) -> Result<(), PyTraverseError> {
| ^^^^^^^^
20 | fn __traverse__(_slf: PyRefMut<Self>, _visit: PyVisit) -> Result<(), PyTraverseError> {
| ^^^^^^^^
error: __traverse__ may not take a receiver other than `&self`. Usually, an implementation of `__traverse__(&self, visit: PyVisit<'_>) -> Result<(), PyTraverseError>` should do nothing but calls to `visit.call`. Most importantly, safe access to the GIL is prohibited inside implementations of `__traverse__`, i.e. `Python::with_gil` will panic.
--> tests/ui/traverse.rs:30:26
--> tests/ui/traverse.rs:30:27
|
30 | fn __traverse__(slf: Bound<'_, Self>, visit: PyVisit) -> Result<(), PyTraverseError> {
| ^^^^^
30 | fn __traverse__(_slf: Bound<'_, Self>, _visit: PyVisit) -> Result<(), PyTraverseError> {
| ^^^^^
error: __traverse__ may not take a receiver other than `&self`. Usually, an implementation of `__traverse__(&self, visit: PyVisit<'_>) -> Result<(), PyTraverseError>` should do nothing but calls to `visit.call`. Most importantly, safe access to the GIL is prohibited inside implementations of `__traverse__`, i.e. `Python::with_gil` will panic.
--> tests/ui/traverse.rs:40:21
|
40 | fn __traverse__(&mut self, visit: PyVisit) -> Result<(), PyTraverseError> {
40 | fn __traverse__(&mut self, _visit: PyVisit) -> Result<(), PyTraverseError> {
| ^
error: __traverse__ may not take `Python`. Usually, an implementation of `__traverse__(&self, visit: PyVisit<'_>) -> Result<(), PyTraverseError>` should do nothing but calls to `visit.call`. Most importantly, safe access to the GIL is prohibited inside implementations of `__traverse__`, i.e. `Python::with_gil` will panic.
--> tests/ui/traverse.rs:60:32
--> tests/ui/traverse.rs:60:33
|
60 | fn __traverse__(&self, py: Python<'_>, visit: PyVisit<'_>) -> Result<(), PyTraverseError> {
| ^^^^^^^^^^
60 | fn __traverse__(&self, _py: Python<'_>, _visit: PyVisit<'_>) -> Result<(), PyTraverseError> {
| ^^^^^^^^^^