mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-06 02:08:02 +00:00
Improve error message on where clause on pallet error (#7821)
* improve error message on where clause on pallet error * Revert "improve error message on where clause on pallet error" This reverts commit 5a3cc38976813fccef3357833553ce30f5b988ea. * Revert "Revert "improve error message on where clause on pallet error"" This reverts commit e3b3fca6bc4fa89816f80dbcb82dc4536a9b2549.
This commit is contained in:
committed by
GitHub
parent
031b4ddabb
commit
ccce3405f4
@@ -53,7 +53,7 @@ impl ErrorDef {
|
||||
instances.push(helper::check_type_def_gen_no_bounds(&item.generics, item.ident.span())?);
|
||||
|
||||
if item.generics.where_clause.is_some() {
|
||||
let msg = "Invalid pallet::error, unexpected where clause";
|
||||
let msg = "Invalid pallet::error, where clause is not allowed on pallet error item";
|
||||
return Err(syn::Error::new(item.generics.where_clause.as_ref().unwrap().span(), msg));
|
||||
}
|
||||
|
||||
|
||||
@@ -1256,6 +1256,8 @@ pub mod pallet_prelude {
|
||||
/// }
|
||||
/// ```
|
||||
/// I.e. a regular rust enum named `Error`, with generic `T` and fieldless variants.
|
||||
/// The generic `T` mustn't bound anything and where clause is not allowed. But bounds and where
|
||||
/// clause shouldn't be needed for any usecase.
|
||||
///
|
||||
/// ### Macro expansion
|
||||
///
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
#[frame_support::pallet]
|
||||
mod pallet {
|
||||
use frame_support::pallet_prelude::Hooks;
|
||||
use frame_system::pallet_prelude::BlockNumberFor;
|
||||
|
||||
#[pallet::config]
|
||||
pub trait Config: frame_system::Config {}
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(core::marker::PhantomData<T>);
|
||||
|
||||
#[pallet::hooks]
|
||||
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {}
|
||||
|
||||
#[pallet::call]
|
||||
impl<T: Config> Pallet<T> {}
|
||||
|
||||
#[pallet::error]
|
||||
pub enum Error<T> where u32: From<u8> {}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
error: Invalid pallet::error, where clause is not allowed on pallet error item
|
||||
--> $DIR/error_where_clause.rs:19:20
|
||||
|
|
||||
19 | pub enum Error<T> where u32: From<u8> {}
|
||||
| ^^^^^
|
||||
Reference in New Issue
Block a user