Create a more rigid overseer builder pattern that fails at compile time (#4753)

Introduces `Missing<Field>` and `Init<Field>` states, that are used in place of builder generics, and make this possible.
This commit is contained in:
Vsevolod Stakhov
2022-02-09 16:01:16 +00:00
committed by GitHub
parent 227e39bff6
commit 84f55cc8d5
20 changed files with 891 additions and 267 deletions
@@ -0,0 +1,15 @@
error[E0599]: no method named `build` found for struct `OverseerBuilder<Init<DummySpawner>, Init<AwesomeSubSys>, Missing<f64>>` in the current scope
--> tests/ui/err-05-missing-field.rs:59:4
|
22 | #[overlord(signal=SigSigSig, error=OverseerError, event=Event, gen=AllMessages)]
| -------------------------------------------------------------------------------- method `build` not found for this
...
59 | .build()
| ^^^^^ method not found in `OverseerBuilder<Init<DummySpawner>, Init<AwesomeSubSys>, Missing<f64>>`
|
= note: the method was found for
- `OverseerBuilder<Init<S>, Init<AwesomeSubSys>, Init<f64>>`
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following traits define an item `build`, perhaps you need to implement one of them:
candidate #1: `frame_support::traits::hooks::GenesisBuild`
candidate #2: `prometheus::vec::MetricVecBuilder`