Skip to content

Commit b4b7175

Browse files
committed
undo clippy changes to procedural-fork since we have silenced
1 parent bbab17a commit b4b7175

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+13983
-14850
lines changed

support/procedural-fork/src/benchmark.rs

Lines changed: 1022 additions & 1099 deletions
Large diffs are not rendered by default.

support/procedural-fork/src/construct_runtime/expand/call.rs

Lines changed: 195 additions & 198 deletions
Large diffs are not rendered by default.

support/procedural-fork/src/construct_runtime/expand/composite_helper.rs

Lines changed: 66 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -20,82 +20,82 @@ use proc_macro2::{Ident, TokenStream};
2020
use quote::quote;
2121

2222
pub(crate) fn expand_conversion_fn(
23-
composite_name: &str,
24-
path: &PalletPath,
25-
instance: Option<&Ident>,
26-
variant_name: &Ident,
23+
composite_name: &str,
24+
path: &PalletPath,
25+
instance: Option<&Ident>,
26+
variant_name: &Ident,
2727
) -> TokenStream {
28-
let composite_name = quote::format_ident!("{}", composite_name);
29-
let runtime_composite_name = quote::format_ident!("Runtime{}", composite_name);
28+
let composite_name = quote::format_ident!("{}", composite_name);
29+
let runtime_composite_name = quote::format_ident!("Runtime{}", composite_name);
3030

31-
if let Some(inst) = instance {
32-
quote! {
33-
impl From<#path::#composite_name<#path::#inst>> for #runtime_composite_name {
34-
fn from(hr: #path::#composite_name<#path::#inst>) -> Self {
35-
#runtime_composite_name::#variant_name(hr)
36-
}
37-
}
38-
}
39-
} else {
40-
quote! {
41-
impl From<#path::#composite_name> for #runtime_composite_name {
42-
fn from(hr: #path::#composite_name) -> Self {
43-
#runtime_composite_name::#variant_name(hr)
44-
}
45-
}
46-
}
47-
}
31+
if let Some(inst) = instance {
32+
quote! {
33+
impl From<#path::#composite_name<#path::#inst>> for #runtime_composite_name {
34+
fn from(hr: #path::#composite_name<#path::#inst>) -> Self {
35+
#runtime_composite_name::#variant_name(hr)
36+
}
37+
}
38+
}
39+
} else {
40+
quote! {
41+
impl From<#path::#composite_name> for #runtime_composite_name {
42+
fn from(hr: #path::#composite_name) -> Self {
43+
#runtime_composite_name::#variant_name(hr)
44+
}
45+
}
46+
}
47+
}
4848
}
4949

5050
pub(crate) fn expand_variant(
51-
composite_name: &str,
52-
index: u8,
53-
path: &PalletPath,
54-
instance: Option<&Ident>,
55-
variant_name: &Ident,
51+
composite_name: &str,
52+
index: u8,
53+
path: &PalletPath,
54+
instance: Option<&Ident>,
55+
variant_name: &Ident,
5656
) -> TokenStream {
57-
let composite_name = quote::format_ident!("{}", composite_name);
57+
let composite_name = quote::format_ident!("{}", composite_name);
5858

59-
if let Some(inst) = instance {
60-
quote! {
61-
#[codec(index = #index)]
62-
#variant_name(#path::#composite_name<#path::#inst>),
63-
}
64-
} else {
65-
quote! {
66-
#[codec(index = #index)]
67-
#variant_name(#path::#composite_name),
68-
}
69-
}
59+
if let Some(inst) = instance {
60+
quote! {
61+
#[codec(index = #index)]
62+
#variant_name(#path::#composite_name<#path::#inst>),
63+
}
64+
} else {
65+
quote! {
66+
#[codec(index = #index)]
67+
#variant_name(#path::#composite_name),
68+
}
69+
}
7070
}
7171

7272
pub(crate) fn expand_variant_count(
73-
composite_name: &str,
74-
path: &PalletPath,
75-
instance: Option<&Ident>,
73+
composite_name: &str,
74+
path: &PalletPath,
75+
instance: Option<&Ident>,
7676
) -> TokenStream {
77-
let composite_name = quote::format_ident!("{}", composite_name);
77+
let composite_name = quote::format_ident!("{}", composite_name);
7878

79-
if let Some(inst) = instance {
80-
quote! {
81-
#path::#composite_name::<#path::#inst>::VARIANT_COUNT
82-
}
83-
} else {
84-
// Wrapped `<`..`>` means: use default type parameter for enum.
85-
//
86-
// This is used for pallets without instance support or pallets with instance support when
87-
// we don't specify instance:
88-
//
89-
// ```
90-
// pub struct Pallet<T, I = ()>{..}
91-
//
92-
// #[pallet::composite_enum]
93-
// pub enum HoldReason<I: 'static = ()> {..}
94-
//
95-
// Pallet1: pallet_x, // <- default type parameter
96-
// ```
97-
quote! {
98-
<#path::#composite_name>::VARIANT_COUNT
99-
}
100-
}
79+
if let Some(inst) = instance {
80+
quote! {
81+
#path::#composite_name::<#path::#inst>::VARIANT_COUNT
82+
}
83+
} else {
84+
// Wrapped `<`..`>` means: use default type parameter for enum.
85+
//
86+
// This is used for pallets without instance support or pallets with instance support when
87+
// we don't specify instance:
88+
//
89+
// ```
90+
// pub struct Pallet<T, I = ()>{..}
91+
//
92+
// #[pallet::composite_enum]
93+
// pub enum HoldReason<I: 'static = ()> {..}
94+
//
95+
// Pallet1: pallet_x, // <- default type parameter
96+
// ```
97+
quote! {
98+
<#path::#composite_name>::VARIANT_COUNT
99+
}
100+
}
101101
}

support/procedural-fork/src/construct_runtime/expand/config.rs

Lines changed: 99 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -23,135 +23,125 @@ use std::str::FromStr;
2323
use syn::Ident;
2424

2525
pub fn expand_outer_config(
26-
runtime: &Ident,
27-
pallet_decls: &[Pallet],
28-
scrate: &TokenStream,
26+
runtime: &Ident,
27+
pallet_decls: &[Pallet],
28+
scrate: &TokenStream,
2929
) -> TokenStream {
30-
let mut types = TokenStream::new();
31-
let mut fields = TokenStream::new();
32-
let mut genesis_build_calls = TokenStream::new();
33-
let mut query_genesis_config_part_macros = Vec::new();
30+
let mut types = TokenStream::new();
31+
let mut fields = TokenStream::new();
32+
let mut genesis_build_calls = TokenStream::new();
33+
let mut query_genesis_config_part_macros = Vec::new();
3434

35-
for decl in pallet_decls {
36-
if let Some(pallet_entry) = decl.find_part("Config") {
37-
let path = &decl.path;
38-
let pallet_name = &decl.name;
39-
let path_str = path.into_token_stream().to_string();
40-
let config = format_ident!("{}Config", pallet_name);
41-
let field_name =
42-
&Ident::new(&pallet_name.to_string().to_snake_case(), decl.name.span());
43-
let part_is_generic = !pallet_entry.generics.params.is_empty();
44-
let attr = &decl
45-
.cfg_pattern
46-
.iter()
47-
.fold(TokenStream::new(), |acc, pattern| {
48-
let attr = TokenStream::from_str(&format!("#[cfg({})]", pattern.original()))
49-
.expect("was successfully parsed before; qed");
50-
quote! {
51-
#acc
52-
#attr
53-
}
54-
});
35+
for decl in pallet_decls {
36+
if let Some(pallet_entry) = decl.find_part("Config") {
37+
let path = &decl.path;
38+
let pallet_name = &decl.name;
39+
let path_str = path.into_token_stream().to_string();
40+
let config = format_ident!("{}Config", pallet_name);
41+
let field_name =
42+
&Ident::new(&pallet_name.to_string().to_snake_case(), decl.name.span());
43+
let part_is_generic = !pallet_entry.generics.params.is_empty();
44+
let attr = &decl.cfg_pattern.iter().fold(TokenStream::new(), |acc, pattern| {
45+
let attr = TokenStream::from_str(&format!("#[cfg({})]", pattern.original()))
46+
.expect("was successfully parsed before; qed");
47+
quote! {
48+
#acc
49+
#attr
50+
}
51+
});
5552

56-
types.extend(expand_config_types(
57-
attr,
58-
runtime,
59-
decl,
60-
&config,
61-
part_is_generic,
62-
));
63-
fields.extend(quote!(#attr pub #field_name: #config,));
64-
genesis_build_calls.extend(expand_config_build_storage_call(
65-
scrate, &config, attr, field_name,
66-
));
67-
query_genesis_config_part_macros.push(quote! {
53+
types.extend(expand_config_types(attr, runtime, decl, &config, part_is_generic));
54+
fields.extend(quote!(#attr pub #field_name: #config,));
55+
genesis_build_calls
56+
.extend(expand_config_build_storage_call(scrate, &config, attr, field_name));
57+
query_genesis_config_part_macros.push(quote! {
6858
#path::__substrate_genesis_config_check::is_genesis_config_defined!(#pallet_name);
6959
#[cfg(feature = "std")]
7060
#path::__substrate_genesis_config_check::is_std_enabled_for_genesis!(#pallet_name, #path_str);
7161
});
72-
}
73-
}
62+
}
63+
}
7464

75-
quote! {
76-
#( #query_genesis_config_part_macros )*
65+
quote! {
66+
#( #query_genesis_config_part_macros )*
7767

78-
#types
68+
#types
7969

80-
use #scrate::__private::serde as __genesis_config_serde_import__;
81-
#[derive(#scrate::__private::serde::Serialize, #scrate::__private::serde::Deserialize, Default)]
82-
#[serde(rename_all = "camelCase")]
83-
#[serde(deny_unknown_fields)]
84-
#[serde(crate = "__genesis_config_serde_import__")]
85-
pub struct RuntimeGenesisConfig {
86-
#fields
87-
}
70+
use #scrate::__private::serde as __genesis_config_serde_import__;
71+
#[derive(#scrate::__private::serde::Serialize, #scrate::__private::serde::Deserialize, Default)]
72+
#[serde(rename_all = "camelCase")]
73+
#[serde(deny_unknown_fields)]
74+
#[serde(crate = "__genesis_config_serde_import__")]
75+
pub struct RuntimeGenesisConfig {
76+
#fields
77+
}
8878

89-
#[cfg(any(feature = "std", test))]
90-
impl #scrate::sp_runtime::BuildStorage for RuntimeGenesisConfig {
91-
fn assimilate_storage(
92-
&self,
93-
storage: &mut #scrate::sp_runtime::Storage,
94-
) -> std::result::Result<(), String> {
95-
#scrate::__private::BasicExternalities::execute_with_storage(storage, || {
96-
<Self as #scrate::traits::BuildGenesisConfig>::build(&self);
97-
Ok(())
98-
})
99-
}
100-
}
79+
#[cfg(any(feature = "std", test))]
80+
impl #scrate::sp_runtime::BuildStorage for RuntimeGenesisConfig {
81+
fn assimilate_storage(
82+
&self,
83+
storage: &mut #scrate::sp_runtime::Storage,
84+
) -> std::result::Result<(), String> {
85+
#scrate::__private::BasicExternalities::execute_with_storage(storage, || {
86+
<Self as #scrate::traits::BuildGenesisConfig>::build(&self);
87+
Ok(())
88+
})
89+
}
90+
}
10191

102-
impl #scrate::traits::BuildGenesisConfig for RuntimeGenesisConfig {
103-
fn build(&self) {
104-
#genesis_build_calls
105-
<AllPalletsWithSystem as #scrate::traits::OnGenesis>::on_genesis();
106-
}
107-
}
92+
impl #scrate::traits::BuildGenesisConfig for RuntimeGenesisConfig {
93+
fn build(&self) {
94+
#genesis_build_calls
95+
<AllPalletsWithSystem as #scrate::traits::OnGenesis>::on_genesis();
96+
}
97+
}
10898

109-
/// Test the `Default` derive impl of the `RuntimeGenesisConfig`.
110-
#[cfg(test)]
111-
#[test]
112-
fn test_genesis_config_builds() {
113-
#scrate::__private::sp_io::TestExternalities::default().execute_with(|| {
114-
<RuntimeGenesisConfig as #scrate::traits::BuildGenesisConfig>::build(
115-
&RuntimeGenesisConfig::default()
116-
);
117-
});
118-
}
119-
}
99+
/// Test the `Default` derive impl of the `RuntimeGenesisConfig`.
100+
#[cfg(test)]
101+
#[test]
102+
fn test_genesis_config_builds() {
103+
#scrate::__private::sp_io::TestExternalities::default().execute_with(|| {
104+
<RuntimeGenesisConfig as #scrate::traits::BuildGenesisConfig>::build(
105+
&RuntimeGenesisConfig::default()
106+
);
107+
});
108+
}
109+
}
120110
}
121111

