mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 10:01:17 +00:00
Fixes error message when _ is used without dev mode (#13886)
* Initial changes * Adds UI test for error when _ is used without dev_mode * Minor * ".git/.scripts/commands/fmt/fmt.sh" * Adds test to verify hasher * Fixes error message when _ is used without dev mode * Updates test * Addresses review comment --------- Co-authored-by: command-bot <>
This commit is contained in:
@@ -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::<syn::Token![_]>(arg.to_token_stream()).is_ok()
|
||||
let arg = retrieve_arg(arg_pos)?;
|
||||
if syn::parse2::<syn::Token![_]>(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)?;
|
||||
|
||||
+7
-15
@@ -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<T: Config> = 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<T: Config> = 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<T: Config> = 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`
|
||||
|
||||
Reference in New Issue
Block a user