Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

codegen: allow(unreachable_patterns) #1814

Merged
merged 1 commit into from
Oct 7, 2024
Merged

codegen: allow(unreachable_patterns) #1814

merged 1 commit into from
Oct 7, 2024

Conversation

bkontur
Copy link
Contributor

@bkontur bkontur commented Oct 5, 2024

It looks like with the new rust version (1.81.0) clippy is complaining, e.g.:
https://gitlab.parity.io/parity/mirrors/parity-bridges-common/-/jobs/7505862

error: unreachable pattern
    --> relay-clients/client-polkadot/src/codegen_runtime.rs:5751:22
     |
5751 |                 Void(runtime_types::sp_core::Void),
     |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ matches no values because `codegen_runtime::api::runtime_types::sp_core::Void` is uninhabited
     |
     = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
     = note: `-D unreachable-patterns` implied by `-D warnings`
     = help: to override `-D warnings` add `#[allow(unreachable_patterns)]`
error: unreachable pattern
    --> relay-clients/client-polkadot/src/codegen_runtime.rs:5835:17
     |
5835 |                 ParasShared(runtime_types::polkadot_runtime_parachains::shared::pallet::Call),
     |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ matches no values because `codegen_runtime::api::runtime_types::polkadot_runtime_parachains::shared::pallet::Call` is uninhabited
     |
     = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
    --> relay-clients/client-polkadot/src/codegen_runtime.rs:5837:19
     |
5837 |                 ParaInclusion(runtime_types::polkadot_runtime_parachains::inclusion::pallet::Call),
     |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ matches no values because `codegen_runtime::api::runtime_types::polkadot_runtime_parachains::inclusion::pallet::Call` is uninhabited
     |
     = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
    --> relay-clients/client-rococo/src/codegen_runtime.rs:7296:22
     |
7296 |                 Void(runtime_types::sp_core::Void),
     |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ matches no values because `codegen_runtime::api::runtime_types::sp_core::Void` is uninhabited
     |
     = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
     = note: `-D unreachable-patterns` implied by `-D warnings`
     = help: to override `-D warnings` add `#[allow(unreachable_patterns)]`
error: unreachable pattern
    --> relay-clients/client-rococo/src/codegen_runtime.rs:7384:17
     |
7384 |                 ParasShared(runtime_types::polkadot_runtime_parachains::shared::pallet::Call),
     |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ matches no values because `codegen_runtime::api::runtime_types::polkadot_runtime_parachains::shared::pallet::Call` is uninhabited
     |
     = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
    --> relay-clients/client-rococo/src/codegen_runtime.rs:7386:19
     |
7386 |                 ParaInclusion(runtime_types::polkadot_runtime_parachains::inclusion::pallet::Call),
     |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ matches no values because `codegen_runtime::api::runtime_types::polkadot_runtime_parachains::inclusion::pallet::Call` is uninhabited
     |
     = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
    --> relay-clients/client-westend/src/codegen_runtime.rs:8835:22
     |
8835 |                 Void(runtime_types::sp_core::Void),
     |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ matches no values because `codegen_runtime::api::runtime_types::sp_core::Void` is uninhabited
     |
     = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
     = note: `-D unreachable-patterns` implied by `-D warnings`
     = help: to override `-D warnings` add `#[allow(unreachable_patterns)]`
error: unreachable pattern
    --> relay-clients/client-westend/src/codegen_runtime.rs:8921:17
     |
8921 |                 ParasShared(runtime_types::polkadot_runtime_parachains::shared::pallet::Call),
     |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ matches no values because `codegen_runtime::api::runtime_types::polkadot_runtime_parachains::shared::pallet::Call` is uninhabited
     |
     = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
    --> relay-clients/client-westend/src/codegen_runtime.rs:8923:19
     |
8923 |                 ParaInclusion(runtime_types::polkadot_runtime_parachains::inclusion::pallet::Call),
     |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ matches no values because `codegen_runtime::api::runtime_types::polkadot_runtime_parachains::inclusion::pallet::Call` is uninhabited
     |
     = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
    --> relay-clients/client-kusama/src/codegen_runtime.rs:8864:22
     |
8864 |                 Void(runtime_types::sp_core::Void),
     |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ matches no values because `codegen_runtime::api::runtime_types::sp_core::Void` is uninhabited
     |
     = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
     = note: `-D unreachable-patterns` implied by `-D warnings`
     = help: to override `-D warnings` add `#[allow(unreachable_patterns)]`