122112
fn expand_config_types(
123-
attr: &TokenStream,
124-
runtime: &Ident,
125-
decl: &Pallet,
126-
config: &Ident,
127-
part_is_generic: bool,
113+
attr: &TokenStream,
114+
runtime: &Ident,
115+
decl: &Pallet,
116+
config: &Ident,
117+
part_is_generic: bool,
128118
) -> TokenStream {
129-
let path = &decl.path;
119+
let path = &decl.path;
130120

131-
match (decl.instance.as_ref(), part_is_generic) {
132-
(Some(inst), true) => quote! {
133-
#attr
134-
pub type #config = #path::GenesisConfig<#runtime, #path::#inst>;
135-
},
136-
(None, true) => quote! {
137-
#attr
138-
pub type #config = #path::GenesisConfig<#runtime>;
139-
},
140-
(_, false) => quote! {
141-
#attr
142-
pub type #config = #path::GenesisConfig;
143-
},
144-
}
121+
match (decl.instance.as_ref(), part_is_generic) {
122+
(Some(inst), true) => quote! {
123+
#attr
124+
pub type #config = #path::GenesisConfig<#runtime, #path::#inst>;
125+
},
126+
(None, true) => quote! {
127+
#attr
128+
pub type #config = #path::GenesisConfig<#runtime>;
129+
},
130+
(_, false) => quote! {
131+
#attr
132+
pub type #config = #path::GenesisConfig;
133+
},
134+
}
145135
}
146136

147137
fn expand_config_build_storage_call(
148-
scrate: &TokenStream,
149-
pallet_genesis_config: &Ident,
150-
attr: &TokenStream,
151-
field_name: &Ident,
138+
scrate: &TokenStream,
139+
pallet_genesis_config: &Ident,
140+
attr: &TokenStream,
141+
field_name: &Ident,
152142
) -> TokenStream {
153-
quote! {
154-
#attr
155-
<#pallet_genesis_config as #scrate::traits::BuildGenesisConfig>::build(&self.#field_name);
156-
}
143+
quote! {
144+
#attr
145+
<#pallet_genesis_config as #scrate::traits::BuildGenesisConfig>::build(&self.#field_name);
146+
}
157147
}

0 commit comments

Comments
 (0)