refactor overseer into proc-macro based pattern (#2962)

This commit is contained in:
Bernhard Schuster
2021-07-08 21:09:26 +02:00
committed by GitHub
parent 2510bfc5d7
commit 3c9104daff
119 changed files with 5675 additions and 3864 deletions
@@ -0,0 +1,13 @@
#![allow(dead_code)]
use polkadot_overseer_all_subsystems_gen::AllSubsystemsGen;
#[derive(Clone, AllSubsystemsGen)]
enum AllSubsystems<A,B> {
A(A),
B(B),
}
fn main() {
let all = AllSubsystems::<u8,u16>::A(0u8);
}
@@ -0,0 +1,5 @@
error: expected `struct`
--> $DIR/err-01-enum.rs:6:1
|
6 | enum AllSubsystems<A,B> {
| ^^^^
@@ -0,0 +1,16 @@
#![allow(dead_code)]
use polkadot_overseer_all_subsystems_gen::AllSubsystemsGen;
#[derive(Clone, AllSubsystemsGen)]
struct AllSubsystems<X> {
a: X,
b: X,
}
fn main() {
let all = AllSubsystems::<u16> {
a: 0_u16,
b: 1_u16,
};
let _all = all.replace_a(77u8);
}
@@ -0,0 +1,14 @@
error: Generic type parameters may only be used for exactly one field, but is used more than once.
--> $DIR/err-01-generic-used-twice.rs:6:5
|
6 | a: X,
| ^
error[E0599]: no method named `replace_a` found for struct `AllSubsystems<u16>` in the current scope
--> $DIR/err-01-generic-used-twice.rs:15:17
|
5 | struct AllSubsystems<X> {
| ----------------------- method `replace_a` not found for this
...
15 | let _all = all.replace_a(77u8);
| ^^^^^^^^^ method not found in `AllSubsystems<u16>`
@@ -0,0 +1,17 @@
#![allow(dead_code)]
use polkadot_overseer_all_subsystems_gen::AllSubsystemsGen;
#[derive(Clone, AllSubsystemsGen)]
struct AllSubsystems {
a: f32,
b: u16,
}
fn main() {
let all = AllSubsystems {
a: 0_f32,
b: 1_u16,
};
let _all = all.replace_a(77u8);
}
@@ -0,0 +1,14 @@
error: struct must have at least one generic parameter.
--> $DIR/err-01-no-generic.rs:6:8
|
6 | struct AllSubsystems {
| ^^^^^^^^^^^^^
error[E0599]: no method named `replace_a` found for struct `AllSubsystems` in the current scope
--> $DIR/err-01-no-generic.rs:16:17
|
6 | struct AllSubsystems {
| -------------------- method `replace_a` not found for this
...
16 | let _all = all.replace_a(77u8);
| ^^^^^^^^^ method not found in `AllSubsystems`
@@ -0,0 +1,14 @@
error: Generic type parameters may only be used once have at least one generic parameter.
--> $DIR/err-01-no-generics.rs:7:5
|
7 | a: X,
| ^
error[E0599]: no method named `replace_a` found for struct `AllSubsystems<u16>` in the current scope
--> $DIR/err-01-no-generics.rs:16:17
|
6 | struct AllSubsystems<X> {
| ----------------------- method `replace_a` not found for this
...
16 | let _all = all.replace_a(77u8);
| ^^^^^^^^^ method not found in `AllSubsystems<u16>`
@@ -0,0 +1,17 @@
#![allow(dead_code)]
use polkadot_overseer_all_subsystems_gen::AllSubsystemsGen;
#[derive(Clone, AllSubsystemsGen)]
struct AllSubsystems<A, B> {
a: A,
b: B,
}
fn main() {
let all = AllSubsystems::<u8, u16> {
a: 0u8,
b: 1u16,
};
let _all: AllSubsystems<_,_> = all.replace_a::<u32>(777_777u32);
}