This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Support for cfg attributes in host functions definitions
#14189
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d9c95bb
Support cfg attribute in host functions definitions
davxy 9d84ade
Added test to check feature gated methods are not included
davxy 929983f
Versioned conditional compiled host function are forbidden
davxy 6bee7e4
Improve runtime-interface macro docs
davxy afb125f
Fix doc
davxy 4ae458c
Apply review suggestion
davxy 71a0b9e
Better error message
davxy 6d496f8
Rust fmt
davxy 2ea78d1
More refinements to the docs
davxy a2cddae
Merge branch 'master' into host-functions-cfg-support
davxy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
18 changes: 18 additions & 0 deletions
18
primitives/runtime-interface/tests/ui/no_feature_gated_method.rs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| use sp_runtime_interface::runtime_interface; | ||
|
|
||
| #[runtime_interface] | ||
| trait Test { | ||
| fn foo() {} | ||
|
|
||
| #[cfg(feature = "bar-feature")] | ||
| fn bar() {} | ||
|
|
||
| #[cfg(not(feature = "bar-feature"))] | ||
| fn qux() {} | ||
| } | ||
|
|
||
| fn main() { | ||
| test::foo(); | ||
| test::bar(); | ||
| test::qux(); | ||
| } |
5 changes: 5 additions & 0 deletions
5
primitives/runtime-interface/tests/ui/no_feature_gated_method.stderr
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| error[E0425]: cannot find function `bar` in module `test` | ||
| --> tests/ui/no_feature_gated_method.rs:16:8 | ||
| | | ||
| 16 | test::bar(); | ||
| | ^^^ not found in `test` |
12 changes: 12 additions & 0 deletions
12
primitives/runtime-interface/tests/ui/no_versioned_conditional_build.rs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| use sp_runtime_interface::runtime_interface; | ||
|
|
||
| #[runtime_interface] | ||
| trait Test { | ||
| fn foo() {} | ||
|
|
||
| #[version(2)] | ||
| #[cfg(feature = "foo-feature")] | ||
| fn foo() {} | ||
| } | ||
|
|
||
| fn main() {} |
5 changes: 5 additions & 0 deletions
5
primitives/runtime-interface/tests/ui/no_versioned_conditional_build.stderr
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| error: Conditional compilation is not supported for versioned functions | ||
| --> tests/ui/no_versioned_conditional_build.rs:7:2 | ||
| | | ||
| 7 | #[version(2)] | ||
| | ^ |
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
nit: this filtering is repeated multiple times, maybe it is worth putting it to some shared util?