-
Notifications
You must be signed in to change notification settings - Fork 99
Disallow duplicated enum variant indices #628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
e6b0b0f
Add limit for codec indexes
pkhry c986e06
fixup tests
pkhry 56c6b3a
clippy
pkhry 722f02e
fmt
pkhry f2cc6c0
review comments
pkhry 7aa0d89
review comments
pkhry 7b92913
just dissalow duplicate indexes
pkhry 614f2b7
merge master
pkhry 9e3c8a6
clippy
pkhry df86890
fixup test
pkhry 6f31b67
Merge branch 'master' into pkhry/codec-indexes
pkhry f2255ee
syn 1.0 -> 2.0
pkhry add9eae
review comments
pkhry 77396b9
remove const eval
pkhry a25db72
fixup ui tests
pkhry 9112b92
fmt
pkhry File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,17 @@ | ||
#[derive(::parity_scale_codec::Decode, ::parity_scale_codec::Encode)] | ||
#[codec(crate = ::parity_scale_codec)] | ||
enum T { | ||
A = 3, | ||
#[codec(index = 3)] | ||
B, | ||
} | ||
|
||
#[derive(::parity_scale_codec::Decode, ::parity_scale_codec::Encode)] | ||
#[codec(crate = ::parity_scale_codec)] | ||
enum T1 { | ||
A, | ||
#[codec(index = 0)] | ||
B, | ||
} | ||
|
||
fn main() {} |
This file contains hidden or 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,23 @@ | ||
error: scale codec error: Invalid variant index, the variant index is duplicated. | ||
--> tests/scale_codec_ui/codec_duplicate_index.rs:5:2 | ||
| | ||
5 | #[codec(index = 3)] | ||
| ^ | ||
|
||
error: Variant index used here. | ||
--> tests/scale_codec_ui/codec_duplicate_index.rs:4:2 | ||
| | ||
4 | A = 3, | ||
| ^ | ||
|
||
error: scale codec error: Invalid variant index, the variant index is duplicated. | ||
--> tests/scale_codec_ui/codec_duplicate_index.rs:13:2 | ||
| | ||
13 | #[codec(index = 0)] | ||
| ^ | ||
|
||
error: Variant index used here. | ||
--> tests/scale_codec_ui/codec_duplicate_index.rs:12:2 | ||
| | ||
12 | A, | ||
| ^ |
16 changes: 16 additions & 0 deletions
16
tests/scale_codec_ui/discriminant_variant_counted_in_default_index.rs
This file contains hidden or 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,16 @@ | ||
#[derive(::parity_scale_codec::Decode, ::parity_scale_codec::Encode)] | ||
#[codec(crate = ::parity_scale_codec)] | ||
enum T { | ||
A = 1, | ||
B, | ||
} | ||
|
||
#[derive(::parity_scale_codec::Decode, ::parity_scale_codec::Encode)] | ||
#[codec(crate = ::parity_scale_codec)] | ||
enum T2 { | ||
#[codec(index = 1)] | ||
A, | ||
B, | ||
} | ||
|
||
fn main() {} |
23 changes: 23 additions & 0 deletions
23
tests/scale_codec_ui/discriminant_variant_counted_in_default_index.stderr
This file contains hidden or 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,23 @@ | ||
error: scale codec error: Invalid variant index, the variant index is duplicated. | ||
--> tests/scale_codec_ui/discriminant_variant_counted_in_default_index.rs:5:2 | ||
| | ||
5 | B, | ||
| ^ | ||
|
||
error: Variant index used here. | ||
--> tests/scale_codec_ui/discriminant_variant_counted_in_default_index.rs:4:2 | ||
| | ||
4 | A = 1, | ||
| ^ | ||
|
||
error: scale codec error: Invalid variant index, the variant index is duplicated. | ||
--> tests/scale_codec_ui/discriminant_variant_counted_in_default_index.rs:13:2 | ||
| | ||
13 | B, | ||
| ^ | ||
|
||
error: Variant index used here. | ||
--> tests/scale_codec_ui/discriminant_variant_counted_in_default_index.rs:11:2 | ||
| | ||
11 | #[codec(index = 1)] | ||
| ^ |
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.