mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 00:28:01 +00:00
clippy fixes (#9173)
This commit is contained in:
@@ -76,7 +76,7 @@ pub fn group_derive(ast: &DeriveInput) -> proc_macro::TokenStream {
|
||||
let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();
|
||||
let fork_name = Ident::new(&format!("{}Fork", name), Span::call_site());
|
||||
|
||||
let fork_fields = generate_fork_fields(&crate_name, &field_names, &field_types);
|
||||
let fork_fields = generate_fork_fields(crate_name, &field_names, &field_types);
|
||||
let to_fork = generate_base_to_fork(&fork_name, &field_names);
|
||||
let combine_with = generate_combine_with(&field_names);
|
||||
let to_base = generate_fork_to_base(name, &field_names);
|
||||
@@ -88,7 +88,7 @@ pub fn group_derive(ast: &DeriveInput) -> proc_macro::TokenStream {
|
||||
Error::new(Span::call_site(), &format!("Could not find `serde` crate: {}", e))
|
||||
.to_compile_error();
|
||||
|
||||
return quote!( #err ).into()
|
||||
return quote!( #err )
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -62,14 +62,14 @@ use syn::parse::{Parse, ParseStream};
|
||||
/// use sp_runtime::curve::PiecewiseLinear;
|
||||
///
|
||||
/// pallet_staking_reward_curve::build! {
|
||||
/// const I_NPOS: PiecewiseLinear<'static> = curve!(
|
||||
/// min_inflation: 0_025_000,
|
||||
/// max_inflation: 0_100_000,
|
||||
/// ideal_stake: 0_500_000,
|
||||
/// falloff: 0_050_000,
|
||||
/// max_piece_count: 40,
|
||||
/// test_precision: 0_005_000,
|
||||
/// );
|
||||
/// const I_NPOS: PiecewiseLinear<'static> = curve!(
|
||||
/// min_inflation: 0_025_000,
|
||||
/// max_inflation: 0_100_000,
|
||||
/// ideal_stake: 0_500_000,
|
||||
/// falloff: 0_050_000,
|
||||
/// max_piece_count: 40,
|
||||
/// test_precision: 0_005_000,
|
||||
/// );
|
||||
/// }
|
||||
/// ```
|
||||
#[proc_macro]
|
||||
@@ -163,9 +163,9 @@ fn parse_field<Token: Parse + Default + ToTokens>(
|
||||
input: ParseStream,
|
||||
bounds: Bounds,
|
||||
) -> syn::Result<u32> {
|
||||
<Token>::parse(&input)?;
|
||||
<syn::Token![:]>::parse(&input)?;
|
||||
let value_lit = syn::LitInt::parse(&input)?;
|
||||
<Token>::parse(input)?;
|
||||
<syn::Token![:]>::parse(input)?;
|
||||
let value_lit = syn::LitInt::parse(input)?;
|
||||
let value: u32 = value_lit.base10_parse()?;
|
||||
if !bounds.check(value) {
|
||||
return Err(syn::Error::new(
|
||||
@@ -186,15 +186,15 @@ impl Parse for INposInput {
|
||||
fn parse(input: ParseStream) -> syn::Result<Self> {
|
||||
let args_input;
|
||||
|
||||
<syn::Token![const]>::parse(&input)?;
|
||||
let ident = <syn::Ident>::parse(&input)?;
|
||||
<syn::Token![:]>::parse(&input)?;
|
||||
let typ = <syn::Type>::parse(&input)?;
|
||||
<syn::Token![=]>::parse(&input)?;
|
||||
<keyword::curve>::parse(&input)?;
|
||||
<syn::Token![!]>::parse(&input)?;
|
||||
<syn::Token![const]>::parse(input)?;
|
||||
let ident = <syn::Ident>::parse(input)?;
|
||||
<syn::Token![:]>::parse(input)?;
|
||||
let typ = <syn::Type>::parse(input)?;
|
||||
<syn::Token![=]>::parse(input)?;
|
||||
<keyword::curve>::parse(input)?;
|
||||
<syn::Token![!]>::parse(input)?;
|
||||
syn::parenthesized!(args_input in input);
|
||||
<syn::Token![;]>::parse(&input)?;
|
||||
<syn::Token![;]>::parse(input)?;
|
||||
|
||||
if !input.is_empty() {
|
||||
return Err(input.error("expected end of input stream, no token expected"))
|
||||
@@ -288,9 +288,7 @@ impl INPoS {
|
||||
fn compute_points(input: &INposInput) -> Vec<(u32, u32)> {
|
||||
let inpos = INPoS::from_input(input);
|
||||
|
||||
let mut points = vec![];
|
||||
points.push((0, inpos.i_0));
|
||||
points.push((inpos.x_ideal, inpos.i_ideal_times_x_ideal));
|
||||
let mut points = vec![(0, inpos.i_0), (inpos.x_ideal, inpos.i_ideal_times_x_ideal)];
|
||||
|
||||
// For each point p: (next_p.0 - p.0) < segment_length && (next_p.1 - p.1) < segment_length.
|
||||
// This ensures that the total number of segment doesn't overflow max_piece_count.
|
||||
@@ -445,5 +443,4 @@ fn generate_test_module(input: &INposInput) -> TokenStream2 {
|
||||
}
|
||||
}
|
||||
)
|
||||
.into()
|
||||
}
|
||||
|
||||
@@ -46,14 +46,14 @@ pub fn log2(p: u32, q: u32) -> u32 {
|
||||
|
||||
// find the power of 2 where q * 2^n <= p < q * 2^(n+1)
|
||||
let mut n = 0u32;
|
||||
while !(p >= pow2!(n) * q) || !(p < pow2!(n + 1) * q) {
|
||||
while (p < pow2!(n) * q) || (p >= pow2!(n + 1) * q) {
|
||||
n += 1;
|
||||
assert!(n < 32); // cannot represent 2^32 in u32
|
||||
}
|
||||
assert!(p < pow2!(n + 1) * q);
|
||||
|
||||
let y_num: u32 = (p - pow2!(n) * q).try_into().unwrap();
|
||||
let y_den: u32 = (p + pow2!(n) * q).try_into().unwrap();
|
||||
let y_num: u32 = p - pow2!(n) * q;
|
||||
let y_den: u32 = p + pow2!(n) * q;
|
||||
|
||||
// Loop through each Taylor series coefficient until it reaches 10^-6
|
||||
let mut res = n * 1_000_000u32;
|
||||
|
||||
@@ -89,7 +89,7 @@ pub fn generate_solution_type(item: TokenStream) -> TokenStream {
|
||||
|
||||
let solution_struct = struct_def(
|
||||
vis,
|
||||
ident.clone(),
|
||||
ident,
|
||||
count,
|
||||
voter_type.clone(),
|
||||
target_type.clone(),
|
||||
|
||||
@@ -101,7 +101,7 @@ mod inner {
|
||||
/// Proxy function to mpsc::UnboundedSender
|
||||
pub fn unbounded_send(&self, msg: T) -> Result<(), TrySendError<T>> {
|
||||
self.1.unbounded_send(msg).map(|s| {
|
||||
UNBOUNDED_CHANNELS_COUNTER.with_label_values(&[self.0, &"send"]).inc();
|
||||
UNBOUNDED_CHANNELS_COUNTER.with_label_values(&[self.0, "send"]).inc();
|
||||
s
|
||||
})
|
||||
}
|
||||
@@ -128,9 +128,7 @@ mod inner {
|
||||
}
|
||||
// and discount the messages
|
||||
if count > 0 {
|
||||
UNBOUNDED_CHANNELS_COUNTER
|
||||
.with_label_values(&[self.0, &"dropped"])
|
||||
.inc_by(count);
|
||||
UNBOUNDED_CHANNELS_COUNTER.with_label_values(&[self.0, "dropped"]).inc_by(count);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,7 +144,7 @@ mod inner {
|
||||
pub fn try_next(&mut self) -> Result<Option<T>, TryRecvError> {
|
||||
self.1.try_next().map(|s| {
|
||||
if s.is_some() {
|
||||
UNBOUNDED_CHANNELS_COUNTER.with_label_values(&[self.0, &"received"]).inc();
|
||||
UNBOUNDED_CHANNELS_COUNTER.with_label_values(&[self.0, "received"]).inc();
|
||||
}
|
||||
s
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user