Skip to content

Commit

Permalink
Fix casting usize to u8 at pallet::error macro (#91) (#95)
Browse files Browse the repository at this point in the history
Fix casting `usize` to `u8` at `pallet::error` macro (reapplying `3f6bdf2`) (#74) (#80)

* Fix casting usize to u8 at pallet::error macro

* Edit error message

Co-authored-by: MOZGIII <mike-n@narod.ru>
  • Loading branch information
dmitrylavrenov and MOZGIII authored Nov 14, 2023
1 parent 98f2e34 commit ef66069
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions frame/support/procedural/src/pallet/expand/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,11 @@ pub fn expand_error(def: &mut Def) -> proc_macro2::TokenStream {
{
fn from(err: #error_ident<#type_use_gen>) -> Self {
use #frame_support::codec::Encode;
let index = <
let index: u8 = <
<T as #frame_system::Config>::PalletInfo
as #frame_support::traits::PalletInfo
>::index::<Pallet<#type_use_gen>>()
.expect("Every active module has an index in the runtime; qed") as u8;
.expect("Every active module has an index in the runtime; qed").try_into().expect("Index should fit into u8");
let mut encoded = err.encode();
encoded.resize(#frame_support::MAX_MODULE_ERROR_ENCODED_SIZE, 0);

Expand Down

0 comments on commit ef66069

Please sign in to comment.