Skip to content

Commit 65cf65a

Browse files
Fix casting usize to u8 at pallet::error macro (reapplying 3f6bdf2) (#74)
* Fix casting usize to u8 at pallet::error macro * Edit error message Co-authored-by: MOZGIII <mike-n@narod.ru> Co-authored-by: MOZGIII <mike-n@narod.ru>
1 parent 18bb7c7 commit 65cf65a

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

  • frame/support/procedural/src/pallet/expand

frame/support/procedural/src/pallet/expand/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,11 @@ pub fn expand_error(def: &mut Def) -> proc_macro2::TokenStream {
152152
{
153153
fn from(err: #error_ident<#type_use_gen>) -> Self {
154154
use #frame_support::codec::Encode;
155-
let index = <
155+
let index: u8 = <
156156
<T as #frame_system::Config>::PalletInfo
157157
as #frame_support::traits::PalletInfo
158158
>::index::<Pallet<#type_use_gen>>()
159-
.expect("Every active module has an index in the runtime; qed") as u8;
159+
.expect("Every active module has an index in the runtime; qed").try_into().expect("Index should fit into u8");
160160
let mut encoded = err.encode();
161161
encoded.resize(#frame_support::MAX_MODULE_ERROR_ENCODED_SIZE, 0);
162162

0 commit comments

Comments
 (0)