-
Notifications
You must be signed in to change notification settings - Fork 34
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
1 parent
55f0b35
commit 2899217
Showing
10 changed files
with
524 additions
and
54 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
56 changes: 56 additions & 0 deletions
56
num_enum/tests/try_build/compile_fail/custom_error_type_parsing.rs
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,56 @@ | ||
#[derive(num_enum::TryFromPrimitive)] | ||
#[num_enum(error_type(name = CustomError))] | ||
#[repr(u8)] | ||
enum MissingConstructor { | ||
Zero, | ||
One, | ||
Two, | ||
} | ||
|
||
#[derive(num_enum::TryFromPrimitive)] | ||
#[num_enum(error_type(constructor = CustomError::new))] | ||
#[repr(u8)] | ||
enum MissingName { | ||
Zero, | ||
One, | ||
Two, | ||
} | ||
|
||
#[derive(num_enum::TryFromPrimitive)] | ||
#[num_enum(error_type(name = CustomError, constructor = CustomError::new, extra = something))] | ||
#[repr(u8)] | ||
enum ExtraAttr { | ||
Zero, | ||
One, | ||
Two, | ||
} | ||
|
||
#[derive(num_enum::TryFromPrimitive)] | ||
#[num_enum(error_type(name = CustomError, constructor = CustomError::new), error_type(name = CustomError, constructor = CustomError::new))] | ||
#[repr(u8)] | ||
enum TwoErrorTypes { | ||
Zero, | ||
One, | ||
Two, | ||
} | ||
|
||
#[derive(num_enum::TryFromPrimitive)] | ||
#[num_enum(error_type(name = CustomError, constructor = CustomError::new))] | ||
#[num_enum(error_type(name = CustomError, constructor = CustomError::new))] | ||
#[repr(u8)] | ||
enum TwoAttrs { | ||
Zero, | ||
One, | ||
Two, | ||
} | ||
|
||
struct CustomError {} | ||
|
||
impl CustomError { | ||
fn new(_: u8) -> CustomError { | ||
CustomError{} | ||
} | ||
} | ||
|
||
fn main() { | ||
} |
29 changes: 29 additions & 0 deletions
29
num_enum/tests/try_build/compile_fail/custom_error_type_parsing.stderr
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,29 @@ | ||
error: num_enum error_type attribute requires `constructor` value | ||
--> tests/try_build/compile_fail/custom_error_type_parsing.rs:2:12 | ||
| | ||
2 | #[num_enum(error_type(name = CustomError))] | ||
| ^^^^^^^^^^ | ||
|
||
error: num_enum error_type attribute requires `name` value | ||
--> tests/try_build/compile_fail/custom_error_type_parsing.rs:11:12 | ||
| | ||
11 | #[num_enum(error_type(constructor = CustomError::new))] | ||
| ^^^^^^^^^^ | ||
|
||
error: expected `name` or `constructor` | ||
--> tests/try_build/compile_fail/custom_error_type_parsing.rs:20:75 | ||
| | ||
20 | #[num_enum(error_type(name = CustomError, constructor = CustomError::new, extra = something))] | ||
| ^^^^^ | ||
|
||
error: num_enum attribute must have at most one error_type | ||
--> tests/try_build/compile_fail/custom_error_type_parsing.rs:29:76 | ||
| | ||
29 | #[num_enum(error_type(name = CustomError, constructor = CustomError::new), error_type(name = CustomError, constructor = CustomError::new))] | ||
| ^^^^^^^^^^ | ||
|
||
error: At most one num_enum error_type attribute may be specified | ||
--> tests/try_build/compile_fail/custom_error_type_parsing.rs:39:1 | ||
| | ||
39 | #[num_enum(error_type(name = CustomError, constructor = CustomError::new))] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
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
Oops, something went wrong.