error: unreachable pattern
    --> relay-clients/client-kusama/src/codegen_runtime.rs:8962:17
     |
8962 |                 ParasShared(runtime_types::polkadot_runtime_parachains::shared::pallet::Call),
     |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ matches no values because `codegen_runtime::api::runtime_types::polkadot_runtime_parachains::shared::pallet::Call` is uninhabited
     |
     = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
    --> relay-clients/client-kusama/src/codegen_runtime.rs:8964:19
     |
8964 |                 ParaInclusion(runtime_types::polkadot_runtime_parachains::inclusion::pallet::Call),
     |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ matches no values because `codegen_runtime::api::runtime_types::polkadot_runtime_parachains::inclusion::pallet::Call` is uninhabited
     |
     = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: could not compile `relay-polkadot-client` (lib test) due to 3 previous errors

…clippy is complaining:

```
error: unreachable pattern
    --> relay-clients/client-polkadot/src/codegen_runtime.rs:5751:22
     |
5751 |                 Void(runtime_types::sp_core::Void),
     |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ matches no values because `codegen_runtime::api::runtime_types::sp_core::Void` is uninhabited
     |
     = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
     = note: `-D unreachable-patterns` implied by `-D warnings`
     = help: to override `-D warnings` add `#[allow(unreachable_patterns)]`
```
@bkontur bkontur added the enhancement New feature or request label Oct 5, 2024
@bkontur bkontur requested a review from a team as a code owner October 5, 2024 21:17
bkontur added a commit to paritytech/parity-bridges-common that referenced this pull request Oct 5, 2024
@bkontur
Copy link
Contributor Author

bkontur commented Oct 5, 2024

looks like this is a problem just with cargo +nightly clippy

@bkontur
Copy link
Contributor Author

bkontur commented Oct 5, 2024

hmm, if not really needed, please just close this

@@ -81,7 +81,7 @@ impl RuntimeGenerator {

Ok(quote! {
#( #item_mod_attrs )*
#[allow(dead_code, unused_imports, non_camel_case_types)]
#[allow(dead_code, unused_imports, non_camel_case_types, unreachable_patterns)]
Copy link
Member

@niklasad1 niklasad1 Oct 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not really a clippy lint but a rustc warning.

I don't mind adding this but more interesting why/when the codegen would generate something like an empty enum or something that can't be instantiated

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@niklasad1 e.g. you can generate it for rococo/westend and run cargo +nighlty clippy, e.g.:
https://github.com/paritytech/parity-bridges-common/pull/3059/files#diff-611bdbe35fbbfe14f550dc53edae00c57c91bbd07b6fc7ad3cdec38f7f2c6cdb

git clone [email protected]:paritytech/parity-bridges-common.git
cd parity-bridges-common/tools/runtime-codegen

cargo run --bin runtime-codegen -- --from-node-url "wss://rococo-rpc.polkadot.io:443" > ../../relay-clients/client-rococo/src/codegen_runtime.rs

cargo run --bin runtime-codegen -- --from-node-url "wss://westend-rpc.polkadot.io:443" > ../../relay-clients/client-westend/src/codegen_runtime.rs

@niklasad1 niklasad1 changed the title Clippy allow - unreachable_patterns codegen: allow(unreachable_patterns) Oct 6, 2024
bkontur added a commit to paritytech/parity-bridges-common that referenced this pull request Oct 7, 2024
… support (#3059)

* Add `LaneId` generic param

* Version

* Update testnet runtimes

* New polkadot-sdk version

* Removed unnecessary `type LaneId`

* 1.7.10 -> 1.7.0

* change bullseye?

* fix test

* I have no idea, inspired by paritytech/frame-metadata#83

* Bump master polkadot-sdk

* Fix clippy for new rustc - next regeneration should be fixed when paritytech/subxt#1814 is released

* Switch clippy from nightly to stable, because of nalgebra deps hangs 6hours: rust-lang/rust#130056 and also polkadot-sdk is using stable for clippy and doc:
https://gitlab.parity.io/parity/mirrors/parity-bridges-common/-/jobs/7515555
https://gitlab.parity.io/parity/mirrors/parity-bridges-common/-/jobs/7515561
Copy link
Collaborator

@lexnv lexnv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for contributing! 🙏

@niklasad1 niklasad1 merged commit 6fd3e7b into master Oct 7, 2024
13 checks passed
@niklasad1 niklasad1 deleted the bko-nit branch October 7, 2024 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants