Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Wrong struct name after #352 merged #410

Closed
fewensa opened this issue Jan 27, 2022 · 0 comments · Fixed by #412
Closed

Wrong struct name after #352 merged #410

fewensa opened this issue Jan 27, 2022 · 0 comments · Fixed by #412

Comments

@fewensa
Copy link
Contributor

fewensa commented Jan 27, 2022

Before #352, the struct name is directly generated by quote! macro

pub struct #type_name #fields

After #352, will create a CompositeDef::struct_def

The question is the sruct_def function will change the name to camel case style

let name = format_ident!("{}", ident.to_camel_case());

After doing this. if we have two upper case words name's struct. like this
https://github.com/darwinia-network/darwinia-common/blob/1861a487b2d15a4831367e2e3ff3e2a73e2e9c8a/frame/staking/src/slashing.rs#L84

The generated code will output some errors.

error[E0412]: cannot find type `RK` in module `runtime_types::darwinia_staking::slashing`
    --> src\runtime.rs:3676:64
     |
3676 |                     runtime_types::darwinia_staking::slashing::RK<
     |                                                                ^^ help: a struct with a similar name exists (notice the capitalization): `Rk`
...
8999 |                 pub struct Rk<_0, _1> {
     |                 --------------------- similarly named struct `Rk` defined here

error[E0412]: cannot find type `RK` in module `runtime_types::darwinia_staking::slashing`
    --> src\runtime.rs:3695:73
     |
3695 |                 type Value = runtime_types::darwinia_staking::slashing::RK<
     |                                                                         ^^ help: a struct with a similar name exists (notice the capitalization): `Rk`
...
8999 |                 pub struct Rk<_0, _1> {
     |                 --------------------- similarly named struct `Rk` defined here

error[E0412]: cannot find type `RK` in module `runtime_types::darwinia_staking::slashing`
    --> src\runtime.rs:4245:68
     |
4245 |                         runtime_types::darwinia_staking::slashing::RK<
     |                                                                    ^^ help: a struct with a similar name exists (notice the capitalization): `Rk`
...
8999 |                 pub struct Rk<_0, _1> {
     |                 --------------------- similarly named struct `Rk` defined here

error[E0412]: cannot find type `RK` in module `runtime_types::darwinia_staking::slashing`
    --> src\runtime.rs:4271:68
     |
4271 |                         runtime_types::darwinia_staking::slashing::RK<
     |                                                                    ^^ help: a struct with a similar name exists (notice the capitalization): `Rk`
...
8999 |                 pub struct Rk<_0, _1> {
     |                 --------------------- similarly named struct `Rk` defined here

error[E0412]: cannot find type `RK` in module `runtime_types::darwinia_staking::slashing`
    --> src\runtime.rs:9018:77
     |
8999 |                 pub struct Rk<_0, _1> {
     |                 --------------------- similarly named struct `Rk` defined here
...
9018 |                     pub slashed: runtime_types::darwinia_staking::slashing::RK<_0, _0>,
     |                                                                             ^^ help: a struct with a similar name exists (notice the capitalization): `Rk`

error[E0412]: cannot find type `RK` in module `runtime_types::darwinia_staking::slashing`
    --> src\runtime.rs:9019:78
     |
8999 |                 pub struct Rk<_0, _1> {
     |                 --------------------- similarly named struct `Rk` defined here
...
9019 |                     pub paid_out: runtime_types::darwinia_staking::slashing::RK<_0, _0>,
     |                                                                              ^^ help: a struct with a similar name exists (notice the capitalization): `Rk`

error[E0412]: cannot find type `RK` in module `runtime_types::darwinia_staking::slashing`
    --> src\runtime.rs:9172:73
     |
8999 |                 pub struct Rk<_0, _1> {
     |                 --------------------- similarly named struct `Rk` defined here
...
9172 |                     pub own: runtime_types::darwinia_staking::slashing::RK<_1, _1>,
     |                                                                         ^^ help: a struct with a similar name exists (notice the capitalization): `Rk`

error[E0412]: cannot find type `RK` in module `runtime_types::darwinia_staking::slashing`
    --> src\runtime.rs:9175:68
     |
8999 |                 pub struct Rk<_0, _1> {
     |                 --------------------- similarly named struct `Rk` defined here
...
9175 |                         runtime_types::darwinia_staking::slashing::RK<_1, _1>,
     |                                                                    ^^ help: a struct with a similar name exists (notice the capitalization): `Rk`

error[E0412]: cannot find type `RK` in module `runtime_types::darwinia_staking::slashing`
    --> src\runtime.rs:9178:76
     |
8999 |                 pub struct Rk<_0, _1> {
     |                 --------------------- similarly named struct `Rk` defined here
...
9178 |                     pub payout: runtime_types::darwinia_staking::slashing::RK<_1, _1>,
     |                                                                            ^^ help: a struct with a similar name exists (notice the capitalization): `Rk`

error[E0282]: type annotations needed
    --> src\runtime.rs:9017:39
     |
9017 |                 pub struct SpanRecord<_0, _1> {
     |                                       ^^ cannot infer type for type parameter `_0`

error[E0283]: type annotations needed
    --> src\runtime.rs:9168:21
     |
9168 |                     :: subxt :: codec :: Encode, :: subxt :: codec :: Decode, Debug, Clone,
     |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `_0`
     |
     = note: cannot satisfy `_0: Encode`
note: required by a bound in `Encode`
    --> d:/opt/scoop/persist/rustup/.cargo\registry\src\github.heygears.com-1ecc6299db9ec823\parity-scale-codec-2.3.1\src\codec.rs:208:1
     |
208  | / pub trait Encode {
209  | |     // !INTERNAL USE ONLY!
210  | |     // This const helps SCALE to optimize the encoding/decoding by doing fake specialization.
211  | |     #[doc(hidden)]
...    |
251  | |     }
252  | | }
     | |_^ required by this bound in `Encode`
     = note: this error originates in the derive macro `::subxt::codec::Encode` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0282]: type annotations needed
    --> src\runtime.rs:9170:43
     |
9170 |                 pub struct UnappliedSlash<_0, _1, _2> {
     |                                           ^^ cannot infer type for type parameter `_0`

Some errors have detailed explanations: E0282, E0283, E0412.
For more information about an error, try `rustc --explain E0282`.
error: could not compile `pangoro-subxt` due to 12 previous errors
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant