Fix cycle dependency in sp-runtime-interface (#4353)

* Fix cycle dependency in `sp-runtime-interface`

* Fixes tests
This commit is contained in:
Bastian Köcher
2019-12-11 09:32:11 +01:00
committed by GitHub
parent 1ff41742bd
commit 6500b33df3
19 changed files with 218 additions and 224 deletions
@@ -0,0 +1,27 @@
// Copyright 2019 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
// Substrate is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Substrate is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
use std::env;
#[rustversion::attr(not(stable), ignore)]
#[test]
fn ui() {
// As trybuild is using `cargo check`, we don't need the real WASM binaries.
env::set_var("BUILD_DUMMY_WASM_BINARY", "1");
let t = trybuild::TestCases::new();
t.compile_fail("tests/ui/*.rs");
}
@@ -0,0 +1,8 @@
use sp_runtime_interface::runtime_interface;
#[runtime_interface]
trait Test<T> {
fn test<R>() {}
}
fn main() {}
@@ -0,0 +1,11 @@
error: Generic parameters not supported.
--> $DIR/no_generic_parameters.rs:5:10
|
5 | fn test<R>() {}
| ^
error: Generic parameters not supported.
--> $DIR/no_generic_parameters.rs:4:12
|
4 | trait Test<T> {
| ^
@@ -0,0 +1,8 @@
use sp_runtime_interface::runtime_interface;
#[runtime_interface]
trait Test {
fn test();
}
fn main() {}
@@ -0,0 +1,5 @@
error: Methods need to have an implementation.
--> $DIR/no_method_implementation.rs:5:2
|
5 | fn test();
| ^^
@@ -0,0 +1,6 @@
use sp_runtime_interface::pass_by::PassByEnum;
#[derive(PassByEnum)]
struct Test;
fn main() {}
@@ -0,0 +1,5 @@
error: `PassByEnum` only supports enums as input type.
--> $DIR/pass_by_enum_with_struct.rs:3:10
|
3 | #[derive(PassByEnum)]
| ^^^^^^^^^^
@@ -0,0 +1,8 @@
use sp_runtime_interface::pass_by::PassByEnum;
#[derive(PassByEnum)]
enum Test {
Var0(u32),
}
fn main() {}
@@ -0,0 +1,5 @@
error: `PassByEnum` only supports unit variants.
--> $DIR/pass_by_enum_with_value_variant.rs:3:10
|
3 | #[derive(PassByEnum)]
| ^^^^^^^^^^
@@ -0,0 +1,9 @@
use sp_runtime_interface::pass_by::PassByInner;
#[derive(PassByInner)]
struct Test {
data: u32,
data2: u32,
}
fn main() {}
@@ -0,0 +1,5 @@
error: Only newtype/one field structs are supported by `PassByInner`!
--> $DIR/pass_by_inner_with_two_fields.rs:3:10
|
3 | #[derive(PassByInner)]
| ^^^^^^^^^^^
@@ -0,0 +1,8 @@
use sp_runtime_interface::runtime_interface;
#[runtime_interface]
trait Test {
fn test(self) {}
}
fn main() {}
@@ -0,0 +1,5 @@
error: Taking `Self` by value is not allowed.
--> $DIR/take_self_by_value.rs:5:10
|
5 | fn test(self) {}
| ^^^^