forked from paritytech/substrate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make types within
generate_solution_type
macro explicit (paritytech…
…#8447) * make types within `generate_solution_type` macro explicit Closes paritytech#8444. Just changes the parsing logic for that macro; does not change any emitted code. The associated types associated with the macro now require explicit, keyword-style declaration. **Old**: ```rust sp_npos_elections::generate_solution_type!( #[compact] pub struct TestCompact::<VoterIndex, TargetIndex, PerU16>(16) ); ``` **New**: ```rust sp_npos_elections::generate_solution_type!( #[compact] pub struct TestCompact::<VoterIndex = VoterIndex, CandidateIndex = TargetIndex, Accuracy = PerU16>(16) ); ``` * un-ignore doc-tests * use new form in bin/node/runtime/ * rename CandidateIndex -> TargetIndex * add tests demonstrating some potential compile failures
- Loading branch information
1 parent
de9c90c
commit 0de37ac
Showing
17 changed files
with
145 additions
and
16 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
9 changes: 9 additions & 0 deletions
9
primitives/npos-elections/compact/tests/ui/fail/missing_accuracy.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,9 @@ | ||
use sp_npos_elections_compact::generate_solution_type; | ||
|
||
generate_solution_type!(pub struct TestSolution::< | ||
VoterIndex = u16, | ||
TargetIndex = u8, | ||
Perbill, | ||
>(8)); | ||
|
||
fn main() {} |
5 changes: 5 additions & 0 deletions
5
primitives/npos-elections/compact/tests/ui/fail/missing_accuracy.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: Expected binding: `Accuracy = ...` | ||
--> $DIR/missing_accuracy.rs:6:2 | ||
| | ||
6 | Perbill, | ||
| ^^^^^^^ |
9 changes: 9 additions & 0 deletions
9
primitives/npos-elections/compact/tests/ui/fail/missing_target.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,9 @@ | ||
use sp_npos_elections_compact::generate_solution_type; | ||
|
||
generate_solution_type!(pub struct TestSolution::< | ||
VoterIndex = u16, | ||
u8, | ||
Accuracy = Perbill, | ||
>(8)); | ||
|
||
fn main() {} |
5 changes: 5 additions & 0 deletions
5
primitives/npos-elections/compact/tests/ui/fail/missing_target.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: Expected binding: `TargetIndex = ...` | ||
--> $DIR/missing_target.rs:5:2 | ||
| | ||
5 | u8, | ||
| ^^ |
9 changes: 9 additions & 0 deletions
9
primitives/npos-elections/compact/tests/ui/fail/missing_voter.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,9 @@ | ||
use sp_npos_elections_compact::generate_solution_type; | ||
|
||
generate_solution_type!(pub struct TestSolution::< | ||
u16, | ||
TargetIndex = u8, | ||
Accuracy = Perbill, | ||
>(8)); | ||
|
||
fn main() {} |
5 changes: 5 additions & 0 deletions
5
primitives/npos-elections/compact/tests/ui/fail/missing_voter.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: Expected binding: `VoterIndex = ...` | ||
--> $DIR/missing_voter.rs:4:2 | ||
| | ||
4 | u16, | ||
| ^^^ |
9 changes: 9 additions & 0 deletions
9
primitives/npos-elections/compact/tests/ui/fail/no_annotations.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,9 @@ | ||
use sp_npos_elections_compact::generate_solution_type; | ||
|
||
generate_solution_type!(pub struct TestSolution::< | ||
u16, | ||
u8, | ||
Perbill, | ||
>(8)); | ||
|
||
fn main() {} |
5 changes: 5 additions & 0 deletions
5
primitives/npos-elections/compact/tests/ui/fail/no_annotations.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: Expected binding: `VoterIndex = ...` | ||
--> $DIR/no_annotations.rs:4:2 | ||
| | ||
4 | u16, | ||
| ^^^ |
9 changes: 9 additions & 0 deletions
9
primitives/npos-elections/compact/tests/ui/fail/swap_voter_target.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,9 @@ | ||
use sp_npos_elections_compact::generate_solution_type; | ||
|
||
generate_solution_type!(pub struct TestSolution::< | ||
TargetIndex = u16, | ||
VoterIndex = u8, | ||
Accuracy = Perbill, | ||
>(8)); | ||
|
||
fn main() {} |
5 changes: 5 additions & 0 deletions
5
primitives/npos-elections/compact/tests/ui/fail/swap_voter_target.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: Expected `VoterIndex` | ||
--> $DIR/swap_voter_target.rs:4:2 | ||
| | ||
4 | TargetIndex = u16, | ||
| ^^^^^^^^^^^ |
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