From 0601b497422f8f96ccf32338d037dc4d3d44a379 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Fri, 9 Dec 2022 20:11:42 +0100 Subject: [PATCH 1/9] Warn on missing call_index Signed-off-by: Oliver Tale-Yazdi --- .../procedural/src/pallet/expand/call.rs | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/frame/support/procedural/src/pallet/expand/call.rs b/frame/support/procedural/src/pallet/expand/call.rs index 6b166e6726d38..addc1dd1d4d1b 100644 --- a/frame/support/procedural/src/pallet/expand/call.rs +++ b/frame/support/procedural/src/pallet/expand/call.rs @@ -54,6 +54,34 @@ pub fn expand_call(def: &mut Def) -> proc_macro2::TokenStream { .map(|fn_name| format!("Create a call with the variant `{}`.", fn_name)) .collect::>(); + let mut warning_structs = Vec::new(); + let mut warning_names = Vec::new(); + // Emit a warning for each call that is missing `call_index` when not in dev-mode. + for method in &methods { + let explicit_call_index = + crate::pallet::parse::helper::take_item_pallet_attrs(&mut method.clone().attrs) + .unwrap_or_default() + .into_iter() + .any(|attr| matches!(attr, crate::pallet::parse::call::FunctionAttr::Weight(_))); + if explicit_call_index || def.dev_mode { + continue + } + + let name = + syn::Ident::new(&format!("implicit_call_index_{}", method.name), method.name.span()); + let warning: syn::ItemStruct = syn::parse_quote!( + #[deprecated(note = r" + `pallet::call_index` is missing on a call while the dev-mode is disabled. + Please ensure that either all your calls have the `pallet::call_index` attribute or + that the dev-mode for your pallet is enabled. For more info see: + and + .")] + struct #name; + ); + warning_names.push(name); + warning_structs.push(warning); + } + let fn_weight = methods.iter().map(|method| &method.weight); let fn_doc = methods.iter().map(|method| &method.docs).collect::>(); @@ -178,6 +206,14 @@ pub fn expand_call(def: &mut Def) -> proc_macro2::TokenStream { .collect::>(); quote::quote_spanned!(span => + fn __trigger_warnings() { + #( + #warning_structs + // This triggers the deprecated warnings. + let _ = #warning_names; + )* + } + #[doc(hidden)] pub mod __substrate_call_check { #[macro_export] From d6ac74fb6ec6dc7b4d2a73231432eb4006503410 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Fri, 9 Dec 2022 20:32:08 +0100 Subject: [PATCH 2/9] Suppress camel case warning Signed-off-by: Oliver Tale-Yazdi --- frame/support/procedural/src/pallet/expand/call.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/frame/support/procedural/src/pallet/expand/call.rs b/frame/support/procedural/src/pallet/expand/call.rs index addc1dd1d4d1b..5e4642b7562f4 100644 --- a/frame/support/procedural/src/pallet/expand/call.rs +++ b/frame/support/procedural/src/pallet/expand/call.rs @@ -76,6 +76,7 @@ pub fn expand_call(def: &mut Def) -> proc_macro2::TokenStream { that the dev-mode for your pallet is enabled. For more info see: and .")] + #[allow(non_camel_case_types)] struct #name; ); warning_names.push(name); From 5e206d84e37151f43f59cf117abb67fb4d765dd4 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Mon, 12 Dec 2022 20:39:22 +0100 Subject: [PATCH 3/9] Simplify code Signed-off-by: Oliver Tale-Yazdi --- .../procedural/src/pallet/expand/call.rs | 21 +++++++------------ .../procedural/src/pallet/parse/call.rs | 4 ++++ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/frame/support/procedural/src/pallet/expand/call.rs b/frame/support/procedural/src/pallet/expand/call.rs index 5e4642b7562f4..3a00b6d767a3d 100644 --- a/frame/support/procedural/src/pallet/expand/call.rs +++ b/frame/support/procedural/src/pallet/expand/call.rs @@ -58,24 +58,19 @@ pub fn expand_call(def: &mut Def) -> proc_macro2::TokenStream { let mut warning_names = Vec::new(); // Emit a warning for each call that is missing `call_index` when not in dev-mode. for method in &methods { - let explicit_call_index = - crate::pallet::parse::helper::take_item_pallet_attrs(&mut method.clone().attrs) - .unwrap_or_default() - .into_iter() - .any(|attr| matches!(attr, crate::pallet::parse::call::FunctionAttr::Weight(_))); - if explicit_call_index || def.dev_mode { + if method.explicit_call_index || def.dev_mode { continue } let name = - syn::Ident::new(&format!("implicit_call_index_{}", method.name), method.name.span()); + syn::Ident::new(&format!("{}", method.name), method.name.span()); let warning: syn::ItemStruct = syn::parse_quote!( #[deprecated(note = r" - `pallet::call_index` is missing on a call while the dev-mode is disabled. - Please ensure that either all your calls have the `pallet::call_index` attribute or - that the dev-mode for your pallet is enabled. For more info see: - and - .")] + Implicit call indices are deprecated in favour of explicit ones. + Please ensure that all calls have the `pallet::call_index` attribute or that the + `dev-mode` of the pallet is enabled. For more info see: + and + .")] #[allow(non_camel_case_types)] struct #name; ); @@ -207,7 +202,7 @@ pub fn expand_call(def: &mut Def) -> proc_macro2::TokenStream { .collect::>(); quote::quote_spanned!(span => - fn __trigger_warnings() { + fn __warnings() { #( #warning_structs // This triggers the deprecated warnings. diff --git a/frame/support/procedural/src/pallet/parse/call.rs b/frame/support/procedural/src/pallet/parse/call.rs index fbca9a52c767c..9620038edfd6d 100644 --- a/frame/support/procedural/src/pallet/parse/call.rs +++ b/frame/support/procedural/src/pallet/parse/call.rs @@ -59,6 +59,8 @@ pub struct CallVariantDef { pub weight: syn::Expr, /// Call index of the dispatchable. pub call_index: u8, + /// Whether an explicit call index was specified. + pub explicit_call_index: bool, /// Docs, used for metadata. pub docs: Vec, /// Attributes annotated at the top of the dispatchable function. @@ -243,6 +245,7 @@ impl CallDef { FunctionAttr::CallIndex(idx) => idx, _ => unreachable!("checked during creation of the let binding"), }); + let explicit_call_index = call_index.is_some(); let final_index = match call_index { Some(i) => i, @@ -296,6 +299,7 @@ impl CallDef { name: method.sig.ident.clone(), weight, call_index: final_index, + explicit_call_index, args, docs, attrs: method.attrs.clone(), From a00adb3f79e7d1ccc6ebade0cfe15f0b91244be4 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Mon, 12 Dec 2022 20:40:17 +0100 Subject: [PATCH 4/9] Disallow warnings in pallet-ui tests Signed-off-by: Oliver Tale-Yazdi --- frame/support/test/tests/pallet_ui.rs | 3 +++ .../test/tests/pallet_ui/call_argument_invalid_bound.rs | 3 ++- .../test/tests/pallet_ui/call_argument_invalid_bound_2.rs | 3 ++- .../test/tests/pallet_ui/call_argument_invalid_bound_3.rs | 3 ++- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/frame/support/test/tests/pallet_ui.rs b/frame/support/test/tests/pallet_ui.rs index 2db1d3cb0543a..26d016c5a7796 100644 --- a/frame/support/test/tests/pallet_ui.rs +++ b/frame/support/test/tests/pallet_ui.rs @@ -27,6 +27,9 @@ fn pallet_ui() { // As trybuild is using `cargo check`, we don't need the real WASM binaries. std::env::set_var("SKIP_WASM_BUILD", "1"); + // Deny all warnings since we emit warnings as part of a Pallet's UI. + std::env::set_var("RUSTFLAGS", "--deny warnings"); + let t = trybuild::TestCases::new(); t.compile_fail("tests/pallet_ui/*.rs"); t.pass("tests/pallet_ui/pass/*.rs"); diff --git a/frame/support/test/tests/pallet_ui/call_argument_invalid_bound.rs b/frame/support/test/tests/pallet_ui/call_argument_invalid_bound.rs index ee9d692eba9b3..4f18f7281817a 100644 --- a/frame/support/test/tests/pallet_ui/call_argument_invalid_bound.rs +++ b/frame/support/test/tests/pallet_ui/call_argument_invalid_bound.rs @@ -17,7 +17,8 @@ mod pallet { #[pallet::call] impl Pallet { #[pallet::weight(0)] - pub fn foo(origin: OriginFor, bar: T::Bar) -> DispatchResultWithPostInfo { + #[pallet::call_index(0)] + pub fn foo(origin: OriginFor, _bar: T::Bar) -> DispatchResultWithPostInfo { Ok(().into()) } } diff --git a/frame/support/test/tests/pallet_ui/call_argument_invalid_bound_2.rs b/frame/support/test/tests/pallet_ui/call_argument_invalid_bound_2.rs index d981b55c48620..20568908e72b2 100644 --- a/frame/support/test/tests/pallet_ui/call_argument_invalid_bound_2.rs +++ b/frame/support/test/tests/pallet_ui/call_argument_invalid_bound_2.rs @@ -17,7 +17,8 @@ mod pallet { #[pallet::call] impl Pallet { #[pallet::weight(0)] - pub fn foo(origin: OriginFor, bar: T::Bar) -> DispatchResultWithPostInfo { + #[pallet::call_index(0)] + pub fn foo(origin: OriginFor, _bar: T::Bar) -> DispatchResultWithPostInfo { Ok(().into()) } } diff --git a/frame/support/test/tests/pallet_ui/call_argument_invalid_bound_3.rs b/frame/support/test/tests/pallet_ui/call_argument_invalid_bound_3.rs index 1cdfb369feadb..64b6642b0a878 100644 --- a/frame/support/test/tests/pallet_ui/call_argument_invalid_bound_3.rs +++ b/frame/support/test/tests/pallet_ui/call_argument_invalid_bound_3.rs @@ -19,7 +19,8 @@ mod pallet { #[pallet::call] impl Pallet { #[pallet::weight(0)] - pub fn foo(origin: OriginFor, bar: Bar) -> DispatchResultWithPostInfo { + #[pallet::call_index(0)] + pub fn foo(origin: OriginFor, _bar: Bar) -> DispatchResultWithPostInfo { Ok(().into()) } } From a26ff78122898b70813dbb4e7f5038bf193ded5b Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Mon, 12 Dec 2022 20:40:22 +0100 Subject: [PATCH 5/9] Add pallet UI test Signed-off-by: Oliver Tale-Yazdi --- .../tests/pallet_ui/call_missing_index.rs | 22 +++++++++++++++++++ .../tests/pallet_ui/call_missing_index.stderr | 12 ++++++++++ 2 files changed, 34 insertions(+) create mode 100644 frame/support/test/tests/pallet_ui/call_missing_index.rs create mode 100644 frame/support/test/tests/pallet_ui/call_missing_index.stderr diff --git a/frame/support/test/tests/pallet_ui/call_missing_index.rs b/frame/support/test/tests/pallet_ui/call_missing_index.rs new file mode 100644 index 0000000000000..7e305a573d622 --- /dev/null +++ b/frame/support/test/tests/pallet_ui/call_missing_index.rs @@ -0,0 +1,22 @@ +#[frame_support::pallet] +mod pallet { + use frame_support::pallet_prelude::DispatchResult; + use frame_system::pallet_prelude::OriginFor; + + #[pallet::config] + pub trait Config: frame_system::Config {} + + #[pallet::pallet] + pub struct Pallet(core::marker::PhantomData); + + #[pallet::call] + impl Pallet { + #[pallet::weight(0)] + pub fn foo(_: OriginFor) -> DispatchResult { + Ok(()) + } + } +} + +fn main() { +} diff --git a/frame/support/test/tests/pallet_ui/call_missing_index.stderr b/frame/support/test/tests/pallet_ui/call_missing_index.stderr new file mode 100644 index 0000000000000..8fc87eb8e951c --- /dev/null +++ b/frame/support/test/tests/pallet_ui/call_missing_index.stderr @@ -0,0 +1,12 @@ +error: use of deprecated unit struct `pallet::__warnings::foo`: + Implicit call indices are deprecated in favour of explicit ones. + Please ensure that all calls have the `pallet::call_index` attribute or that the + `dev-mode` of the pallet is enabled. For more info see: + and + . + --> tests/pallet_ui/call_missing_index.rs:15:10 + | +15 | pub fn foo(_: OriginFor) -> DispatchResultWith {} + | ^^^ + | + = note: `-D deprecated` implied by `-D warnings` From 92b1dd7d009ee84ecaa52ecdcd16e1cc80315f29 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Mon, 12 Dec 2022 21:39:16 +0100 Subject: [PATCH 6/9] Update Pallet UI Signed-off-by: Oliver Tale-Yazdi --- .../call_argument_invalid_bound.stderr | 18 +++++++------- .../call_argument_invalid_bound_2.stderr | 24 +++++++++---------- .../call_argument_invalid_bound_3.stderr | 6 ++--- .../tests/pallet_ui/call_missing_index.stderr | 2 +- ...ev_mode_without_arg_max_encoded_len.stderr | 13 ++++++++++ 5 files changed, 38 insertions(+), 25 deletions(-) diff --git a/frame/support/test/tests/pallet_ui/call_argument_invalid_bound.stderr b/frame/support/test/tests/pallet_ui/call_argument_invalid_bound.stderr index 62d8649f8af49..aed53b07b5e63 100644 --- a/frame/support/test/tests/pallet_ui/call_argument_invalid_bound.stderr +++ b/frame/support/test/tests/pallet_ui/call_argument_invalid_bound.stderr @@ -1,21 +1,21 @@ error[E0277]: `::Bar` doesn't implement `std::fmt::Debug` - --> tests/pallet_ui/call_argument_invalid_bound.rs:20:36 + --> tests/pallet_ui/call_argument_invalid_bound.rs:21:36 | -20 | pub fn foo(origin: OriginFor, bar: T::Bar) -> DispatchResultWithPostInfo { - | ^^^ `::Bar` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug` +21 | pub fn foo(origin: OriginFor, _bar: T::Bar) -> DispatchResultWithPostInfo { + | ^^^^ `::Bar` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug` | = help: the trait `std::fmt::Debug` is not implemented for `::Bar` = note: required for `&::Bar` to implement `std::fmt::Debug` = note: required for the cast from `&::Bar` to the object type `dyn std::fmt::Debug` error[E0277]: the trait bound `::Bar: Clone` is not satisfied - --> tests/pallet_ui/call_argument_invalid_bound.rs:20:36 + --> tests/pallet_ui/call_argument_invalid_bound.rs:21:36 | -20 | pub fn foo(origin: OriginFor, bar: T::Bar) -> DispatchResultWithPostInfo { - | ^^^ the trait `Clone` is not implemented for `::Bar` +21 | pub fn foo(origin: OriginFor, _bar: T::Bar) -> DispatchResultWithPostInfo { + | ^^^^ the trait `Clone` is not implemented for `::Bar` error[E0369]: binary operation `==` cannot be applied to type `&::Bar` - --> tests/pallet_ui/call_argument_invalid_bound.rs:20:36 + --> tests/pallet_ui/call_argument_invalid_bound.rs:21:36 | -20 | pub fn foo(origin: OriginFor, bar: T::Bar) -> DispatchResultWithPostInfo { - | ^^^ +21 | pub fn foo(origin: OriginFor, _bar: T::Bar) -> DispatchResultWithPostInfo { + | ^^^^ diff --git a/frame/support/test/tests/pallet_ui/call_argument_invalid_bound_2.stderr b/frame/support/test/tests/pallet_ui/call_argument_invalid_bound_2.stderr index f486c071631ea..3e2e70432a9c9 100644 --- a/frame/support/test/tests/pallet_ui/call_argument_invalid_bound_2.stderr +++ b/frame/support/test/tests/pallet_ui/call_argument_invalid_bound_2.stderr @@ -1,27 +1,27 @@ error[E0277]: `::Bar` doesn't implement `std::fmt::Debug` - --> tests/pallet_ui/call_argument_invalid_bound_2.rs:20:36 + --> tests/pallet_ui/call_argument_invalid_bound_2.rs:21:36 | -20 | pub fn foo(origin: OriginFor, bar: T::Bar) -> DispatchResultWithPostInfo { - | ^^^ `::Bar` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug` +21 | pub fn foo(origin: OriginFor, _bar: T::Bar) -> DispatchResultWithPostInfo { + | ^^^^ `::Bar` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug` | = help: the trait `std::fmt::Debug` is not implemented for `::Bar` = note: required for `&::Bar` to implement `std::fmt::Debug` = note: required for the cast from `&::Bar` to the object type `dyn std::fmt::Debug` error[E0277]: the trait bound `::Bar: Clone` is not satisfied - --> tests/pallet_ui/call_argument_invalid_bound_2.rs:20:36 + --> tests/pallet_ui/call_argument_invalid_bound_2.rs:21:36 | -20 | pub fn foo(origin: OriginFor, bar: T::Bar) -> DispatchResultWithPostInfo { - | ^^^ the trait `Clone` is not implemented for `::Bar` +21 | pub fn foo(origin: OriginFor, _bar: T::Bar) -> DispatchResultWithPostInfo { + | ^^^^ the trait `Clone` is not implemented for `::Bar` error[E0369]: binary operation `==` cannot be applied to type `&::Bar` - --> tests/pallet_ui/call_argument_invalid_bound_2.rs:20:36 + --> tests/pallet_ui/call_argument_invalid_bound_2.rs:21:36 | -20 | pub fn foo(origin: OriginFor, bar: T::Bar) -> DispatchResultWithPostInfo { - | ^^^ +21 | pub fn foo(origin: OriginFor, _bar: T::Bar) -> DispatchResultWithPostInfo { + | ^^^^ error[E0277]: the trait bound `::Bar: WrapperTypeEncode` is not satisfied - --> tests/pallet_ui/call_argument_invalid_bound_2.rs:20:36 + --> tests/pallet_ui/call_argument_invalid_bound_2.rs:21:36 | 1 | / #[frame_support::pallet] 2 | | mod pallet { @@ -32,8 +32,8 @@ error[E0277]: the trait bound `::Bar: WrapperTypeEncode` is 17 | | #[pallet::call] | |__________________- required by a bound introduced by this call ... -20 | pub fn foo(origin: OriginFor, bar: T::Bar) -> DispatchResultWithPostInfo { - | ^^^ the trait `WrapperTypeEncode` is not implemented for `::Bar` +21 | pub fn foo(origin: OriginFor, _bar: T::Bar) -> DispatchResultWithPostInfo { + | ^^^^ the trait `WrapperTypeEncode` is not implemented for `::Bar` | = note: required for `::Bar` to implement `Encode` diff --git a/frame/support/test/tests/pallet_ui/call_argument_invalid_bound_3.stderr b/frame/support/test/tests/pallet_ui/call_argument_invalid_bound_3.stderr index 6e51bf2dbf862..395da09cb0d6d 100644 --- a/frame/support/test/tests/pallet_ui/call_argument_invalid_bound_3.stderr +++ b/frame/support/test/tests/pallet_ui/call_argument_invalid_bound_3.stderr @@ -1,8 +1,8 @@ error[E0277]: `Bar` doesn't implement `std::fmt::Debug` - --> tests/pallet_ui/call_argument_invalid_bound_3.rs:22:36 + --> tests/pallet_ui/call_argument_invalid_bound_3.rs:23:36 | -22 | pub fn foo(origin: OriginFor, bar: Bar) -> DispatchResultWithPostInfo { - | ^^^ `Bar` cannot be formatted using `{:?}` +23 | pub fn foo(origin: OriginFor, _bar: Bar) -> DispatchResultWithPostInfo { + | ^^^^ `Bar` cannot be formatted using `{:?}` | = help: the trait `std::fmt::Debug` is not implemented for `Bar` = note: add `#[derive(Debug)]` to `Bar` or manually `impl std::fmt::Debug for Bar` diff --git a/frame/support/test/tests/pallet_ui/call_missing_index.stderr b/frame/support/test/tests/pallet_ui/call_missing_index.stderr index 8fc87eb8e951c..0048e0f40fb2e 100644 --- a/frame/support/test/tests/pallet_ui/call_missing_index.stderr +++ b/frame/support/test/tests/pallet_ui/call_missing_index.stderr @@ -6,7 +6,7 @@ error: use of deprecated unit struct `pallet::__warnings::foo`: . --> tests/pallet_ui/call_missing_index.rs:15:10 | -15 | pub fn foo(_: OriginFor) -> DispatchResultWith {} +15 | pub fn foo(_: OriginFor) -> DispatchResult { | ^^^ | = note: `-D deprecated` implied by `-D warnings` diff --git a/frame/support/test/tests/pallet_ui/dev_mode_without_arg_max_encoded_len.stderr b/frame/support/test/tests/pallet_ui/dev_mode_without_arg_max_encoded_len.stderr index a5ec31a9bb4e7..c0f1ed56b8764 100644 --- a/frame/support/test/tests/pallet_ui/dev_mode_without_arg_max_encoded_len.stderr +++ b/frame/support/test/tests/pallet_ui/dev_mode_without_arg_max_encoded_len.stderr @@ -1,3 +1,16 @@ +error: use of deprecated unit struct `pallet::__warnings::my_call`: + Implicit call indices are deprecated in favour of explicit ones. + Please ensure that all calls have the `pallet::call_index` attribute or that the + `dev-mode` of the pallet is enabled. For more info see: + and + . + --> tests/pallet_ui/dev_mode_without_arg_max_encoded_len.rs:25:10 + | +25 | pub fn my_call(_origin: OriginFor) -> DispatchResult { + | ^^^^^^^ + | + = note: `-D deprecated` implied by `-D warnings` + error[E0277]: the trait bound `Vec: MaxEncodedLen` is not satisfied --> tests/pallet_ui/dev_mode_without_arg_max_encoded_len.rs:11:12 | From d2c4ab5ebc3a0e51c5b6c65c9a1caec1ad1455af Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Mon, 12 Dec 2022 22:36:30 +0100 Subject: [PATCH 7/9] fmt Signed-off-by: Oliver Tale-Yazdi --- frame/support/procedural/src/pallet/expand/call.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frame/support/procedural/src/pallet/expand/call.rs b/frame/support/procedural/src/pallet/expand/call.rs index 3a00b6d767a3d..9e405576f679e 100644 --- a/frame/support/procedural/src/pallet/expand/call.rs +++ b/frame/support/procedural/src/pallet/expand/call.rs @@ -62,8 +62,7 @@ pub fn expand_call(def: &mut Def) -> proc_macro2::TokenStream { continue } - let name = - syn::Ident::new(&format!("{}", method.name), method.name.span()); + let name = syn::Ident::new(&format!("{}", method.name), method.name.span()); let warning: syn::ItemStruct = syn::parse_quote!( #[deprecated(note = r" Implicit call indices are deprecated in favour of explicit ones. From ffa1066dc1679e3e4740ce1ad58c114eba992228 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Wed, 14 Dec 2022 17:29:51 +0100 Subject: [PATCH 8/9] Use module instead of function Signed-off-by: Oliver Tale-Yazdi --- frame/support/procedural/src/pallet/expand/call.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frame/support/procedural/src/pallet/expand/call.rs b/frame/support/procedural/src/pallet/expand/call.rs index 9e405576f679e..30ef1a8fca31d 100644 --- a/frame/support/procedural/src/pallet/expand/call.rs +++ b/frame/support/procedural/src/pallet/expand/call.rs @@ -201,11 +201,11 @@ pub fn expand_call(def: &mut Def) -> proc_macro2::TokenStream { .collect::>(); quote::quote_spanned!(span => - fn __warnings() { + mod warnings { #( #warning_structs - // This triggers the deprecated warnings. - let _ = #warning_names; + // This triggers each deprecated warning once. + const _: Option<#warning_names> = None; )* } From 5f4bbe2290336077eb49192c4bf19cdb1272b6cb Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Wed, 14 Dec 2022 17:39:40 +0100 Subject: [PATCH 9/9] Update pallet-ui Signed-off-by: Oliver Tale-Yazdi --- frame/support/test/tests/pallet_ui/call_missing_index.stderr | 2 +- .../tests/pallet_ui/dev_mode_without_arg_max_encoded_len.stderr | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frame/support/test/tests/pallet_ui/call_missing_index.stderr b/frame/support/test/tests/pallet_ui/call_missing_index.stderr index 0048e0f40fb2e..9d00204979211 100644 --- a/frame/support/test/tests/pallet_ui/call_missing_index.stderr +++ b/frame/support/test/tests/pallet_ui/call_missing_index.stderr @@ -1,4 +1,4 @@ -error: use of deprecated unit struct `pallet::__warnings::foo`: +error: use of deprecated struct `pallet::warnings::foo`: Implicit call indices are deprecated in favour of explicit ones. Please ensure that all calls have the `pallet::call_index` attribute or that the `dev-mode` of the pallet is enabled. For more info see: diff --git a/frame/support/test/tests/pallet_ui/dev_mode_without_arg_max_encoded_len.stderr b/frame/support/test/tests/pallet_ui/dev_mode_without_arg_max_encoded_len.stderr index c0f1ed56b8764..170555665d877 100644 --- a/frame/support/test/tests/pallet_ui/dev_mode_without_arg_max_encoded_len.stderr +++ b/frame/support/test/tests/pallet_ui/dev_mode_without_arg_max_encoded_len.stderr @@ -1,4 +1,4 @@ -error: use of deprecated unit struct `pallet::__warnings::my_call`: +error: use of deprecated struct `pallet::warnings::my_call`: Implicit call indices are deprecated in favour of explicit ones. Please ensure that all calls have the `pallet::call_index` attribute or that the `dev-mode` of the pallet is enabled. For more info see: