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

Refactor construct_runtime to procedural #3810

Merged
merged 90 commits into from
Nov 25, 2019

Conversation

alexeuler
Copy link
Contributor

Description
Refactor construct_runtime macro from declarative to procedural. Reference issue #1897.

Copy link
Member

@bkchr bkchr left a comment

Choose a reason for hiding this comment

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

Thank you again for all your work. I reviewed it, mostly it looks good, but I think that we still can improve and reduce the amount of code :)

let transformed_generics: Vec<_> = generics[0]
.params
.iter()
.map(|param| quote!(<#param>))
Copy link
Member

Choose a reason for hiding this comment

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

This can be just a map() on the value from above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure what you mean here. The thing is that in case of 2 params decl macros accept something like <T> <I> instead of <T, I> - that's what this code does.

Copy link
Member

Choose a reason for hiding this comment

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

Where do we accept <T><I>?

And what I wanted is, you should not call collect in line 188. Use find and then you just get an Option that you can map directly.

Copy link
Contributor Author

@alexeuler alexeuler Nov 19, 2019

Choose a reason for hiding this comment

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

Where do we accept <T><I>?

macro_rules! impl_outer_config {
(
pub struct $main:ident for $concrete:ident {
$( $config:ident =>
$snake:ident $( $instance:ident )? $( <$generic:ident> )*, )*
}
) => {

As far as I can see it accepts <T>, <I> vs <T, I>

Copy link
Contributor Author

@alexeuler alexeuler Nov 19, 2019

Choose a reason for hiding this comment

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

And what I wanted is, you should not call collect in line 188

I see, I made the fix to make the code shorter

@@ -243,7 +243,7 @@ construct_runtime!(
Timestamp: timestamp::{Module, Call, Storage, Inherent},
Aura: aura::{Module, Config<T>, Inherent(Timestamp)},
Grandpa: grandpa::{Module, Call, Storage, Config, Event},
Indices: indices::{default, Config<T>},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bkchr Note that I had to fix it, since now construct_runtime errors on this

@bkchr
Copy link
Member

bkchr commented Nov 19, 2019

@alleycat-at-git ready for review again?

@alexeuler
Copy link
Contributor Author

@alleycat-at-git ready for review again?

@bkchr Yes

@gavofyork gavofyork requested review from gui1117 and bkchr November 22, 2019 12:14
@gavofyork
Copy link
Member

conflicts need resolving @alleycat-at-git and need to do a final review @bkchr @thiolliere .

…truct-runtime-proc-macro

# Conflicts:
#	bin/node/runtime/src/lib.rs
#	frame/support/src/lib.rs
#	frame/support/src/runtime.rs
@alexeuler
Copy link
Contributor Author

conflicts need resolving @alleycat-at-git and need to do a final review @bkchr @thiolliere .

@gavofyork @bkchr @thiolliere - fixed conflicts

Copy link
Member

@bkchr bkchr left a comment

Choose a reason for hiding this comment

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

One last thing that needs to be done before merging, please convert your files to use tabs and not spaces.

@alexeuler
Copy link
Contributor Author

One last thing that needs to be done before merging, please convert your files to use tabs and not spaces.

@bkchr fixed

@bkchr bkchr merged commit 298b632 into paritytech:master Nov 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants