-
Notifications
You must be signed in to change notification settings - Fork 726
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
104 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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
61 changes: 61 additions & 0 deletions
61
substrate/primitives/api/test/tests/ui/incorrect_extension_import.rs
This file contains 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,61 @@ | ||
// This file is part of Substrate. | ||
|
||
// Copyright (C) Parity Technologies (UK) Ltd. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
use sp_runtime::traits::Block as BlockT; | ||
use substrate_test_runtime_client::runtime::Block; | ||
|
||
struct Runtime {} | ||
|
||
sp_api::decl_runtime_apis! { | ||
#[api_version(2)] | ||
pub trait Api { | ||
fn test1(); | ||
fn test2(); | ||
#[api_version(3)] | ||
fn test3(); | ||
#[api_version(4)] | ||
fn test4(); | ||
} | ||
} | ||
|
||
sp_api::impl_runtime_apis! { | ||
impl sp_api::Core<Block> for Runtime { | ||
fn version() -> sp_version::RuntimeVersion { | ||
unimplemented!() | ||
} | ||
fn execute_block(_: Block) { | ||
unimplemented!() | ||
} | ||
fn initialize_block(_: &<Block as BlockT>::Header) -> sp_runtime::ExtrinsicInclusionMode { | ||
unimplemented!() | ||
} | ||
} | ||
|
||
use example::{api, *}; | ||
} | ||
|
||
#[sp_api::impl_runtime_apis_ext] | ||
mod example { | ||
use super::*; | ||
#[api_version(2)] | ||
impl self::Api<Block> for Runtime { | ||
fn test1() {} | ||
fn test2() {} | ||
} | ||
} | ||
|
||
fn main() {} |
21 changes: 21 additions & 0 deletions
21
substrate/primitives/api/test/tests/ui/incorrect_extension_import.stderr
This file contains 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,21 @@ | ||
error: Unsupported syntax used to import api implementaions from an extension module. Try using `pub use <path>::*` or `use <path>::*` | ||
--> tests/ui/incorrect_extension_import.rs:48:15 | ||
| | ||
48 | use example::{api, *}; | ||
| ^^^^^^^^ | ||
|
||
error[E0412]: cannot find type `RuntimeApiImpl` in this scope | ||
--> tests/ui/incorrect_extension_import.rs:51:1 | ||
| | ||
51 | #[sp_api::impl_runtime_apis_ext] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope | ||
| | ||
= note: this error originates in the attribute macro `sp_api::impl_runtime_apis_ext` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
warning: unused import: `sp_runtime::traits::Block` | ||
--> tests/ui/incorrect_extension_import.rs:18:5 | ||
| | ||
18 | use sp_runtime::traits::Block as BlockT; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `#[warn(unused_imports)]` on by default |