diff --git a/frame/support/procedural/src/pallet/parse/storage.rs b/frame/support/procedural/src/pallet/parse/storage.rs index fee6ec9f1ca87..4e90a423f79ef 100644 --- a/frame/support/procedural/src/pallet/parse/storage.rs +++ b/frame/support/procedural/src/pallet/parse/storage.rs @@ -514,10 +514,16 @@ fn process_unnamed_generics( })?; let use_default_hasher = |arg_pos| { - if let Some(arg) = retrieve_arg(arg_pos).ok() { - dev_mode && syn::parse2::(arg.to_token_stream()).is_ok() + let arg = retrieve_arg(arg_pos)?; + if syn::parse2::(arg.to_token_stream()).is_ok() { + if dev_mode { + Ok(true) + } else { + let msg = "`_` can only be used in dev_mode. Please specify an appropriate hasher."; + Err(syn::Error::new(arg.span(), msg)) + } } else { - false + Ok(false) } }; @@ -528,13 +534,13 @@ fn process_unnamed_generics( None, Metadata::Map { key: retrieve_arg(2)?, value: retrieve_arg(3)? }, retrieve_arg(4).ok(), - use_default_hasher(1), + use_default_hasher(1)?, ), StorageKind::CountedMap => ( None, Metadata::CountedMap { key: retrieve_arg(2)?, value: retrieve_arg(3)? }, retrieve_arg(4).ok(), - use_default_hasher(1), + use_default_hasher(1)?, ), StorageKind::DoubleMap => ( None, @@ -544,7 +550,7 @@ fn process_unnamed_generics( value: retrieve_arg(5)?, }, retrieve_arg(6).ok(), - use_default_hasher(1) && use_default_hasher(3), + use_default_hasher(1)? && use_default_hasher(3)?, ), StorageKind::NMap => { let keygen = retrieve_arg(1)?; diff --git a/frame/support/test/tests/pallet_ui/dev_mode_without_arg_default_hasher.stderr b/frame/support/test/tests/pallet_ui/dev_mode_without_arg_default_hasher.stderr index 5317f5c52b9b6..e0dbc8c953b4e 100644 --- a/frame/support/test/tests/pallet_ui/dev_mode_without_arg_default_hasher.stderr +++ b/frame/support/test/tests/pallet_ui/dev_mode_without_arg_default_hasher.stderr @@ -1,19 +1,11 @@ -error[E0121]: the placeholder `_` is not allowed within types on item signatures for type aliases +error: `_` can only be used in dev_mode. Please specify an appropriate hasher. --> tests/pallet_ui/dev_mode_without_arg_default_hasher.rs:21:47 | 21 | type MyStorageMap = StorageMap<_, _, u32, u64>; - | ^ not allowed in type signatures + | ^ -error[E0121]: the placeholder `_` is not allowed within types on item signatures for type aliases - --> tests/pallet_ui/dev_mode_without_arg_default_hasher.rs:24:59 - | -24 | type MyStorageDoubleMap = StorageDoubleMap<_, _, u32, _, u64, u64>; - | ^ ^ not allowed in type signatures - | | - | not allowed in type signatures - -error[E0121]: the placeholder `_` is not allowed within types on item signatures for type aliases - --> tests/pallet_ui/dev_mode_without_arg_default_hasher.rs:27:61 - | -27 | type MyCountedStorageMap = CountedStorageMap<_, _, u32, u64>; - | ^ not allowed in type signatures +error[E0432]: unresolved import `pallet` + --> tests/pallet_ui/dev_mode_without_arg_default_hasher.rs:3:9 + | +3 | pub use pallet::*; + | ^^^^^^ help: a similar path exists: `test_pallet::pallet`