Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

construct_runtime: Fix generation of types behind features #12229

Merged
merged 3 commits into from
Sep 10, 2022

Conversation

bkchr
Copy link
Member

@bkchr bkchr commented Sep 9, 2022

With the recent addition of supporting features in construct_runtime! there was a bug overseen. The AllPalletsWithSystem etc type declarations would be declared twice when a certain was enabled. The problem was that in the macro we didn't feature gate the types that should be declared when there is no feature enabled. This pull request now takes care of feature gating this type behind all(#( not(feature) )). So, these types will only be enabled if no of the configured features is enabled.

It also adds a test to ensure that the code is tested properly.

With the recent addition of supporting features in `construct_runtime!` there was a bug overseen.
The `AllPalletsWithSystem` etc type declarations would be declared twice when a certain was enabled.
The problem was that in the macro we didn't feature gate the types that should be declared when
there is no feature enabled. This pull request now takes care of feature gating this type behind
`all(#( not(feature) ))`. So, these types will only be enabled if no of the configured features is enabled.
@bkchr bkchr added A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit labels Sep 9, 2022
@bkchr bkchr requested review from sam0x17 and KiChjang September 9, 2022 13:19
@bkchr bkchr requested a review from a team as a code owner September 9, 2022 13:19
Copy link
Contributor

@KiChjang KiChjang left a comment

Choose a reason for hiding this comment

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

very nice!

if features.is_empty() {
let test_cfg = all_features.remove("test").then_some(quote!(test)).into_iter();
let features = all_features.iter();
let attr = quote!(#[cfg(all( #(not(#test_cfg)),* #(not(feature = #features)),* ))]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah this is exactly the line that I was missing... I told myself to include this while coding, but I guess it just slipped through the cracks. Thanks!

@bkchr
Copy link
Member Author

bkchr commented Sep 10, 2022

bot merge

@paritytech-processbot
Copy link

Waiting for commit status.

@paritytech-processbot
Copy link

Merge cancelled due to error. Error: Statuses failed for 590d2a6

@bkchr bkchr merged commit 51f60d0 into master Sep 10, 2022
@bkchr bkchr deleted the bkchr-fix-construct-runtime-rust-features branch September 10, 2022 19:51
ark0f pushed a commit to gear-tech/substrate that referenced this pull request Feb 27, 2023
…h#12229)

* construct_runtime: Fix generation of types behind features

With the recent addition of supporting features in `construct_runtime!` there was a bug overseen.
The `AllPalletsWithSystem` etc type declarations would be declared twice when a certain was enabled.
The problem was that in the macro we didn't feature gate the types that should be declared when
there is no feature enabled. This pull request now takes care of feature gating this type behind
`all(#( not(feature) ))`. So, these types will only be enabled if no of the configured features is enabled.

* Fix tests

* FMT
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants