mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 00:01:03 +00:00
clippy fixes (#9173)
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user