This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Support for cfg attributes in host functions definitions#14189
Merged
davxy merged 10 commits intoparitytech:masterfrom May 25, 2023
davxy:host-functions-cfg-support
Merged
Support for cfg attributes in host functions definitions#14189davxy merged 10 commits intoparitytech:masterfrom davxy:host-functions-cfg-support
cfg attributes in host functions definitions#14189davxy merged 10 commits intoparitytech:masterfrom
davxy:host-functions-cfg-support
Conversation
bkchr
approved these changes
May 22, 2023
Member
bkchr
left a comment
There was a problem hiding this comment.
A test with a feature that doesn't exist and thus, doesn't gets activated would be nice. (There is a testing crate for this stuff)
Member
Author
|
Required by #13974 |
michalkucharczyk
approved these changes
May 23, 2023
| method.sig.ident, | ||
| ); | ||
| let return_value = &method.sig.output; | ||
| let cfg_attrs = method.attrs.iter().filter(|a| a.path().is_ident("cfg")); |
Contributor
There was a problem hiding this comment.
nit: this filtering is repeated multiple times, maybe it is worth putting it to some shared util?
koute
approved these changes
May 23, 2023
primitives/runtime-interface/proc-macro/src/runtime_interface/host_function_interface.rs
Outdated
Show resolved
Hide resolved
Member
Please add it to the crate docs as well (or only the crate docs), but never the README exclusively. Most of these readmes were generated from the crate docs. |
Co-authored-by: Koute <koute@users.noreply.github.com>
Ank4n
pushed a commit
that referenced
this pull request
Jul 8, 2023
* Support cfg attribute in host functions definitions * Added test to check feature gated methods are not included * Versioned conditional compiled host function are forbidden * Improve runtime-interface macro docs * Fix doc * Apply review suggestion Co-authored-by: Koute <koute@users.noreply.github.com> * Better error message * Rust fmt * More refinements to the docs --------- Co-authored-by: Koute <koute@users.noreply.github.com>
nathanwhit
pushed a commit
to nathanwhit/substrate
that referenced
this pull request
Jul 19, 2023
…h#14189) * Support cfg attribute in host functions definitions * Added test to check feature gated methods are not included * Versioned conditional compiled host function are forbidden * Improve runtime-interface macro docs * Fix doc * Apply review suggestion Co-authored-by: Koute <koute@users.noreply.github.com> * Better error message * Rust fmt * More refinements to the docs --------- Co-authored-by: Koute <koute@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As per title...
If I'm not terribly wrong, before this PR was not possible to define a host function gated by some
#[cfg(feature = ...)]. A similar technique has been used byframe.Usage scenario: we require to early integrate and experiment with an host function that is still in "beta" phase as this one:
https://github.com/davxy/substrate/blob/5d2e2bbf17bb7f375d6d24bfe696be2c6e54aa2a/primitives/io/src/lib.rs#L1146-L1159
I'm not a rust macro wizard 🧙 so please carefully check