mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 08:11:04 +00:00
allow where clause in decl_error (#7324)
This commit is contained in:
committed by
GitHub
parent
8503cc0892
commit
1164ced041
@@ -77,6 +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 )* $(,)? )?
|
||||||
{
|
{
|
||||||
$(
|
$(
|
||||||
$( #[doc = $doc_attr:tt] )*
|
$( #[doc = $doc_attr:tt] )*
|
||||||
@@ -86,7 +87,9 @@ 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 )* )?
|
||||||
|
{
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
__Ignore(
|
__Ignore(
|
||||||
$crate::sp_std::marker::PhantomData<($generic, $( $inst_generic)?)>,
|
$crate::sp_std::marker::PhantomData<($generic, $( $inst_generic)?)>,
|
||||||
@@ -100,13 +103,16 @@ 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 )* )?
|
||||||
{
|
{
|
||||||
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())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 )* )?
|
||||||
|
{
|
||||||
fn as_u8(&self) -> u8 {
|
fn as_u8(&self) -> u8 {
|
||||||
$crate::decl_error! {
|
$crate::decl_error! {
|
||||||
@GENERATE_AS_U8
|
@GENERATE_AS_U8
|
||||||
@@ -130,6 +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 )* )?
|
||||||
{
|
{
|
||||||
fn from(err: $error<$generic $(, $inst_generic)?>) -> &'static str {
|
fn from(err: $error<$generic $(, $inst_generic)?>) -> &'static str {
|
||||||
err.as_str()
|
err.as_str()
|
||||||
@@ -138,6 +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 )* )?
|
||||||
{
|
{
|
||||||
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>
|
||||||
@@ -154,6 +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 )* )?
|
||||||
{
|
{
|
||||||
fn metadata() -> &'static [$crate::error::ErrorMetadata] {
|
fn metadata() -> &'static [$crate::error::ErrorMetadata] {
|
||||||
&[
|
&[
|
||||||
|
|||||||
@@ -81,6 +81,13 @@ mod module1 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
frame_support::decl_error! {
|
||||||
|
pub enum Error for Module<T: Trait<I>, I: Instance> where T::BlockNumber: From<u32> {
|
||||||
|
/// Test
|
||||||
|
Test,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
frame_support::decl_event! {
|
frame_support::decl_event! {
|
||||||
pub enum Event<T, I> where Phantom = std::marker::PhantomData<T> {
|
pub enum Event<T, I> where Phantom = std::marker::PhantomData<T> {
|
||||||
_Phantom(Phantom),
|
_Phantom(Phantom),
|
||||||
|
|||||||
Reference in New Issue
Block a user