This repository has been 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
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sp-api: Set correct where bound in the generated code (#14252)
The where bound for the `create_metadata` function wasn't correct. This pr fixes this by using the where bound declared at the type declaration augmented with the manual where bound.
- Loading branch information
Showing
4 changed files
with
56 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
46 changes: 46 additions & 0 deletions
46
primitives/api/test/tests/ui/positive_cases/custom_where_bound.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,46 @@ | ||
use codec::{Decode, Encode}; | ||
use scale_info::TypeInfo; | ||
use sp_runtime::traits::{Block as BlockT, GetNodeBlockType}; | ||
use substrate_test_runtime_client::runtime::Block; | ||
|
||
struct Runtime {} | ||
impl GetNodeBlockType for Runtime { | ||
type NodeBlock = Block; | ||
} | ||
|
||
pub trait CustomTrait: Encode + Decode + TypeInfo {} | ||
|
||
#[derive(Encode, Decode, TypeInfo)] | ||
pub struct SomeImpl; | ||
impl CustomTrait for SomeImpl {} | ||
|
||
#[derive(Encode, Decode, TypeInfo)] | ||
pub struct SomeOtherType<C: CustomTrait>(C); | ||
|
||
sp_api::decl_runtime_apis! { | ||
pub trait Api<A> where A: CustomTrait { | ||
fn test() -> A; | ||
fn test2() -> SomeOtherType<A>; | ||
} | ||
} | ||
|
||
sp_api::impl_runtime_apis! { | ||
impl self::Api<Block, SomeImpl> for Runtime { | ||
fn test() -> SomeImpl { SomeImpl } | ||
fn test2() -> SomeOtherType<SomeImpl> { SomeOtherType(SomeImpl) } | ||
} | ||
|
||
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) { | ||
unimplemented!() | ||
} | ||
} | ||
} | ||
|
||
fn main() {} |