-
Notifications
You must be signed in to change notification settings - Fork 778
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix ambiguous associated item error (#4725)
* Add test for ambiguous associated item The `#[pyclass]` macro implements `IntoPyObject` for the annotated enum. When the enum has any of `Error`, `Output` or `Target` as members, this clashes with the associated types of `IntoPyObject`. This also happens when deriving `IntoPyObject` directly. * Fix #4723: ambiguous associated item in #[pyclass] This uses the fix described in rust-lang/rust#57644 Also apply fix to `#[derive(IntoPyObject)]`.
- Loading branch information
1 parent
ab999ae
commit 02eb2a1
Showing
5 changed files
with
42 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix `ambiguous_associated_items` lint error in `#[pyclass]` and `#[derive(IntoPyObject)]` macros. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use pyo3::prelude::*; | ||
|
||
#[pyclass(eq)] | ||
#[derive(PartialEq)] | ||
pub enum SimpleItems { | ||
Error, | ||
Output, | ||
Target, | ||
} | ||
|
||
#[pyclass] | ||
pub enum ComplexItems { | ||
Error(PyObject), | ||
Output(PyObject), | ||
Target(PyObject), | ||
} | ||
|
||
#[derive(IntoPyObject)] | ||
enum DeriveItems { | ||
Error(PyObject), | ||
Output(PyObject), | ||
Target(PyObject), | ||
} | ||
|
||
fn main() {} |