make types within generate_solution_type macro explicit (#8447)

* make types within `generate_solution_type` macro explicit

Closes #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
This commit is contained in:
Peter Goodspeed-Niklaus
2021-03-28 10:21:06 +02:00
committed by GitHub
parent 2af0de50c9
commit c2dd5e21a4
17 changed files with 145 additions and 16 deletions
@@ -19,3 +19,9 @@ syn = { version = "1.0.58", features = ["full", "visit"] }
quote = "1.0"
proc-macro2 = "1.0.6"
proc-macro-crate = "1.0.0"
[dev-dependencies]
parity-scale-codec = "2.0.1"
sp-arithmetic = { path = "../../arithmetic" }
sp-npos-elections = { path = ".." }
trybuild = "1.0.41"