-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Adds ability to provide defaults for types provided by construct_runtime
#14682
Adds ability to provide defaults for types provided by construct_runtime
#14682
Conversation
construct_runtime
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is looking good to me just needs docs in a few places and some integration tests etc
#[derive(derive_syn_parse::Parse, PartialEq, Eq)] | ||
pub enum PalletAttrType { | ||
#[peek(keyword::verbatim, name = "verbatim")] | ||
Verbatim(keyword::verbatim), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice making this extendible 💯
Seems like the right direction to have a fully elided Can you elaborate a bit about why you chose the word |
that's my fault. Its a term in general it just means "as-is" |
…derive-impl-improvements
…derive-impl-improvements
/// A bool for each sub-trait item indicates whether the item has | ||
/// `#[pallet::no_default_bounds]` attached to it. If true, the item will not have any bounds | ||
/// in the generated default sub-trait. | ||
pub items: Vec<(syn::TraitItem, bool)>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use an enum instead of a boolean in here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if it adds a lot of value here. What are the enum variants that you would suggest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already looks much better!
Co-authored-by: Bastian Köcher <git@kchr.de>
Co-authored-by: Bastian Köcher <git@kchr.de>
…derive-impl-improvements
bot merge |
Step in paritytech/polkadot-sdk#171
As described in #14453 (comment), this PR attempts to provide defaults for types provided by
construct_runtime
.This is achieved by the combination of two macros:
#[pallet::no_default_bounds]
that adds the ability to remove trait bounds while creatingDefaultConfig
. This allows us to set types likeRuntimeCall
as()
.becomes
#[inject_runtime_type]
that can be added to types generated byconstruct_runtime
while registering the default impl. When this is later combined with the user-provided impl, it's replaced with the respective types.becomes
Todo: