-
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.
Underline the correct alternative variant in case of error. (#98)
Fix #97. Small PR to underline the correct alternative variant when they are not written in order.
- Loading branch information
1 parent
ea9c4f0
commit 483e933
Showing
5 changed files
with
37 additions
and
5 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
num_enum/tests/try_build/compile_fail/alternative_clashes_with_its_discriminant.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,10 @@ | ||
#[derive(num_enum::TryFromPrimitive)] | ||
#[repr(u8)] | ||
enum Numbers { | ||
Zero = 0, | ||
#[num_enum(alternatives = [3,1,4])] | ||
One = 1, | ||
Two = 2, | ||
} | ||
|
||
fn main() {} |
5 changes: 5 additions & 0 deletions
5
num_enum/tests/try_build/compile_fail/alternative_clashes_with_its_discriminant.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,5 @@ | ||
error: '1' in the alternative values is already attributed as the discriminant of this variant | ||
--> tests/try_build/compile_fail/alternative_clashes_with_its_discriminant.rs:5:34 | ||
| | ||
5 | #[num_enum(alternatives = [3,1,4])] | ||
| ^ |
10 changes: 10 additions & 0 deletions
10
num_enum/tests/try_build/compile_fail/alternative_clashes_with_variant_out_of_order.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,10 @@ | ||
#[derive(num_enum::TryFromPrimitive)] | ||
#[repr(u8)] | ||
enum Numbers { | ||
Zero = 0, | ||
#[num_enum(alternatives = [5,7,0,3])] | ||
One = 1, | ||
Two = 2, | ||
} | ||
|
||
fn main() {} |
5 changes: 5 additions & 0 deletions
5
num_enum/tests/try_build/compile_fail/alternative_clashes_with_variant_out_of_order.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,5 @@ | ||
error: '0' in the alternative values is already attributed to a previous variant | ||
--> tests/try_build/compile_fail/alternative_clashes_with_variant_out_of_order.rs:5:36 | ||
| | ||
5 | #[num_enum(alternatives = [5,7,0,3])] | ||
| ^ |
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