-
Notifications
You must be signed in to change notification settings - Fork 806
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
196 additions
and
0 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
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,90 @@ | ||
use pyo3::IntoPyObject; | ||
|
||
#[derive(IntoPyObject)] | ||
struct Foo(); | ||
|
||
#[derive(IntoPyObject)] | ||
struct Foo2 {} | ||
|
||
#[derive(IntoPyObject)] | ||
enum EmptyEnum {} | ||
|
||
#[derive(IntoPyObject)] | ||
enum EnumWithEmptyTupleVar { | ||
EmptyTuple(), | ||
Valid(String), | ||
} | ||
|
||
#[derive(IntoPyObject)] | ||
enum EnumWithEmptyStructVar { | ||
EmptyStruct {}, | ||
Valid(String), | ||
} | ||
|
||
#[derive(IntoPyObject)] | ||
#[pyo3(transparent)] | ||
struct EmptyTransparentTup(); | ||
|
||
#[derive(IntoPyObject)] | ||
#[pyo3(transparent)] | ||
struct EmptyTransparentStruct {} | ||
|
||
#[derive(IntoPyObject)] | ||
enum EnumWithTransparentEmptyTupleVar { | ||
#[pyo3(transparent)] | ||
EmptyTuple(), | ||
Valid(String), | ||
} | ||
|
||
#[derive(IntoPyObject)] | ||
enum EnumWithTransparentEmptyStructVar { | ||
#[pyo3(transparent)] | ||
EmptyStruct {}, | ||
Valid(String), | ||
} | ||
|
||
#[derive(IntoPyObject)] | ||
#[pyo3(transparent)] | ||
struct TransparentTupTooManyFields(String, String); | ||
|
||
#[derive(IntoPyObject)] | ||
#[pyo3(transparent)] | ||
struct TransparentStructTooManyFields { | ||
foo: String, | ||
bar: String, | ||
} | ||
|
||
#[derive(IntoPyObject)] | ||
enum EnumWithTransparentTupleTooMany { | ||
#[pyo3(transparent)] | ||
EmptyTuple(String, String), | ||
Valid(String), | ||
} | ||
|
||
#[derive(IntoPyObject)] | ||
enum EnumWithTransparentStructTooMany { | ||
#[pyo3(transparent)] | ||
EmptyStruct { | ||
foo: String, | ||
bar: String, | ||
}, | ||
Valid(String), | ||
} | ||
|
||
#[derive(IntoPyObject)] | ||
#[pyo3(unknown = "should not work")] | ||
struct UnknownContainerAttr { | ||
a: String, | ||
} | ||
|
||
#[derive(IntoPyObject)] | ||
union Union { | ||
a: usize, | ||
} | ||
|
||
#[derive(IntoPyObject)] | ||
enum UnitEnum { | ||
Unit, | ||
} | ||
|
||
fn main() {} |
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,105 @@ | ||
error: cannot derive `IntoPyObject` for empty structs and variants | ||
--> tests/ui/invalid_intopy_derive.rs:4:11 | ||
| | ||
4 | struct Foo(); | ||
| ^^ | ||
|
||
error: cannot derive `IntoPyObject` for empty structs and variants | ||
--> tests/ui/invalid_intopy_derive.rs:7:13 | ||
| | ||
7 | struct Foo2 {} | ||
| ^^ | ||
|
||
error: cannot derive `IntoPyObject` for empty enum | ||
--> tests/ui/invalid_intopy_derive.rs:10:6 | ||
| | ||
10 | enum EmptyEnum {} | ||
| ^^^^^^^^^ | ||
|
||
error: cannot derive `IntoPyObject` for empty structs and variants | ||
--> tests/ui/invalid_intopy_derive.rs:14:15 | ||
| | ||
14 | EmptyTuple(), | ||
| ^^ | ||
|
||
error: cannot derive `IntoPyObject` for empty structs and variants | ||
--> tests/ui/invalid_intopy_derive.rs:20:17 | ||
| | ||
20 | EmptyStruct {}, | ||
| ^^ | ||
|
||
error: cannot derive `IntoPyObject` for empty structs and variants | ||
--> tests/ui/invalid_intopy_derive.rs:26:27 | ||
| | ||
26 | struct EmptyTransparentTup(); | ||
| ^^ | ||
|
||
error: cannot derive `IntoPyObject` for empty structs and variants | ||
--> tests/ui/invalid_intopy_derive.rs:30:31 | ||
| | ||
30 | struct EmptyTransparentStruct {} | ||
| ^^ | ||
|
||
error: cannot derive `IntoPyObject` for empty structs and variants | ||
--> tests/ui/invalid_intopy_derive.rs:35:15 | ||
| | ||
35 | EmptyTuple(), | ||
| ^^ | ||
|
||
error: cannot derive `IntoPyObject` for empty structs and variants | ||
--> tests/ui/invalid_intopy_derive.rs:42:17 | ||
| | ||
42 | EmptyStruct {}, | ||
| ^^ | ||
|
||
error: transparent structs and variants can only have 1 field | ||
--> tests/ui/invalid_intopy_derive.rs:48:35 | ||
| | ||
48 | struct TransparentTupTooManyFields(String, String); | ||
| ^^^^^^^^^^^^^^^^ | ||
|
||
error: transparent structs and variants can only have 1 field | ||
--> tests/ui/invalid_intopy_derive.rs:52:39 | ||
| | ||
52 | struct TransparentStructTooManyFields { | ||
| _______________________________________^ | ||
53 | | foo: String, | ||
54 | | bar: String, | ||
55 | | } | ||
| |_^ | ||
|
||
error: transparent structs and variants can only have 1 field | ||
--> tests/ui/invalid_intopy_derive.rs:60:15 | ||
| | ||
60 | EmptyTuple(String, String), | ||
| ^^^^^^^^^^^^^^^^ | ||
|
||
error: transparent structs and variants can only have 1 field | ||
--> tests/ui/invalid_intopy_derive.rs:67:17 | ||
| | ||
67 | EmptyStruct { | ||
| _________________^ | ||
68 | | foo: String, | ||
69 | | bar: String, | ||
70 | | }, | ||
| |_____^ | ||
|
||
error: expected `transparent` or `crate` | ||
--> tests/ui/invalid_intopy_derive.rs:75:8 | ||
| | ||
75 | #[pyo3(unknown = "should not work")] | ||
| ^^^^^^^ | ||
|
||
error: #[derive(`IntoPyObject`)] is not supported for unions | ||
--> tests/ui/invalid_intopy_derive.rs:81:1 | ||
| | ||
81 | union Union { | ||
| ^^^^^ | ||
|
||
error: cannot derive `IntoPyObject` for empty structs and variants | ||
--> tests/ui/invalid_intopy_derive.rs:85:10 | ||
| | ||
85 | #[derive(IntoPyObject)] | ||
| ^^^^^^^^^^^^ | ||
| | ||
= note: this error originates in the derive macro `IntoPyObject` (in Nightly builds, run with -Z macro-backtrace for more info) |