mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 15:41:02 +00:00
Replace compile_fail doc tests with trybuild (#2588)
* WIP: use trybuild for compile tests * declaring_old_block * declaring_own_block_with_different_name * adding_self_parameter * adding_at_parameter * invalid_api_version * invalid_api_version2 & invalid_api_version3 * missing_block_generic_parameter * Restore main functions * missing_path_for_trait * empty_impl_runtime_apis_call * empty_impl_runtime_apis_call * type_reference_in_impl_runtime_apis_call * impl_incorrect_method_signature * impl_two_traits_with_same_name * changed_at_unknown_version * changed_at > changed_in * fix test
This commit is contained in:
committed by
Bastian Köcher
parent
aa2c496a65
commit
b2ea94d73d
@@ -20,3 +20,4 @@ nohup.out
|
|||||||
rls*.log
|
rls*.log
|
||||||
*.orig
|
*.orig
|
||||||
*.rej
|
*.rej
|
||||||
|
**/wip/*.stderr
|
||||||
|
|||||||
Generated
+30
@@ -1024,6 +1024,11 @@ name = "glob"
|
|||||||
version = "0.2.11"
|
version = "0.2.11"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "glob"
|
||||||
|
version = "0.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "globset"
|
name = "globset"
|
||||||
version = "0.4.3"
|
version = "0.4.3"
|
||||||
@@ -3269,6 +3274,7 @@ dependencies = [
|
|||||||
"substrate-state-machine 2.0.0",
|
"substrate-state-machine 2.0.0",
|
||||||
"substrate-test-client 2.0.0",
|
"substrate-test-client 2.0.0",
|
||||||
"syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
"syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"trybuild 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -5010,6 +5016,14 @@ dependencies = [
|
|||||||
"serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "toml"
|
||||||
|
version = "0.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "traitobject"
|
name = "traitobject"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
@@ -5065,6 +5079,19 @@ name = "try-lock"
|
|||||||
version = "0.2.2"
|
version = "0.2.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "trybuild"
|
||||||
|
version = "1.0.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"toml 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "twofish"
|
name = "twofish"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
@@ -5631,6 +5658,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
"checksum get_if_addrs 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abddb55a898d32925f3148bd281174a68eeb68bbfd9a5938a57b18f506ee4ef7"
|
"checksum get_if_addrs 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abddb55a898d32925f3148bd281174a68eeb68bbfd9a5938a57b18f506ee4ef7"
|
||||||
"checksum get_if_addrs-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0d04f9fb746cf36b191c00f3ede8bde9c8e64f9f4b05ae2694a9ccf5e3f5ab48"
|
"checksum get_if_addrs-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0d04f9fb746cf36b191c00f3ede8bde9c8e64f9f4b05ae2694a9ccf5e3f5ab48"
|
||||||
"checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb"
|
"checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb"
|
||||||
|
"checksum glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
|
||||||
"checksum globset 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ef4feaabe24a0a658fd9cf4a9acf6ed284f045c77df0f49020ba3245cfb7b454"
|
"checksum globset 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ef4feaabe24a0a658fd9cf4a9acf6ed284f045c77df0f49020ba3245cfb7b454"
|
||||||
"checksum h2 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "85ab6286db06040ddefb71641b50017c06874614001a134b423783e2db2920bd"
|
"checksum h2 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "85ab6286db06040ddefb71641b50017c06874614001a134b423783e2db2920bd"
|
||||||
"checksum hash-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ba7fb417e5c470acdd61068c79767d0e65962e70836cf6c9dfd2409f06345ce0"
|
"checksum hash-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ba7fb417e5c470acdd61068c79767d0e65962e70836cf6c9dfd2409f06345ce0"
|
||||||
@@ -5888,12 +5916,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
"checksum tokio-udp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "66268575b80f4a4a710ef83d087fdfeeabdce9b74c797535fbac18a2cb906e92"
|
"checksum tokio-udp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "66268575b80f4a4a710ef83d087fdfeeabdce9b74c797535fbac18a2cb906e92"
|
||||||
"checksum tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "037ffc3ba0e12a0ab4aca92e5234e0dedeb48fddf6ccd260f1f150a36a9f2445"
|
"checksum tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "037ffc3ba0e12a0ab4aca92e5234e0dedeb48fddf6ccd260f1f150a36a9f2445"
|
||||||
"checksum toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f"
|
"checksum toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f"
|
||||||
|
"checksum toml 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "87c5890a989fa47ecdc7bcb4c63a77a82c18f306714104b1decfd722db17b39e"
|
||||||
"checksum traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079"
|
"checksum traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079"
|
||||||
"checksum trie-bench 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ba20f7d9865497ea46511860b43e05a44f4ac9a76ee089d34cd80a839a690264"
|
"checksum trie-bench 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ba20f7d9865497ea46511860b43e05a44f4ac9a76ee089d34cd80a839a690264"
|
||||||
"checksum trie-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1ba73747fd3a64ab531274c04cb588dfa9d30d972d62990831e63fbce2cfec59"
|
"checksum trie-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1ba73747fd3a64ab531274c04cb588dfa9d30d972d62990831e63fbce2cfec59"
|
||||||
"checksum trie-root 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "cfa2e20c4f1418ac2e71ddc418e35e1b56e34022e2146209ffdbf1b2de8b1bd9"
|
"checksum trie-root 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "cfa2e20c4f1418ac2e71ddc418e35e1b56e34022e2146209ffdbf1b2de8b1bd9"
|
||||||
"checksum trie-standardmap 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e4e24277af05f38f3aaf03ac78e3a154be83f13db9c8ef0cb95bb1aa764a477b"
|
"checksum trie-standardmap 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e4e24277af05f38f3aaf03ac78e3a154be83f13db9c8ef0cb95bb1aa764a477b"
|
||||||
"checksum try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382"
|
"checksum try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382"
|
||||||
|
"checksum trybuild 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0b0df728de48978b759da185ed7ef76676ef0c878ae4800c9e90024c998dc75b"
|
||||||
"checksum twofish 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712d261e83e727c8e2dbb75dacac67c36e35db36a958ee504f2164fc052434e1"
|
"checksum twofish 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712d261e83e727c8e2dbb75dacac67c36e35db36a958ee504f2164fc052434e1"
|
||||||
"checksum twox-hash 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "09871da9f15424236082e0b220fd404a4eb6bebc7205c67653701229234ac64c"
|
"checksum twox-hash 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "09871da9f15424236082e0b220fd404a4eb6bebc7205c67653701229234ac64c"
|
||||||
"checksum typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1410f6f91f21d1612654e7cc69193b0334f909dcf2c790c4826254fbb86f8887"
|
"checksum typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1410f6f91f21d1612654e7cc69193b0334f909dcf2c790c4826254fbb86f8887"
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ substrate-primitives = { path = "../primitives" }
|
|||||||
criterion = "0.2"
|
criterion = "0.2"
|
||||||
consensus_common = { package = "substrate-consensus-common", path = "../consensus/common" }
|
consensus_common = { package = "substrate-consensus-common", path = "../consensus/common" }
|
||||||
codec = { package = "parity-codec", version = "3.5.1" }
|
codec = { package = "parity-codec", version = "3.5.1" }
|
||||||
|
trybuild = "1.0"
|
||||||
|
|
||||||
[[bench]]
|
[[bench]]
|
||||||
name = "bench"
|
name = "bench"
|
||||||
|
|||||||
@@ -1,412 +0,0 @@
|
|||||||
// Copyright 2018-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/>.
|
|
||||||
|
|
||||||
//! Compile fail tests.
|
|
||||||
|
|
||||||
mod declaring_own_block {
|
|
||||||
/*!
|
|
||||||
```compile_fail
|
|
||||||
#[macro_use]
|
|
||||||
extern crate client;
|
|
||||||
extern crate sr_primitives as runtime_primitives;
|
|
||||||
|
|
||||||
use runtime_primitives::traits::Block as BlockT;
|
|
||||||
|
|
||||||
decl_runtime_apis! {
|
|
||||||
pub trait Api<Block: BlockT> {
|
|
||||||
fn test();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {}
|
|
||||||
```
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
mod declaring_own_block_with_different_name {
|
|
||||||
/*!
|
|
||||||
```compile_fail
|
|
||||||
#[macro_use]
|
|
||||||
extern crate client;
|
|
||||||
extern crate sr_primitives as runtime_primitives;
|
|
||||||
|
|
||||||
use runtime_primitives::traits::Block as BlockT;
|
|
||||||
|
|
||||||
decl_runtime_apis! {
|
|
||||||
pub trait Api<B: BlockT> {
|
|
||||||
fn test();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {}
|
|
||||||
```
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
mod adding_self_parameter {
|
|
||||||
/*!
|
|
||||||
```compile_fail
|
|
||||||
#[macro_use]
|
|
||||||
extern crate client;
|
|
||||||
extern crate sr_primitives as runtime_primitives;
|
|
||||||
|
|
||||||
decl_runtime_apis! {
|
|
||||||
pub trait Api {
|
|
||||||
fn test(&self);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {}
|
|
||||||
```
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
mod adding_at_parameter {
|
|
||||||
/*!
|
|
||||||
```compile_fail
|
|
||||||
#[macro_use]
|
|
||||||
extern crate client;
|
|
||||||
extern crate sr_primitives as runtime_primitives;
|
|
||||||
|
|
||||||
decl_runtime_apis! {
|
|
||||||
pub trait Api {
|
|
||||||
fn test(at: u64);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {}
|
|
||||||
```
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
mod invalid_api_version {
|
|
||||||
/*!
|
|
||||||
```compile_fail
|
|
||||||
#[macro_use]
|
|
||||||
extern crate client;
|
|
||||||
extern crate sr_primitives as runtime_primitives;
|
|
||||||
|
|
||||||
decl_runtime_apis! {
|
|
||||||
#[api_version]
|
|
||||||
pub trait Api {
|
|
||||||
fn test(data: u64);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {}
|
|
||||||
```
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
mod invalid_api_version_2 {
|
|
||||||
/*!
|
|
||||||
```compile_fail
|
|
||||||
#[macro_use]
|
|
||||||
extern crate client;
|
|
||||||
extern crate sr_primitives as runtime_primitives;
|
|
||||||
|
|
||||||
decl_runtime_apis! {
|
|
||||||
#[api_version("1")]
|
|
||||||
pub trait Api {
|
|
||||||
fn test(data: u64);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {}
|
|
||||||
```
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
mod invalid_api_version_3 {
|
|
||||||
/*!
|
|
||||||
```compile_fail
|
|
||||||
#[macro_use]
|
|
||||||
extern crate client;
|
|
||||||
extern crate sr_primitives as runtime_primitives;
|
|
||||||
|
|
||||||
decl_runtime_apis! {
|
|
||||||
#[api_version()]
|
|
||||||
pub trait Api {
|
|
||||||
fn test(data: u64);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {}
|
|
||||||
```
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
mod missing_block_generic_parameter {
|
|
||||||
/*!
|
|
||||||
```compile_fail
|
|
||||||
#[macro_use]
|
|
||||||
extern crate client;
|
|
||||||
extern crate substrate_test_client as test_client;
|
|
||||||
extern crate sr_primitives as runtime_primitives;
|
|
||||||
extern crate substrate_primitives as primitives;
|
|
||||||
|
|
||||||
use runtime_primitives::traits::GetNodeBlockType;
|
|
||||||
use test_client::runtime::Block;
|
|
||||||
|
|
||||||
/// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType`
|
|
||||||
/// trait are done by the `construct_runtime!` macro in a real runtime.
|
|
||||||
struct Runtime {}
|
|
||||||
impl GetNodeBlockType for Runtime {
|
|
||||||
type NodeBlock = Block;
|
|
||||||
}
|
|
||||||
|
|
||||||
decl_runtime_apis! {
|
|
||||||
pub trait Api {
|
|
||||||
fn test(data: u64);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl_runtime_apis! {
|
|
||||||
impl self::Api for Runtime {
|
|
||||||
fn test(data: u64) {
|
|
||||||
unimplemented!()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {}
|
|
||||||
```
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
mod missing_path_for_trait {
|
|
||||||
/*!
|
|
||||||
```compile_fail
|
|
||||||
#[macro_use]
|
|
||||||
extern crate client;
|
|
||||||
extern crate substrate_test_client as test_client;
|
|
||||||
extern crate sr_primitives as runtime_primitives;
|
|
||||||
extern crate substrate_primitives as primitives;
|
|
||||||
|
|
||||||
use runtime_primitives::traits::GetNodeBlockType;
|
|
||||||
use test_client::runtime::Block;
|
|
||||||
|
|
||||||
/// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType`
|
|
||||||
/// trait are done by the `construct_runtime!` macro in a real runtime.
|
|
||||||
struct Runtime {}
|
|
||||||
impl GetNodeBlockType for Runtime {
|
|
||||||
type NodeBlock = Block;
|
|
||||||
}
|
|
||||||
|
|
||||||
decl_runtime_apis! {
|
|
||||||
pub trait Api {
|
|
||||||
fn test(data: u64);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl_runtime_apis! {
|
|
||||||
impl Api<Block> for Runtime {
|
|
||||||
fn test(data: u64) {
|
|
||||||
unimplemented!()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {}
|
|
||||||
```
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
mod empty_impl_runtime_apis_call {
|
|
||||||
/*!
|
|
||||||
```compile_fail
|
|
||||||
#[macro_use]
|
|
||||||
extern crate client;
|
|
||||||
extern crate substrate_test_client as test_client;
|
|
||||||
extern crate sr_primitives as runtime_primitives;
|
|
||||||
extern crate substrate_primitives as primitives;
|
|
||||||
|
|
||||||
use runtime_primitives::traits::GetNodeBlockType;
|
|
||||||
use test_client::runtime::Block;
|
|
||||||
|
|
||||||
/// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType`
|
|
||||||
/// trait are done by the `construct_runtime!` macro in a real runtime.
|
|
||||||
struct Runtime {}
|
|
||||||
impl GetNodeBlockType for Runtime {
|
|
||||||
type NodeBlock = Block;
|
|
||||||
}
|
|
||||||
|
|
||||||
decl_runtime_apis! {
|
|
||||||
pub trait Api {
|
|
||||||
fn test(data: u64);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl_runtime_apis! {}
|
|
||||||
|
|
||||||
fn main() {}
|
|
||||||
```
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
mod type_reference_in_impl_runtime_apis_call {
|
|
||||||
/*!
|
|
||||||
```compile_fail
|
|
||||||
#[macro_use]
|
|
||||||
extern crate client;
|
|
||||||
extern crate substrate_test_client as test_client;
|
|
||||||
extern crate sr_primitives as runtime_primitives;
|
|
||||||
extern crate substrate_primitives as primitives;
|
|
||||||
|
|
||||||
use runtime_primitives::traits::GetNodeBlockType;
|
|
||||||
use test_client::runtime::Block;
|
|
||||||
|
|
||||||
/// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType`
|
|
||||||
/// trait are done by the `construct_runtime!` macro in a real runtime.
|
|
||||||
struct Runtime {}
|
|
||||||
impl GetNodeBlockType for Runtime {
|
|
||||||
type NodeBlock = Block;
|
|
||||||
}
|
|
||||||
|
|
||||||
decl_runtime_apis! {
|
|
||||||
pub trait Api {
|
|
||||||
fn test(data: u64);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl_runtime_apis! {
|
|
||||||
impl self::Api<Block> for Runtime {
|
|
||||||
fn test(data: &u64) {
|
|
||||||
unimplemented!()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {}
|
|
||||||
```
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
mod impl_incorrect_method_signature {
|
|
||||||
/*!
|
|
||||||
```compile_fail
|
|
||||||
#[macro_use]
|
|
||||||
extern crate client;
|
|
||||||
extern crate substrate_test_client as test_client;
|
|
||||||
extern crate sr_primitives as runtime_primitives;
|
|
||||||
extern crate substrate_primitives as primitives;
|
|
||||||
|
|
||||||
use runtime_primitives::traits::GetNodeBlockType;
|
|
||||||
use test_client::runtime::Block;
|
|
||||||
|
|
||||||
/// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType`
|
|
||||||
/// trait are done by the `construct_runtime!` macro in a real runtime.
|
|
||||||
struct Runtime {}
|
|
||||||
impl GetNodeBlockType for Runtime {
|
|
||||||
type NodeBlock = Block;
|
|
||||||
}
|
|
||||||
|
|
||||||
decl_runtime_apis! {
|
|
||||||
pub trait Api {
|
|
||||||
fn test(data: u64);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl_runtime_apis! {
|
|
||||||
impl self::Api<Block> for Runtime {
|
|
||||||
fn test(data: String) {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {}
|
|
||||||
```
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
mod impl_two_traits_with_same_name {
|
|
||||||
/*!
|
|
||||||
```compile_fail
|
|
||||||
#[macro_use]
|
|
||||||
extern crate client;
|
|
||||||
extern crate substrate_test_client as test_client;
|
|
||||||
extern crate sr_primitives as runtime_primitives;
|
|
||||||
extern crate substrate_primitives as primitives;
|
|
||||||
|
|
||||||
use runtime_primitives::traits::GetNodeBlockType;
|
|
||||||
use test_client::runtime::Block;
|
|
||||||
|
|
||||||
/// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType`
|
|
||||||
/// trait are done by the `construct_runtime!` macro in a real runtime.
|
|
||||||
struct Runtime {}
|
|
||||||
impl GetNodeBlockType for Runtime {
|
|
||||||
type NodeBlock = Block;
|
|
||||||
}
|
|
||||||
|
|
||||||
decl_runtime_apis! {
|
|
||||||
pub trait Api {
|
|
||||||
fn test(data: u64);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mod second {
|
|
||||||
decl_runtime_apis! {
|
|
||||||
pub trait Api {
|
|
||||||
fn test2(data: u64);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl_runtime_apis! {
|
|
||||||
impl self::Api<Block> for Runtime {
|
|
||||||
fn test(data: u64) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl second::Api<Block> for Runtime {
|
|
||||||
fn test2(data: u64) {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {}
|
|
||||||
```
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
mod changed_at_unknown_version {
|
|
||||||
/*!
|
|
||||||
```compile_fail
|
|
||||||
#[macro_use]
|
|
||||||
extern crate client;
|
|
||||||
extern crate substrate_test_client as test_client;
|
|
||||||
extern crate sr_primitives as runtime_primitives;
|
|
||||||
extern crate substrate_primitives as primitives;
|
|
||||||
|
|
||||||
use runtime_primitives::traits::GetNodeBlockType;
|
|
||||||
use test_client::runtime::Block;
|
|
||||||
|
|
||||||
/// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType`
|
|
||||||
/// trait are done by the `construct_runtime!` macro in a real runtime.
|
|
||||||
struct Runtime {}
|
|
||||||
impl GetNodeBlockType for Runtime {
|
|
||||||
type NodeBlock = Block;
|
|
||||||
}
|
|
||||||
|
|
||||||
decl_runtime_apis! {
|
|
||||||
pub trait Api {
|
|
||||||
#[changed_in(2)]
|
|
||||||
fn test(data: u64);
|
|
||||||
fn test(data: u64);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {}
|
|
||||||
```
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
@@ -24,7 +24,6 @@ use proc_macro::TokenStream;
|
|||||||
mod impl_runtime_apis;
|
mod impl_runtime_apis;
|
||||||
mod decl_runtime_apis;
|
mod decl_runtime_apis;
|
||||||
mod utils;
|
mod utils;
|
||||||
mod compile_fail_tests;
|
|
||||||
|
|
||||||
/// Tags given trait implementations as runtime apis.
|
/// Tags given trait implementations as runtime apis.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
#[test]
|
||||||
|
fn ui() {
|
||||||
|
let t = trybuild::TestCases::new();
|
||||||
|
t.compile_fail("tests/ui/*.rs");
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
use client::decl_runtime_apis;
|
||||||
|
|
||||||
|
decl_runtime_apis! {
|
||||||
|
pub trait Api {
|
||||||
|
fn test(at: u64);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
error: `decl_runtime_apis!` adds automatically a parameter `at: &BlockId<Block>`. Please rename/remove your parameter.
|
||||||
|
--> $DIR/adding_at_parameter.rs:5:11
|
||||||
|
|
|
||||||
|
5 | fn test(at: u64);
|
||||||
|
| ^^
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
use client::decl_runtime_apis;
|
||||||
|
|
||||||
|
decl_runtime_apis! {
|
||||||
|
pub trait Api {
|
||||||
|
fn test(&self);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
error: Self values are not supported.
|
||||||
|
--> $DIR/adding_self_parameter.rs:5:11
|
||||||
|
|
|
||||||
|
5 | fn test(&self);
|
||||||
|
| ^
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
use runtime_primitives::traits::GetNodeBlockType;
|
||||||
|
use test_client::runtime::Block;
|
||||||
|
use client::decl_runtime_apis;
|
||||||
|
|
||||||
|
/// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType`
|
||||||
|
/// trait are done by the `construct_runtime!` macro in a real runtime.
|
||||||
|
struct Runtime {}
|
||||||
|
impl GetNodeBlockType for Runtime {
|
||||||
|
type NodeBlock = Block;
|
||||||
|
}
|
||||||
|
|
||||||
|
decl_runtime_apis! {
|
||||||
|
pub trait Api {
|
||||||
|
#[changed_in(2)]
|
||||||
|
fn test(data: u64);
|
||||||
|
fn test(data: u64);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
error: `changed_in` version can not be greater than the `api_version`
|
||||||
|
--> $DIR/changed_in_unknown_version.rs:15:3
|
||||||
|
|
|
||||||
|
15 | fn test(data: u64);
|
||||||
|
| ^^
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
use runtime_primitives::traits::Block as BlockT;
|
||||||
|
use client::decl_runtime_apis;
|
||||||
|
|
||||||
|
decl_runtime_apis! {
|
||||||
|
pub trait Api<Block: BlockT> {
|
||||||
|
fn test();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
error: `Block: BlockT` generic parameter will be added automatically by the `decl_runtime_apis!` macro!
|
||||||
|
--> $DIR/declaring_old_block.rs:5:16
|
||||||
|
|
|
||||||
|
5 | pub trait Api<Block: BlockT> {
|
||||||
|
| ^^^^^
|
||||||
|
|
||||||
|
error: `Block: BlockT` generic parameter will be added automatically by the `decl_runtime_apis!` macro! If you try to use a different trait than the substrate `Block` trait, please rename it locally.
|
||||||
|
--> $DIR/declaring_old_block.rs:5:23
|
||||||
|
|
|
||||||
|
5 | pub trait Api<Block: BlockT> {
|
||||||
|
| ^^^^^^
|
||||||
|
|
||||||
|
warning: unused import: `runtime_primitives::traits::Block as BlockT`
|
||||||
|
--> $DIR/declaring_old_block.rs:1:5
|
||||||
|
|
|
||||||
|
1 | use runtime_primitives::traits::Block as BlockT;
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: #[warn(unused_imports)] on by default
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
use runtime_primitives::traits::Block as BlockT;
|
||||||
|
use client::decl_runtime_apis;
|
||||||
|
|
||||||
|
decl_runtime_apis! {
|
||||||
|
pub trait Api<B: BlockT> {
|
||||||
|
fn test();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
error: `Block: BlockT` generic parameter will be added automatically by the `decl_runtime_apis!` macro! If you try to use a different trait than the substrate `Block` trait, please rename it locally.
|
||||||
|
--> $DIR/declaring_own_block_with_different_name.rs:5:19
|
||||||
|
|
|
||||||
|
5 | pub trait Api<B: BlockT> {
|
||||||
|
| ^^^^^^
|
||||||
|
|
||||||
|
warning: unused import: `runtime_primitives::traits::Block as BlockT`
|
||||||
|
--> $DIR/declaring_own_block_with_different_name.rs:1:5
|
||||||
|
|
|
||||||
|
1 | use runtime_primitives::traits::Block as BlockT;
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: #[warn(unused_imports)] on by default
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
use runtime_primitives::traits::GetNodeBlockType;
|
||||||
|
use test_client::runtime::Block;
|
||||||
|
use client::{decl_runtime_apis, impl_runtime_apis};
|
||||||
|
|
||||||
|
/// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType`
|
||||||
|
/// trait are done by the `construct_runtime!` macro in a real runtime.
|
||||||
|
struct Runtime {}
|
||||||
|
impl GetNodeBlockType for Runtime {
|
||||||
|
type NodeBlock = Block;
|
||||||
|
}
|
||||||
|
|
||||||
|
decl_runtime_apis! {
|
||||||
|
pub trait Api {
|
||||||
|
fn test(data: u64);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl_runtime_apis! {}
|
||||||
|
|
||||||
|
fn main() {}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
error: No api implementation given!
|
||||||
|
--> $DIR/empty_impl_runtime_apis_call.rs:18:1
|
||||||
|
|
|
||||||
|
18 | impl_runtime_apis! {}
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
use runtime_primitives::traits::GetNodeBlockType;
|
||||||
|
use test_client::runtime::Block;
|
||||||
|
use client::{decl_runtime_apis, impl_runtime_apis};
|
||||||
|
|
||||||
|
/// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType`
|
||||||
|
/// trait are done by the `construct_runtime!` macro in a real runtime.
|
||||||
|
struct Runtime {}
|
||||||
|
impl GetNodeBlockType for Runtime {
|
||||||
|
type NodeBlock = Block;
|
||||||
|
}
|
||||||
|
|
||||||
|
decl_runtime_apis! {
|
||||||
|
pub trait Api {
|
||||||
|
fn test(data: u64);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl_runtime_apis! {
|
||||||
|
impl self::Api<Block> for Runtime {
|
||||||
|
fn test(data: String) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
error[E0053]: method `test` has an incompatible type for trait
|
||||||
|
--> $DIR/impl_incorrect_method_signature.rs:20:17
|
||||||
|
|
|
||||||
|
14 | fn test(data: u64);
|
||||||
|
| --- type in trait
|
||||||
|
...
|
||||||
|
20 | fn test(data: String) {}
|
||||||
|
| ^^^^^^ expected u64, found struct `std::string::String`
|
||||||
|
|
|
||||||
|
= note: expected type `fn(u64)`
|
||||||
|
found type `fn(std::string::String)`
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0053`.
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
use runtime_primitives::traits::GetNodeBlockType;
|
||||||
|
use test_client::runtime::Block;
|
||||||
|
use client::{decl_runtime_apis, impl_runtime_apis};
|
||||||
|
|
||||||
|
/// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType`
|
||||||
|
/// trait are done by the `construct_runtime!` macro in a real runtime.
|
||||||
|
struct Runtime {}
|
||||||
|
impl GetNodeBlockType for Runtime {
|
||||||
|
type NodeBlock = Block;
|
||||||
|
}
|
||||||
|
|
||||||
|
decl_runtime_apis! {
|
||||||
|
pub trait Api {
|
||||||
|
fn test(data: u64);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mod second {
|
||||||
|
decl_runtime_apis! {
|
||||||
|
pub trait Api {
|
||||||
|
fn test2(data: u64);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl_runtime_apis! {
|
||||||
|
impl self::Api<Block> for Runtime {
|
||||||
|
fn test(data: u64) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl second::Api<Block> for Runtime {
|
||||||
|
fn test2(data: u64) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
error: Two traits with the same name detected! The trait name is used to generate its ID. Please rename one trait at the declaration!
|
||||||
|
--> $DIR/impl_two_traits_with_same_name.rs:31:15
|
||||||
|
|
|
||||||
|
31 | impl second::Api<Block> for Runtime {
|
||||||
|
| ^^^
|
||||||
|
|
||||||
|
error: cannot find macro `decl_runtime_apis!` in this scope
|
||||||
|
--> $DIR/impl_two_traits_with_same_name.rs:19:2
|
||||||
|
|
|
||||||
|
19 | decl_runtime_apis! {
|
||||||
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error[E0433]: failed to resolve: could not find `runtime_decl_for_Api` in `second`
|
||||||
|
--> $DIR/impl_two_traits_with_same_name.rs:26:1
|
||||||
|
|
|
||||||
|
26 | / impl_runtime_apis! {
|
||||||
|
27 | | impl self::Api<Block> for Runtime {
|
||||||
|
28 | | fn test(data: u64) {}
|
||||||
|
29 | | }
|
||||||
|
... |
|
||||||
|
33 | | }
|
||||||
|
34 | | }
|
||||||
|
| |_^ could not find `runtime_decl_for_Api` in `second`
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0433`.
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
use client::decl_runtime_apis;
|
||||||
|
|
||||||
|
decl_runtime_apis! {
|
||||||
|
#[api_version]
|
||||||
|
pub trait Api {
|
||||||
|
fn test(data: u64);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
error: can't qualify macro invocation with `pub`
|
||||||
|
--> $DIR/invalid_api_version.rs:3:1
|
||||||
|
|
|
||||||
|
3 | / decl_runtime_apis! {
|
||||||
|
4 | | #[api_version]
|
||||||
|
5 | | pub trait Api {
|
||||||
|
6 | | fn test(data: u64);
|
||||||
|
7 | | }
|
||||||
|
8 | | }
|
||||||
|
| |_^
|
||||||
|
|
|
||||||
|
= help: try adjusting the macro to put `pub` inside the invocation
|
||||||
|
|
||||||
|
error: Unexpected `api_version` attribute. The supported format is `api_version(1)`
|
||||||
|
--> $DIR/invalid_api_version.rs:3:1
|
||||||
|
|
|
||||||
|
3 | / decl_runtime_apis! {
|
||||||
|
4 | | #[api_version]
|
||||||
|
5 | | pub trait Api {
|
||||||
|
6 | | fn test(data: u64);
|
||||||
|
7 | | }
|
||||||
|
8 | | }
|
||||||
|
| |_^
|
||||||
|
|
||||||
|
error: Unexpected `api_version` attribute. The supported format is `api_version(1)`
|
||||||
|
--> $DIR/invalid_api_version.rs:4:4
|
||||||
|
|
|
||||||
|
4 | #[api_version]
|
||||||
|
| ^^^^^^^^^^^
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
use client::decl_runtime_apis;
|
||||||
|
|
||||||
|
decl_runtime_apis! {
|
||||||
|
#[api_version("1")]
|
||||||
|
pub trait Api {
|
||||||
|
fn test(data: u64);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
||||||
|
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
error: can't qualify macro invocation with `pub`
|
||||||
|
--> $DIR/invalid_api_version_2.rs:3:1
|
||||||
|
|
|
||||||
|
3 | / decl_runtime_apis! {
|
||||||
|
4 | | #[api_version("1")]
|
||||||
|
5 | | pub trait Api {
|
||||||
|
6 | | fn test(data: u64);
|
||||||
|
7 | | }
|
||||||
|
8 | | }
|
||||||
|
| |_^
|
||||||
|
|
|
||||||
|
= help: try adjusting the macro to put `pub` inside the invocation
|
||||||
|
|
||||||
|
error: Unexpected `api_version` attribute. The supported format is `api_version(1)`
|
||||||
|
--> $DIR/invalid_api_version_2.rs:3:1
|
||||||
|
|
|
||||||
|
3 | / decl_runtime_apis! {
|
||||||
|
4 | | #[api_version("1")]
|
||||||
|
5 | | pub trait Api {
|
||||||
|
6 | | fn test(data: u64);
|
||||||
|
7 | | }
|
||||||
|
8 | | }
|
||||||
|
| |_^
|
||||||
|
|
||||||
|
error: Unexpected `api_version` attribute. The supported format is `api_version(1)`
|
||||||
|
--> $DIR/invalid_api_version_2.rs:4:4
|
||||||
|
|
|
||||||
|
4 | #[api_version("1")]
|
||||||
|
| ^^^^^^^^^^^
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
use client::decl_runtime_apis;
|
||||||
|
|
||||||
|
decl_runtime_apis! {
|
||||||
|
#[api_version()]
|
||||||
|
pub trait Api {
|
||||||
|
fn test(data: u64);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
error: can't qualify macro invocation with `pub`
|
||||||
|
--> $DIR/invalid_api_version_3.rs:3:1
|
||||||
|
|
|
||||||
|
3 | / decl_runtime_apis! {
|
||||||
|
4 | | #[api_version()]
|
||||||
|
5 | | pub trait Api {
|
||||||
|
6 | | fn test(data: u64);
|
||||||
|
7 | | }
|
||||||
|
8 | | }
|
||||||
|
| |_^
|
||||||
|
|
|
||||||
|
= help: try adjusting the macro to put `pub` inside the invocation
|
||||||
|
|
||||||
|
error: Unexpected `api_version` attribute. The supported format is `api_version(1)`
|
||||||
|
--> $DIR/invalid_api_version_3.rs:3:1
|
||||||
|
|
|
||||||
|
3 | / decl_runtime_apis! {
|
||||||
|
4 | | #[api_version()]
|
||||||
|
5 | | pub trait Api {
|
||||||
|
6 | | fn test(data: u64);
|
||||||
|
7 | | }
|
||||||
|
8 | | }
|
||||||
|
| |_^
|
||||||
|
|
||||||
|
error: Unexpected `api_version` attribute. The supported format is `api_version(1)`
|
||||||
|
--> $DIR/invalid_api_version_3.rs:4:4
|
||||||
|
|
|
||||||
|
4 | #[api_version()]
|
||||||
|
| ^^^^^^^^^^^
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
use runtime_primitives::traits::GetNodeBlockType;
|
||||||
|
use test_client::runtime::Block;
|
||||||
|
use client::{decl_runtime_apis, impl_runtime_apis};
|
||||||
|
|
||||||
|
/// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType`
|
||||||
|
/// trait are done by the `construct_runtime!` macro in a real runtime.
|
||||||
|
struct Runtime {}
|
||||||
|
impl GetNodeBlockType for Runtime {
|
||||||
|
type NodeBlock = Block;
|
||||||
|
}
|
||||||
|
|
||||||
|
decl_runtime_apis! {
|
||||||
|
pub trait Api {
|
||||||
|
fn test(data: u64);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl_runtime_apis! {
|
||||||
|
impl self::Api for Runtime {
|
||||||
|
fn test(data: u64) {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
error: Missing `Block` generic parameter.
|
||||||
|
--> $DIR/missing_block_generic_parameter.rs:19:13
|
||||||
|
|
|
||||||
|
19 | impl self::Api for Runtime {
|
||||||
|
| ^^^
|
||||||
|
|
||||||
|
error[E0107]: wrong number of type arguments: expected 1, found 0
|
||||||
|
--> $DIR/missing_block_generic_parameter.rs:19:7
|
||||||
|
|
|
||||||
|
19 | impl self::Api for Runtime {
|
||||||
|
| ^^^^^^^^^ expected 1 type argument
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0107`.
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
use runtime_primitives::traits::GetNodeBlockType;
|
||||||
|
use test_client::runtime::Block;
|
||||||
|
use client::{decl_runtime_apis, impl_runtime_apis};
|
||||||
|
|
||||||
|
/// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType`
|
||||||
|
/// trait are done by the `construct_runtime!` macro in a real runtime.
|
||||||
|
struct Runtime {}
|
||||||
|
impl GetNodeBlockType for Runtime {
|
||||||
|
type NodeBlock = Block;
|
||||||
|
}
|
||||||
|
|
||||||
|
decl_runtime_apis! {
|
||||||
|
pub trait Api {
|
||||||
|
fn test(data: u64);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl_runtime_apis! {
|
||||||
|
impl Api<Block> for Runtime {
|
||||||
|
fn test(data: u64) {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
error: The implemented trait has to be referenced with a path, e.g. `impl client::Core for Runtime`.
|
||||||
|
--> $DIR/missing_path_for_trait.rs:19:7
|
||||||
|
|
|
||||||
|
19 | impl Api<Block> for Runtime {
|
||||||
|
| ^^^
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
use runtime_primitives::traits::GetNodeBlockType;
|
||||||
|
use test_client::runtime::Block;
|
||||||
|
use client::{decl_runtime_apis, impl_runtime_apis};
|
||||||
|
|
||||||
|
/// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType`
|
||||||
|
/// trait are done by the `construct_runtime!` macro in a real runtime.
|
||||||
|
struct Runtime {}
|
||||||
|
impl GetNodeBlockType for Runtime {
|
||||||
|
type NodeBlock = Block;
|
||||||
|
}
|
||||||
|
|
||||||
|
decl_runtime_apis! {
|
||||||
|
pub trait Api {
|
||||||
|
fn test(data: u64);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl_runtime_apis! {
|
||||||
|
impl self::Api<Block> for Runtime {
|
||||||
|
fn test(data: &u64) {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
error[E0053]: method `test` has an incompatible type for trait
|
||||||
|
--> $DIR/type_reference_in_impl_runtime_apis_call.rs:20:17
|
||||||
|
|
|
||||||
|
14 | fn test(data: u64);
|
||||||
|
| --- type in trait
|
||||||
|
...
|
||||||
|
20 | fn test(data: &u64) {
|
||||||
|
| ^^^^ expected u64, found &u64
|
||||||
|
|
|
||||||
|
= note: expected type `fn(u64)`
|
||||||
|
found type `fn(&u64)`
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0053`.
|
||||||
Reference in New Issue
Block a user