Skip to content

Commit 3f6bdf2

Browse files
Merge pull request #68 from humanode-network/patch-pallet-error-macro-clippy-cast-possible-truncation
Fix casting `usize` to `u8` at `pallet::error` macro
2 parents 5ea6d95 + f896b6a commit 3f6bdf2

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)