mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-20 22:11:01 +00:00
Allow multiple bounds to be specified at decl_error! (#7448)
* Allow multiple bounds to be specified at decl_error! Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Test if decl_error! accepts multiple bounds Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
9687759774
commit
9bfaf451a7
@@ -77,7 +77,7 @@ macro_rules! decl_error {
|
|||||||
$generic:ident: $trait:path
|
$generic:ident: $trait:path
|
||||||
$(, $inst_generic:ident: $instance:path)?
|
$(, $inst_generic:ident: $instance:path)?
|
||||||
>
|
>
|
||||||
$( where $( $where_ty:ty: $where_bound:path )* $(,)? )?
|
$( where $( $where_ty:ty: $where_bound:path ),* $(,)? )?
|
||||||
{
|
{
|
||||||
$(
|
$(
|
||||||
$( #[doc = $doc_attr:tt] )*
|
$( #[doc = $doc_attr:tt] )*
|
||||||
@@ -88,7 +88,7 @@ macro_rules! decl_error {
|
|||||||
) => {
|
) => {
|
||||||
$(#[$attr])*
|
$(#[$attr])*
|
||||||
pub enum $error<$generic: $trait $(, $inst_generic: $instance)?>
|
pub enum $error<$generic: $trait $(, $inst_generic: $instance)?>
|
||||||
$( where $( $where_ty: $where_bound )* )?
|
$( where $( $where_ty: $where_bound ),* )?
|
||||||
{
|
{
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
__Ignore(
|
__Ignore(
|
||||||
@@ -103,7 +103,7 @@ macro_rules! decl_error {
|
|||||||
|
|
||||||
impl<$generic: $trait $(, $inst_generic: $instance)?> $crate::sp_std::fmt::Debug
|
impl<$generic: $trait $(, $inst_generic: $instance)?> $crate::sp_std::fmt::Debug
|
||||||
for $error<$generic $(, $inst_generic)?>
|
for $error<$generic $(, $inst_generic)?>
|
||||||
$( where $( $where_ty: $where_bound )* )?
|
$( where $( $where_ty: $where_bound ),* )?
|
||||||
{
|
{
|
||||||
fn fmt(&self, f: &mut $crate::sp_std::fmt::Formatter<'_>) -> $crate::sp_std::fmt::Result {
|
fn fmt(&self, f: &mut $crate::sp_std::fmt::Formatter<'_>) -> $crate::sp_std::fmt::Result {
|
||||||
f.write_str(self.as_str())
|
f.write_str(self.as_str())
|
||||||
@@ -111,7 +111,7 @@ macro_rules! decl_error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<$generic: $trait $(, $inst_generic: $instance)?> $error<$generic $(, $inst_generic)?>
|
impl<$generic: $trait $(, $inst_generic: $instance)?> $error<$generic $(, $inst_generic)?>
|
||||||
$( where $( $where_ty: $where_bound )* )?
|
$( where $( $where_ty: $where_bound ),* )?
|
||||||
{
|
{
|
||||||
fn as_u8(&self) -> u8 {
|
fn as_u8(&self) -> u8 {
|
||||||
$crate::decl_error! {
|
$crate::decl_error! {
|
||||||
@@ -136,7 +136,7 @@ macro_rules! decl_error {
|
|||||||
|
|
||||||
impl<$generic: $trait $(, $inst_generic: $instance)?> From<$error<$generic $(, $inst_generic)?>>
|
impl<$generic: $trait $(, $inst_generic: $instance)?> From<$error<$generic $(, $inst_generic)?>>
|
||||||
for &'static str
|
for &'static str
|
||||||
$( where $( $where_ty: $where_bound )* )?
|
$( where $( $where_ty: $where_bound ),* )?
|
||||||
{
|
{
|
||||||
fn from(err: $error<$generic $(, $inst_generic)?>) -> &'static str {
|
fn from(err: $error<$generic $(, $inst_generic)?>) -> &'static str {
|
||||||
err.as_str()
|
err.as_str()
|
||||||
@@ -145,7 +145,7 @@ macro_rules! decl_error {
|
|||||||
|
|
||||||
impl<$generic: $trait $(, $inst_generic: $instance)?> From<$error<$generic $(, $inst_generic)?>>
|
impl<$generic: $trait $(, $inst_generic: $instance)?> From<$error<$generic $(, $inst_generic)?>>
|
||||||
for $crate::sp_runtime::DispatchError
|
for $crate::sp_runtime::DispatchError
|
||||||
$( where $( $where_ty: $where_bound )* )?
|
$( where $( $where_ty: $where_bound ),* )?
|
||||||
{
|
{
|
||||||
fn from(err: $error<$generic $(, $inst_generic)?>) -> Self {
|
fn from(err: $error<$generic $(, $inst_generic)?>) -> Self {
|
||||||
let index = <$generic::PalletInfo as $crate::traits::PalletInfo>
|
let index = <$generic::PalletInfo as $crate::traits::PalletInfo>
|
||||||
@@ -162,7 +162,7 @@ macro_rules! decl_error {
|
|||||||
|
|
||||||
impl<$generic: $trait $(, $inst_generic: $instance)?> $crate::error::ModuleErrorMetadata
|
impl<$generic: $trait $(, $inst_generic: $instance)?> $crate::error::ModuleErrorMetadata
|
||||||
for $error<$generic $(, $inst_generic)?>
|
for $error<$generic $(, $inst_generic)?>
|
||||||
$( where $( $where_ty: $where_bound )* )?
|
$( where $( $where_ty: $where_bound ),* )?
|
||||||
{
|
{
|
||||||
fn metadata() -> &'static [$crate::error::ErrorMetadata] {
|
fn metadata() -> &'static [$crate::error::ErrorMetadata] {
|
||||||
&[
|
&[
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ pub trait Currency {}
|
|||||||
// * Origin, Inherent, Event
|
// * Origin, Inherent, Event
|
||||||
mod module1 {
|
mod module1 {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use sp_std::ops::Add;
|
||||||
|
|
||||||
pub trait Trait<I>: system::Trait where <Self as system::Trait>::BlockNumber: From<u32> {
|
pub trait Trait<I>: system::Trait where <Self as system::Trait>::BlockNumber: From<u32> {
|
||||||
type Event: From<Event<Self, I>> + Into<<Self as system::Trait>::Event>;
|
type Event: From<Event<Self, I>> + Into<<Self as system::Trait>::Event>;
|
||||||
@@ -82,7 +83,11 @@ mod module1 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
frame_support::decl_error! {
|
frame_support::decl_error! {
|
||||||
pub enum Error for Module<T: Trait<I>, I: Instance> where T::BlockNumber: From<u32> {
|
pub enum Error for Module<T: Trait<I>, I: Instance> where
|
||||||
|
T::BlockNumber: From<u32>,
|
||||||
|
T::BlockNumber: Add,
|
||||||
|
T::AccountId: AsRef<[u8]>,
|
||||||
|
{
|
||||||
/// Test
|
/// Test
|
||||||
Test,
|
Test,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user