mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 02:57:57 +00:00
Support for cfg attributes in host functions definitions (#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 commit is contained in:
@@ -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();
|
||||
}
|
||||
@@ -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`
|
||||
@@ -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() {}
|
||||
@@ -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)]
|
||||
| ^
|
||||
Reference in New Issue
Block a user