pyo3/tests/ui/invalid_pyclass_args.stderr

224 lines
7.6 KiB
Plaintext
Raw Normal View History

feat: Add 'ord' option for PyClass and corresponding tests (#4202) * feat: Add 'ord' option for PyClass and corresponding tests Updated the macros back-end to include 'ord' as an option for PyClass allowing for Python-style ordering comparison of enum variants. Additionally, test cases to verify the proper functioning of this new feature have been introduced. * update: fix formatting with cargo fmt * update: documented added feature in newsfragments * update: updated saved errors for comparison test for invalid pyclass args * update: removed nested match arms and extended cases for ordering instead * update: alphabetically ordered entries * update: added section to class documentation with example for using ord argument. * refactor: reduced duplication of code using closure to process tokens. * update: used ensure_spanned macro to emit compile time errors for uses of ord on complex enums or structs, updated test errors for bad compile cases * fix: remove errant character * update: added note about PartialOrd being required. * feat: implemented ordering for structs and complex enums. Retained the equality logic for simple enums until PartialEq is deprecated. * update: adjusted compile time error checks for missing PartialOrd implementations. Refactored growing set of comparison tests for simple and complex enums and structs into separate test file. * fix: updated with clippy findings * update: added not to pyclass parameters on ord (assumes that eq will be implemented and merged first) * update: rebased on main after merging of `eq` feature * update: format update * update: update all test output and doc tests * Update guide/src/class.md Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com> * Update pyo3-macros-backend/src/pyclass.rs Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com> * Update newsfragments/4202.added.md Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com> * Update guide/pyclass-parameters.md Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com> * update: added note about `ord` implementation with example. * fix doc formatting --------- Co-authored-by: Michael Gilbert <git.3mc1o@aleeas.com> Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>
2024-06-07 19:08:53 +00:00
error: expected one of: `crate`, `dict`, `eq`, `eq_int`, `extends`, `freelist`, `frozen`, `get_all`, `hash`, `mapping`, `module`, `name`, `ord`, `rename_all`, `sequence`, `set_all`, `subclass`, `unsendable`, `weakref`
--> tests/ui/invalid_pyclass_args.rs:3:11
|
3 | #[pyclass(extend=pyo3::types::PyDict)]
| ^^^^^^
error: expected identifier
--> tests/ui/invalid_pyclass_args.rs:6:21
|
6 | #[pyclass(extends = "PyDict")]
| ^^^^^^^^
error: expected string literal
--> tests/ui/invalid_pyclass_args.rs:9:18
|
9 | #[pyclass(name = m::MyClass)]
| ^
error: expected a single identifier in double quotes
--> tests/ui/invalid_pyclass_args.rs:12:18
2020-12-12 09:50:25 +00:00
|
12 | #[pyclass(name = "Custom Name")]
| ^^^^^^^^^^^^^
error: expected string literal
--> tests/ui/invalid_pyclass_args.rs:15:18
2020-12-12 09:50:25 +00:00
|
15 | #[pyclass(name = CustomName)]
| ^^^^^^^^^^
error: expected string literal
--> tests/ui/invalid_pyclass_args.rs:18:24
|
18 | #[pyclass(rename_all = camelCase)]
| ^^^^^^^^^
error: expected a valid renaming rule, possible values are: "camelCase", "kebab-case", "lowercase", "PascalCase", "SCREAMING-KEBAB-CASE", "SCREAMING_SNAKE_CASE", "snake_case", "UPPERCASE"
--> tests/ui/invalid_pyclass_args.rs:21:24
|
21 | #[pyclass(rename_all = "Camel-Case")]
| ^^^^^^^^^^^^
error: expected string literal
--> tests/ui/invalid_pyclass_args.rs:24:20
|
24 | #[pyclass(module = my_module)]
| ^^^^^^^^^
feat: Add 'ord' option for PyClass and corresponding tests (#4202) * feat: Add 'ord' option for PyClass and corresponding tests Updated the macros back-end to include 'ord' as an option for PyClass allowing for Python-style ordering comparison of enum variants. Additionally, test cases to verify the proper functioning of this new feature have been introduced. * update: fix formatting with cargo fmt * update: documented added feature in newsfragments * update: updated saved errors for comparison test for invalid pyclass args * update: removed nested match arms and extended cases for ordering instead * update: alphabetically ordered entries * update: added section to class documentation with example for using ord argument. * refactor: reduced duplication of code using closure to process tokens. * update: used ensure_spanned macro to emit compile time errors for uses of ord on complex enums or structs, updated test errors for bad compile cases * fix: remove errant character * update: added note about PartialOrd being required. * feat: implemented ordering for structs and complex enums. Retained the equality logic for simple enums until PartialEq is deprecated. * update: adjusted compile time error checks for missing PartialOrd implementations. Refactored growing set of comparison tests for simple and complex enums and structs into separate test file. * fix: updated with clippy findings * update: added not to pyclass parameters on ord (assumes that eq will be implemented and merged first) * update: rebased on main after merging of `eq` feature * update: format update * update: update all test output and doc tests * Update guide/src/class.md Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com> * Update pyo3-macros-backend/src/pyclass.rs Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com> * Update newsfragments/4202.added.md Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com> * Update guide/pyclass-parameters.md Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com> * update: added note about `ord` implementation with example. * fix doc formatting --------- Co-authored-by: Michael Gilbert <git.3mc1o@aleeas.com> Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>
2024-06-07 19:08:53 +00:00
error: expected one of: `crate`, `dict`, `eq`, `eq_int`, `extends`, `freelist`, `frozen`, `get_all`, `hash`, `mapping`, `module`, `name`, `ord`, `rename_all`, `sequence`, `set_all`, `subclass`, `unsendable`, `weakref`
--> tests/ui/invalid_pyclass_args.rs:27:11
|
27 | #[pyclass(weakrev)]
| ^^^^^^^
error: a `#[pyclass]` cannot be both a `mapping` and a `sequence`
--> tests/ui/invalid_pyclass_args.rs:31:8
|
31 | struct CannotBeMappingAndSequence {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: `eq_int` can only be used on simple enums.
--> tests/ui/invalid_pyclass_args.rs:52:11
|
52 | #[pyclass(eq_int)]
| ^^^^^^
error: The `hash` option requires the `frozen` option.
--> tests/ui/invalid_pyclass_args.rs:59:11
|
59 | #[pyclass(hash)]
| ^^^^
error: The `hash` option requires the `eq` option.
--> tests/ui/invalid_pyclass_args.rs:59:11
|
59 | #[pyclass(hash)]
| ^^^^
feat: Add 'ord' option for PyClass and corresponding tests (#4202) * feat: Add 'ord' option for PyClass and corresponding tests Updated the macros back-end to include 'ord' as an option for PyClass allowing for Python-style ordering comparison of enum variants. Additionally, test cases to verify the proper functioning of this new feature have been introduced. * update: fix formatting with cargo fmt * update: documented added feature in newsfragments * update: updated saved errors for comparison test for invalid pyclass args * update: removed nested match arms and extended cases for ordering instead * update: alphabetically ordered entries * update: added section to class documentation with example for using ord argument. * refactor: reduced duplication of code using closure to process tokens. * update: used ensure_spanned macro to emit compile time errors for uses of ord on complex enums or structs, updated test errors for bad compile cases * fix: remove errant character * update: added note about PartialOrd being required. * feat: implemented ordering for structs and complex enums. Retained the equality logic for simple enums until PartialEq is deprecated. * update: adjusted compile time error checks for missing PartialOrd implementations. Refactored growing set of comparison tests for simple and complex enums and structs into separate test file. * fix: updated with clippy findings * update: added not to pyclass parameters on ord (assumes that eq will be implemented and merged first) * update: rebased on main after merging of `eq` feature * update: format update * update: update all test output and doc tests * Update guide/src/class.md Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com> * Update pyo3-macros-backend/src/pyclass.rs Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com> * Update newsfragments/4202.added.md Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com> * Update guide/pyclass-parameters.md Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com> * update: added note about `ord` implementation with example. * fix doc formatting --------- Co-authored-by: Michael Gilbert <git.3mc1o@aleeas.com> Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>
2024-06-07 19:08:53 +00:00
error: The `ord` option requires the `eq` option.
--> tests/ui/invalid_pyclass_args.rs:74:11
|
74 | #[pyclass(ord)]
| ^^^
error[E0592]: duplicate definitions with name `__pymethod___richcmp____`
--> tests/ui/invalid_pyclass_args.rs:36:1
|
36 | #[pyclass(eq)]
| ^^^^^^^^^^^^^^ duplicate definitions for `__pymethod___richcmp____`
...
40 | #[pymethods]
| ------------ other definition for `__pymethod___richcmp____`
|
= note: this error originates in the attribute macro `pyclass` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0592]: duplicate definitions with name `__pymethod___hash____`
--> tests/ui/invalid_pyclass_args.rs:63:1
|
63 | #[pyclass(frozen, eq, hash)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ duplicate definitions for `__pymethod___hash____`
...
67 | #[pymethods]
| ------------ other definition for `__pymethod___hash____`
|
= note: this error originates in the attribute macro `pyclass` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0369]: binary operation `==` cannot be applied to type `&EqOptRequiresEq`
--> tests/ui/invalid_pyclass_args.rs:33:11
|
33 | #[pyclass(eq)]
| ^^
|
note: an implementation of `PartialEq` might be missing for `EqOptRequiresEq`
--> tests/ui/invalid_pyclass_args.rs:34:1
|
34 | struct EqOptRequiresEq {}
| ^^^^^^^^^^^^^^^^^^^^^^ must implement `PartialEq`
help: consider annotating `EqOptRequiresEq` with `#[derive(PartialEq)]`
|
34 + #[derive(PartialEq)]
35 | struct EqOptRequiresEq {}
|
error[E0369]: binary operation `!=` cannot be applied to type `&EqOptRequiresEq`
--> tests/ui/invalid_pyclass_args.rs:33:11
|
33 | #[pyclass(eq)]
| ^^
|
note: an implementation of `PartialEq` might be missing for `EqOptRequiresEq`
--> tests/ui/invalid_pyclass_args.rs:34:1
|
34 | struct EqOptRequiresEq {}
| ^^^^^^^^^^^^^^^^^^^^^^ must implement `PartialEq`
help: consider annotating `EqOptRequiresEq` with `#[derive(PartialEq)]`
|
34 + #[derive(PartialEq)]
35 | struct EqOptRequiresEq {}
|
error[E0034]: multiple applicable items in scope
--> tests/ui/invalid_pyclass_args.rs:36:1
|
36 | #[pyclass(eq)]
| ^^^^^^^^^^^^^^ multiple `__pymethod___richcmp____` found
|
note: candidate #1 is defined in an impl for the type `EqOptAndManualRichCmp`
--> tests/ui/invalid_pyclass_args.rs:36:1
|
36 | #[pyclass(eq)]
| ^^^^^^^^^^^^^^
note: candidate #2 is defined in an impl for the type `EqOptAndManualRichCmp`
--> tests/ui/invalid_pyclass_args.rs:40:1
|
40 | #[pymethods]
| ^^^^^^^^^^^^
= note: this error originates in the attribute macro `pyclass` 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_pyclass_args.rs:40:1
|
40 | #[pymethods]
| ^^^^^^^^^^^^ multiple `__pymethod___richcmp____` found
|
note: candidate #1 is defined in an impl for the type `EqOptAndManualRichCmp`
--> tests/ui/invalid_pyclass_args.rs:36:1
|
36 | #[pyclass(eq)]
| ^^^^^^^^^^^^^^
note: candidate #2 is defined in an impl for the type `EqOptAndManualRichCmp`
--> tests/ui/invalid_pyclass_args.rs:40:1
|
40 | #[pymethods]
| ^^^^^^^^^^^^
= 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 `HashOptRequiresHash: Hash` is not satisfied
--> tests/ui/invalid_pyclass_args.rs:55:23
|
55 | #[pyclass(frozen, eq, hash)]
| ^^^^ the trait `Hash` is not implemented for `HashOptRequiresHash`
|
help: consider annotating `HashOptRequiresHash` with `#[derive(Hash)]`
|
57 + #[derive(Hash)]
58 | struct HashOptRequiresHash;
|
error[E0034]: multiple applicable items in scope
--> tests/ui/invalid_pyclass_args.rs:63:1
|
63 | #[pyclass(frozen, eq, hash)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ multiple `__pymethod___hash____` found
|
note: candidate #1 is defined in an impl for the type `HashOptAndManualHash`
--> tests/ui/invalid_pyclass_args.rs:63:1
|
63 | #[pyclass(frozen, eq, hash)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: candidate #2 is defined in an impl for the type `HashOptAndManualHash`
--> tests/ui/invalid_pyclass_args.rs:67:1
|
67 | #[pymethods]
| ^^^^^^^^^^^^
= note: this error originates in the attribute macro `pyclass` 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_pyclass_args.rs:67:1
|
67 | #[pymethods]
| ^^^^^^^^^^^^ multiple `__pymethod___hash____` found
|
note: candidate #1 is defined in an impl for the type `HashOptAndManualHash`
--> tests/ui/invalid_pyclass_args.rs:63:1
|
63 | #[pyclass(frozen, eq, hash)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: candidate #2 is defined in an impl for the type `HashOptAndManualHash`
--> tests/ui/invalid_pyclass_args.rs:67:1
|
67 | #[pymethods]
| ^^^^^^^^^^^^
= note: this error originates in the attribute macro `pymethods` (in Nightly builds, run with -Z macro-backtrace for more info)