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

Allow to use path in construct_runtime. #8085

Closed
gui1117 opened this issue Feb 9, 2021 · 3 comments · Fixed by #8801
Closed

Allow to use path in construct_runtime. #8085

gui1117 opened this issue Feb 9, 2021 · 3 comments · Fixed by #8801
Assignees
Labels
J0-enhancement An additional feature request. Z2-medium Can be fixed by a coder with good Rust knowledge but little knowledge of the codebase.

Comments

@gui1117
Copy link
Contributor

gui1117 commented Feb 9, 2021

Currently construct_runtime only allows to have an identifier for the path of the pallet, this result in code like this:

use pallet_session::historical as pallet_session_historical;
construct_runtime!(
	...
	Historical: pallet_session_historical::{Module},
);

instead we should be able to do stuff like this:

construct_runtime!(
	...
	Historical: pallet_session::historical::{Module},
);

Maybe impl_outer_* should be reimplemented in procedural macro so that this issue is easier to do.
Or we can make construct_runtime note using them and instead use its own code (which shouldn't be a lot of code actually, but would be great to share code generation for stuff like impl_outer_inherent).
Or maybe we can just handle path in impl_outer_* but this is probably tricky and doesn't worth the pain.

@gui1117 gui1117 added J0-enhancement An additional feature request. Z2-medium Can be fixed by a coder with good Rust knowledge but little knowledge of the codebase. labels Feb 9, 2021
@bkchr
Copy link
Member

bkchr commented Feb 9, 2021

We should deprecate these old macros with the old decl_module macro.

@bkchr
Copy link
Member

bkchr commented Feb 9, 2021

And rewrite them as a procedural macro.

@KiChjang
Copy link
Contributor

KiChjang commented May 12, 2021

So, getting the old macros to work with paths, while seemingly straightforward and simple, is in fact not, due to the limitations of what syntactical constructs can be appended to path fragments, i.e. if I matched a $module:path fragment, we are not allowed to generate the following code:

$module::<Runtime, Instance>
$module::Type
$module::path_segment::Type
$module::function
$module::CONSTANT

In summary, appending additional path segments during macro expansion is prohibited. So in order to get paths working with the overall construct_runtime macro, the path of least resistance does seem to be, at the very least, rewriting impl_runtime_metadata, since this is the only macro so far that needs to be aware of the path of where the pallet is located.

This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
J0-enhancement An additional feature request. Z2-medium Can be fixed by a coder with good Rust knowledge but little knowledge of the codebase.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants