Skip to content

Commit 3f8b496

Browse files
committed
Enable arbitrary self types in ui tests
1 parent 5da685c commit 3f8b496

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+553
-512
lines changed

tests/ui/abi3_inheritance.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![feature(arbitrary_self_types)]
12
use pyo3::exceptions::PyException;
23
use pyo3::prelude::*;
34

tests/ui/abi3_inheritance.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
error[E0277]: pyclass `PyException` cannot be subclassed
2-
--> tests/ui/abi3_inheritance.rs:4:19
2+
--> tests/ui/abi3_inheritance.rs:5:19
33
|
4-
4 | #[pyclass(extends=PyException)]
4+
5 | #[pyclass(extends=PyException)]
55
| ^^^^^^^^^^^ required for `#[pyclass(extends=PyException)]`
66
|
77
= help: the trait `PyClassBaseType` is not implemented for `PyException`
@@ -15,9 +15,9 @@ note: required by a bound in `PyClassImpl::BaseType`
1515
| ^^^^^^^^^^^^^^^ required by this bound in `PyClassImpl::BaseType`
1616

1717
error[E0277]: pyclass `PyException` cannot be subclassed
18-
--> tests/ui/abi3_inheritance.rs:4:1
18+
--> tests/ui/abi3_inheritance.rs:5:1
1919
|
20-
4 | #[pyclass(extends=PyException)]
20+
5 | #[pyclass(extends=PyException)]
2121
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required for `#[pyclass(extends=PyException)]`
2222
|
2323
= help: the trait `PyClassBaseType` is not implemented for `PyException`

tests/ui/abi3_nativetype_inheritance.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//! With abi3, we cannot inherit native types.
2+
#![feature(arbitrary_self_types)]
23
use pyo3::prelude::*;
34
use pyo3::types::PyDict;
45

tests/ui/abi3_nativetype_inheritance.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
error[E0277]: pyclass `PyDict` cannot be subclassed
2-
--> tests/ui/abi3_nativetype_inheritance.rs:5:19
2+
--> tests/ui/abi3_nativetype_inheritance.rs:6:19
33
|
4-
5 | #[pyclass(extends=PyDict)]
4+
6 | #[pyclass(extends=PyDict)]
55
| ^^^^^^ required for `#[pyclass(extends=PyDict)]`
66
|
77
= help: the trait `PyClassBaseType` is not implemented for `PyDict`
@@ -15,9 +15,9 @@ note: required by a bound in `PyClassImpl::BaseType`
1515
| ^^^^^^^^^^^^^^^ required by this bound in `PyClassImpl::BaseType`
1616

1717
error[E0277]: pyclass `PyDict` cannot be subclassed
18-
--> tests/ui/abi3_nativetype_inheritance.rs:5:1
18+
--> tests/ui/abi3_nativetype_inheritance.rs:6:1
1919
|
20-
5 | #[pyclass(extends=PyDict)]
20+
6 | #[pyclass(extends=PyDict)]
2121
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ required for `#[pyclass(extends=PyDict)]`
2222
|
2323
= help: the trait `PyClassBaseType` is not implemented for `PyDict`

tests/ui/ambiguous_associated_items.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![feature(arbitrary_self_types)]
12
use pyo3::prelude::*;
23

34
#[pyclass(eq)]

tests/ui/forbid_unsafe.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![feature(arbitrary_self_types)]
12
#![forbid(unsafe_code)]
23
#![forbid(unsafe_op_in_unsafe_fn)]
34

tests/ui/invalid_base_class.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![feature(arbitrary_self_types)]
12
use pyo3::prelude::*;
23
use pyo3::types::PyBool;
34

tests/ui/invalid_base_class.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
error[E0277]: pyclass `PyBool` cannot be subclassed
2-
--> tests/ui/invalid_base_class.rs:4:19
2+
--> tests/ui/invalid_base_class.rs:5:19
33
|
4-
4 | #[pyclass(extends=PyBool)]
4+
5 | #[pyclass(extends=PyBool)]
55
| ^^^^^^ required for `#[pyclass(extends=PyBool)]`
66
|
77
= help: the trait `PyClassBaseType` is not implemented for `PyBool`
@@ -23,9 +23,9 @@ note: required by a bound in `PyClassImpl::BaseType`
2323
| ^^^^^^^^^^^^^^^ required by this bound in `PyClassImpl::BaseType`
2424

2525
error[E0277]: pyclass `PyBool` cannot be subclassed
26-
--> tests/ui/invalid_base_class.rs:4:1
26+
--> tests/ui/invalid_base_class.rs:5:1
2727
|
28-
4 | #[pyclass(extends=PyBool)]
28+
5 | #[pyclass(extends=PyBool)]
2929
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ required for `#[pyclass(extends=PyBool)]`
3030
|
3131
= help: the trait `PyClassBaseType` is not implemented for `PyBool`

tests/ui/invalid_cancel_handle.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ error[E0277]: the trait bound `CancelHandle: PyFunctionArgument<'_, '_>` is not
4242
--> tests/ui/invalid_cancel_handle.rs:20:50
4343
|
4444
20 | async fn missing_cancel_handle_attribute(_param: pyo3::coroutine::CancelHandle) {}
45-
| ^^^^ the trait `PyClass` is not implemented for `CancelHandle`
45+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `PyClass` is not implemented for `CancelHandle`
4646
|
4747
= help: the trait `PyClass` is implemented for `pyo3::coroutine::Coroutine`
4848
= note: required for `CancelHandle` to implement `FromPyObject<'_>`
@@ -61,7 +61,7 @@ error[E0277]: the trait bound `CancelHandle: PyFunctionArgument<'_, '_>` is not
6161
--> tests/ui/invalid_cancel_handle.rs:20:50
6262
|
6363
20 | async fn missing_cancel_handle_attribute(_param: pyo3::coroutine::CancelHandle) {}
64-
| ^^^^ the trait `Clone` is not implemented for `CancelHandle`
64+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `CancelHandle`
6565
|
6666
= help: the following other types implement trait `PyFunctionArgument<'a, 'py>`:
6767
&'a mut pyo3::coroutine::Coroutine

tests/ui/invalid_frozen_pyclass_borrow.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![feature(arbitrary_self_types)]
12
use pyo3::prelude::*;
23

34
#[pyclass(frozen)]

tests/ui/invalid_frozen_pyclass_borrow.stderr

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error: cannot use `#[pyo3(set)]` on a `frozen` class
2-
--> tests/ui/invalid_frozen_pyclass_borrow.rs:38:12
2+
--> tests/ui/invalid_frozen_pyclass_borrow.rs:39:12
33
|
4-
38 | #[pyo3(set)]
4+
39 | #[pyo3(set)]
55
| ^^^
66

77
error[E0271]: type mismatch resolving `<Foo as PyClass>::Frozen == False`
8-
--> tests/ui/invalid_frozen_pyclass_borrow.rs:11:19
8+
--> tests/ui/invalid_frozen_pyclass_borrow.rs:12:19
99
|
10-
11 | fn mut_method(&mut self) {}
10+
12 | fn mut_method(&mut self) {}
1111
| ^^^^^^^^^ expected `False`, found `True`
1212
|
1313
note: required by a bound in `extract_pyclass_ref_mut`
@@ -17,22 +17,22 @@ note: required by a bound in `extract_pyclass_ref_mut`
1717
| ^^^^^^^^^^^^^^ required by this bound in `extract_pyclass_ref_mut`
1818

1919
error[E0271]: type mismatch resolving `<Foo as PyClass>::Frozen == False`
20-
--> tests/ui/invalid_frozen_pyclass_borrow.rs:9:1
21-
|
22-
9 | #[pymethods]
23-
| ^^^^^^^^^^^^ expected `False`, found `True`
24-
|
20+
--> tests/ui/invalid_frozen_pyclass_borrow.rs:10:1
21+
|
22+
10 | #[pymethods]
23+
| ^^^^^^^^^^^^ expected `False`, found `True`
24+
|
2525
note: required by a bound in `PyRefMut`
26-
--> src/pycell.rs
27-
|
28-
| pub struct PyRefMut<'p, T: PyClass<Frozen = False>> {
29-
| ^^^^^^^^^^^^^^ required by this bound in `PyRefMut`
30-
= note: this error originates in the attribute macro `pymethods` (in Nightly builds, run with -Z macro-backtrace for more info)
26+
--> src/pycell.rs
27+
|
28+
| pub struct PyRefMut<'p, T: PyClass<Frozen = False>> {
29+
| ^^^^^^^^^^^^^^ required by this bound in `PyRefMut`
30+
= note: this error originates in the attribute macro `pymethods` (in Nightly builds, run with -Z macro-backtrace for more info)
3131

3232
error[E0271]: type mismatch resolving `<Foo as PyClass>::Frozen == False`
33-
--> tests/ui/invalid_frozen_pyclass_borrow.rs:15:31
33+
--> tests/ui/invalid_frozen_pyclass_borrow.rs:16:31
3434
|
35-
15 | let borrow = foo.bind(py).borrow_mut();
35+
16 | let borrow = foo.bind(py).borrow_mut();
3636
| ^^^^^^^^^^ expected `False`, found `True`
3737
|
3838
note: required by a bound in `pyo3::Bound::<'py, T>::borrow_mut`
@@ -45,9 +45,9 @@ note: required by a bound in `pyo3::Bound::<'py, T>::borrow_mut`
4545
| ^^^^^^^^^^^^^^ required by this bound in `Bound::<'py, T>::borrow_mut`
4646

4747
error[E0271]: type mismatch resolving `<ImmutableChild as PyClass>::Frozen == False`
48-
--> tests/ui/invalid_frozen_pyclass_borrow.rs:25:33
48+
--> tests/ui/invalid_frozen_pyclass_borrow.rs:26:33
4949
|
50-
25 | let borrow = child.bind(py).borrow_mut();
50+
26 | let borrow = child.bind(py).borrow_mut();
5151
| ^^^^^^^^^^ expected `False`, found `True`
5252
|
5353
note: required by a bound in `pyo3::Bound::<'py, T>::borrow_mut`
@@ -60,9 +60,9 @@ note: required by a bound in `pyo3::Bound::<'py, T>::borrow_mut`
6060
| ^^^^^^^^^^^^^^ required by this bound in `Bound::<'py, T>::borrow_mut`
6161

6262
error[E0271]: type mismatch resolving `<MutableBase as PyClass>::Frozen == True`
63-
--> tests/ui/invalid_frozen_pyclass_borrow.rs:29:11
63+
--> tests/ui/invalid_frozen_pyclass_borrow.rs:30:11
6464
|
65-
29 | class.get();
65+
30 | class.get();
6666
| ^^^ expected `True`, found `False`
6767
|
6868
note: required by a bound in `pyo3::Py::<T>::get`
@@ -75,9 +75,9 @@ note: required by a bound in `pyo3::Py::<T>::get`
7575
| ^^^^^^^^^^^^^ required by this bound in `Py::<T>::get`
7676

7777
error[E0271]: type mismatch resolving `<MutableBase as PyClass>::Frozen == True`
78-
--> tests/ui/invalid_frozen_pyclass_borrow.rs:33:11
78+
--> tests/ui/invalid_frozen_pyclass_borrow.rs:34:11
7979
|
80-
33 | class.get();
80+
34 | class.get();
8181
| ^^^ expected `True`, found `False`
8282
|
8383
note: required by a bound in `pyo3::Bound::<'py, T>::get`

tests/ui/invalid_property_args.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![feature(arbitrary_self_types)]
12
use pyo3::prelude::*;
23

34
#[pyclass]

tests/ui/invalid_property_args.stderr

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,55 @@
11
error: getter function can only have one argument (of type pyo3::Python)
2-
--> tests/ui/invalid_property_args.rs:9:56
3-
|
4-
9 | fn getter_with_arg(&self, _py: Python<'_>, _index: u32) {}
5-
| ^^^
2+
--> tests/ui/invalid_property_args.rs:10:56
3+
|
4+
10 | fn getter_with_arg(&self, _py: Python<'_>, _index: u32) {}
5+
| ^^^
66

77
error: setter function expected to have one argument
8-
--> tests/ui/invalid_property_args.rs:18:8
8+
--> tests/ui/invalid_property_args.rs:19:8
99
|
10-
18 | fn setter_with_no_arg(&mut self, _py: Python<'_>) {}
10+
19 | fn setter_with_no_arg(&mut self, _py: Python<'_>) {}
1111
| ^^^^^^^^^^^^^^^^^^
1212

1313
error: setter function can have at most two arguments ([pyo3::Python,] and value)
14-
--> tests/ui/invalid_property_args.rs:24:79
14+
--> tests/ui/invalid_property_args.rs:25:79
1515
|
16-
24 | fn setter_with_too_many_args(&mut self, _py: Python<'_>, _foo: u32, _bar: u32) {}
16+
25 | fn setter_with_too_many_args(&mut self, _py: Python<'_>, _foo: u32, _bar: u32) {}
1717
| ^^^
1818

1919
error: `get` and `set` with tuple struct fields require `name`
20-
--> tests/ui/invalid_property_args.rs:28:50
20+
--> tests/ui/invalid_property_args.rs:29:50
2121
|
22-
28 | struct TupleGetterSetterNoName(#[pyo3(get, set)] i32);
22+
29 | struct TupleGetterSetterNoName(#[pyo3(get, set)] i32);
2323
| ^^^
2424

2525
error: `get` may only be specified once
26-
--> tests/ui/invalid_property_args.rs:31:32
26+
--> tests/ui/invalid_property_args.rs:32:32
2727
|
28-
31 | struct MultipleGet(#[pyo3(get, get)] i32);
28+
32 | struct MultipleGet(#[pyo3(get, get)] i32);
2929
| ^^^
3030

3131
error: `set` may only be specified once
32-
--> tests/ui/invalid_property_args.rs:34:32
32+
--> tests/ui/invalid_property_args.rs:35:32
3333
|
34-
34 | struct MultipleSet(#[pyo3(set, set)] i32);
34+
35 | struct MultipleSet(#[pyo3(set, set)] i32);
3535
| ^^^
3636

3737
error: `name` may only be specified once
38-
--> tests/ui/invalid_property_args.rs:37:42
38+
--> tests/ui/invalid_property_args.rs:38:42
3939
|
40-
37 | struct MultipleName(#[pyo3(name = "foo", name = "bar")] i32);
40+
38 | struct MultipleName(#[pyo3(name = "foo", name = "bar")] i32);
4141
| ^^^^^^^^^^^^
4242

4343
error: `name` is useless without `get` or `set`
44-
--> tests/ui/invalid_property_args.rs:40:33
44+
--> tests/ui/invalid_property_args.rs:41:33
4545
|
46-
40 | struct NameWithoutGetSet(#[pyo3(name = "value")] i32);
46+
41 | struct NameWithoutGetSet(#[pyo3(name = "value")] i32);
4747
| ^^^^^^^^^^^^^^
4848

4949
error[E0277]: `PhantomData<i32>` cannot be converted to a Python object
50-
--> tests/ui/invalid_property_args.rs:45:12
50+
--> tests/ui/invalid_property_args.rs:46:12
5151
|
52-
45 | value: ::std::marker::PhantomData<i32>,
52+
46 | value: ::std::marker::PhantomData<i32>,
5353
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by `#[pyo3(get)]` to create a readable property from a field of type `PhantomData<i32>`
5454
|
5555
= help: the trait `IntoPyObject<'_>` is not implemented for `PhantomData<i32>`

tests/ui/invalid_proto_pymethods.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
//! For convenience use #[pyo3(name = "__some_dunder__")] to create the methods,
44
//! so that the function names can describe the edge case to be rejected.
55
6+
#![feature(arbitrary_self_types)]
67
use pyo3::prelude::*;
78
use pyo3::pyclass::CompareOp;
89

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,49 @@
11
error: Expected 1 arguments, got 0
2-
--> tests/ui/invalid_proto_pymethods.rs:19:8
2+
--> tests/ui/invalid_proto_pymethods.rs:20:8
33
|
4-
19 | fn truediv_expects_one_argument(&self) -> PyResult<()> {
4+
20 | fn truediv_expects_one_argument(&self) -> PyResult<()> {
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66

77
error: Expected 1 arguments, got 0
8-
--> tests/ui/invalid_proto_pymethods.rs:27:8
8+
--> tests/ui/invalid_proto_pymethods.rs:28:8
99
|
10-
27 | fn truediv_expects_one_argument_py(&self, _py: Python<'_>) -> PyResult<()> {
10+
28 | fn truediv_expects_one_argument_py(&self, _py: Python<'_>) -> PyResult<()> {
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1212

1313
error: `signature` cannot be used with magic method `__bool__`
14-
--> tests/ui/invalid_proto_pymethods.rs:38:31
14+
--> tests/ui/invalid_proto_pymethods.rs:39:31
1515
|
16-
38 | #[pyo3(name = "__bool__", signature = ())]
16+
39 | #[pyo3(name = "__bool__", signature = ())]
1717
| ^^^^^^^^^
1818

1919
error: `text_signature` cannot be used with magic method `__bool__`
20-
--> tests/ui/invalid_proto_pymethods.rs:46:31
20+
--> tests/ui/invalid_proto_pymethods.rs:47:31
2121
|
22-
46 | #[pyo3(name = "__bool__", text_signature = "")]
22+
47 | #[pyo3(name = "__bool__", text_signature = "")]
2323
| ^^^^^^^^^^^^^^
2424

2525
error[E0034]: multiple applicable items in scope
26-
--> tests/ui/invalid_proto_pymethods.rs:55:1
26+
--> tests/ui/invalid_proto_pymethods.rs:56:1
2727
|
28-
55 | #[pymethods]
28+
56 | #[pymethods]
2929
| ^^^^^^^^^^^^ multiple `__pymethod___richcmp____` found
3030
|
3131
note: candidate #1 is defined in an impl for the type `EqAndRichcmp`
32-
--> tests/ui/invalid_proto_pymethods.rs:55:1
32+
--> tests/ui/invalid_proto_pymethods.rs:56:1
3333
|
34-
55 | #[pymethods]
34+
56 | #[pymethods]
3535
| ^^^^^^^^^^^^
3636
note: candidate #2 is defined in an impl for the type `EqAndRichcmp`
37-
--> tests/ui/invalid_proto_pymethods.rs:55:1
37+
--> tests/ui/invalid_proto_pymethods.rs:56:1
3838
|
39-
55 | #[pymethods]
39+
56 | #[pymethods]
4040
| ^^^^^^^^^^^^
4141
= 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)
4242

4343
error[E0592]: duplicate definitions with name `__pymethod___richcmp____`
44-
--> tests/ui/invalid_proto_pymethods.rs:55:1
44+
--> tests/ui/invalid_proto_pymethods.rs:56:1
4545
|
46-
55 | #[pymethods]
46+
56 | #[pymethods]
4747
| ^^^^^^^^^^^^
4848
| |
4949
| duplicate definitions for `__pymethod___richcmp____`
@@ -52,19 +52,19 @@ error[E0592]: duplicate definitions with name `__pymethod___richcmp____`
5252
= 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)
5353

5454
error[E0034]: multiple applicable items in scope
55-
--> tests/ui/invalid_proto_pymethods.rs:55:1
55+
--> tests/ui/invalid_proto_pymethods.rs:56:1
5656
|
57-
55 | #[pymethods]
57+
56 | #[pymethods]
5858
| ^^^^^^^^^^^^ multiple `__pymethod___richcmp____` found
5959
|
6060
note: candidate #1 is defined in an impl for the type `EqAndRichcmp`
61-
--> tests/ui/invalid_proto_pymethods.rs:55:1
61+
--> tests/ui/invalid_proto_pymethods.rs:56:1
6262
|
63-
55 | #[pymethods]
63+
56 | #[pymethods]
6464
| ^^^^^^^^^^^^
6565
note: candidate #2 is defined in an impl for the type `EqAndRichcmp`
66-
--> tests/ui/invalid_proto_pymethods.rs:55:1
66+
--> tests/ui/invalid_proto_pymethods.rs:56:1
6767
|
68-
55 | #[pymethods]
68+
56 | #[pymethods]
6969
| ^^^^^^^^^^^^
7070
= note: this error originates in the attribute macro `pymethods` (in Nightly builds, run with -Z macro-backtrace for more info)

tests/ui/invalid_pyclass_args.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![feature(arbitrary_self_types)]
12
use pyo3::prelude::*;
23
use std::fmt::{Display, Formatter};
34

0 commit comments

Comments
 (0)