-
Notifications
You must be signed in to change notification settings - Fork 1.1k
sp-api: impl_runtime_apis! replace the use of Self as a type argument
#4012
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
sp-api: impl_runtime_apis! replace the use of Self as a type argument
#4012
Conversation
…tansam/polkadot-sdk into feat/runtime-api-restrict-self
impl_runtime_apis! prevent use of Selfimpl_runtime_apis! prevent the use of Self
impl_runtime_apis! prevent the use of Selfimpl_runtime_apis! prevent the use of Self
|
The CI pipeline was cancelled due to failure one of the required jobs. |
…tansam/polkadot-sdk into feat/runtime-api-restrict-self
impl_runtime_apis! prevent the use of Selfimpl_runtime_apis! prevent the use of Self as a type argument
|
@kianenigma just pinging here :) |
|
IMO, it would make more sense to replace |
kianenigma
left a comment
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 would be happy with the existing approach, but maybe we should explore @bkchr's suggestion? at least see how much harder it is?
in any case, this is great and we will submit a tip for it, thank you!
sure, I will give it a try |
|
any updates? |
working on it |
|
again? :) |
will try to push it through this weekend, if not, I am ok if someone takes over) |
| impl client::Core<Block> for Runtime { | ||
| fn initialize_block(header: &HeaderFor<Runtime>) -> Output<Runtime> { | ||
| let _: HeaderFor<Runtime> = header.clone(); | ||
| example_fn::<Runtime>(header) |
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.
ie would it currently work if I had something like this?:
let foo: Self = ...
Or is that sort of thing nonsensical anyways.
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'd keep things conservative in this regard
|
Looks good to me but I wonder if we can simplify the code a touch and whether we should replace |
Co-authored-by: Alexandru Vasile <[email protected]>
|
/cmd fmt |
|
Command "fmt" has started 🚀 See logs here |
|
Command "fmt" has finished ✅ See logs here |
Co-authored-by: Bastian Köcher <[email protected]>
Co-authored-by: Bastian Köcher <[email protected]>
|
/cmd fmt |
|
Command "fmt" has started 🚀 See logs here |
|
Command "fmt" has finished ✅ See logs here |
a1aa71e
closes #1890
Overview
Introduces similar checker struct to
CheckTraitDeclsindecl_runtime_apis!-CheckTraitImpls. Overridesvisit::visit_type_pathto detect usage ofSelfas a type argument within the scope ofimpl_runtime_apis!.Note: only prevents the usage of
Selfas a type argument in an angle bracket<>, as it is the only use case that fails to compile. For example, the code below compiles fine:Result
Given a block of code like this:
Output: