Skip to content

Commit

Permalink
fix(pallet-support-procedural): remove unwanted formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
pandres95 committed Mar 6, 2024
1 parent 05b0820 commit 5312b58
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 22 deletions.
4 changes: 2 additions & 2 deletions substrate/frame/benchmarking/src/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ macro_rules! impl_bench_name_tests {
// Every variant must implement [`BenchmarkingSetup`].
//
// ```nocompile
//
//
// struct Transfer;
// impl BenchmarkingSetup for Transfer { ... }
//
Expand Down Expand Up @@ -1866,7 +1866,7 @@ macro_rules! add_benchmark {
verify,
e,
);
return Err(e.into());
return Err(e.into())
},
Err($crate::BenchmarkError::Skip) => {
$crate::__private::log::error!(
Expand Down
36 changes: 16 additions & 20 deletions substrate/frame/support/procedural/src/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ impl syn::parse::Parse for BenchmarkAttrKeyword {
let lookahead = input.lookahead1();
if lookahead.peek(keywords::extra) {
let _extra: keywords::extra = input.parse()?;
return Ok(BenchmarkAttrKeyword::Extra);
return Ok(BenchmarkAttrKeyword::Extra)
} else if lookahead.peek(keywords::skip_meta) {
let _skip_meta: keywords::skip_meta = input.parse()?;
return Ok(BenchmarkAttrKeyword::SkipMeta);
return Ok(BenchmarkAttrKeyword::SkipMeta)
} else {
return Err(lookahead.error());
return Err(lookahead.error())
}
}
}
Expand All @@ -104,13 +104,13 @@ impl syn::parse::Parse for BenchmarkAttrs {
match arg {
BenchmarkAttrKeyword::Extra => {
if extra {
return Err(input.error("`extra` can only be specified once"));
return Err(input.error("`extra` can only be specified once"))
}
extra = true;
},
BenchmarkAttrKeyword::SkipMeta => {
if skip_meta {
return Err(input.error("`skip_meta` can only be specified once"));
return Err(input.error("`skip_meta` can only be specified once"))
}
skip_meta = true;
},
Expand Down Expand Up @@ -169,7 +169,7 @@ fn ensure_valid_return_type(item_fn: &ItemFn) -> Result<()> {
return Err(Error::new(
typ.span(),
"Only `Result<(), BenchmarkError>` or a blank return type is allowed on benchmark function definitions",
));
))
};
let seg = path
.segments
Expand All @@ -179,7 +179,7 @@ fn ensure_valid_return_type(item_fn: &ItemFn) -> Result<()> {
// ensure T in Result<T, E> is ()
let Type::Tuple(tup) = res.unit else { return non_unit(res.unit.span()) };
if !tup.elems.is_empty() {
return non_unit(tup.span());
return non_unit(tup.span())
}
let TypePath { path, qself: _ } = res.e_type;
let seg = path
Expand All @@ -199,7 +199,7 @@ fn parse_params(item_fn: &ItemFn) -> Result<Vec<ParamDef>> {
return Err(Error::new(
span,
"Invalid benchmark function param. A valid example would be `x: Linear<5, 10>`.",
));
))
};

let FnArg::Typed(arg) = arg else { return invalid_param(arg.span()) };
Expand All @@ -215,11 +215,11 @@ fn parse_params(item_fn: &ItemFn) -> Result<Vec<ParamDef>> {
};
let name = ident.ident.to_token_stream().to_string();
if name.len() > 1 {
return invalid_param_name();
return invalid_param_name()
};
let Some(name_char) = name.chars().next() else { return invalid_param_name() };
if !name_char.is_alphabetic() || !name_char.is_lowercase() {
return invalid_param_name();
return invalid_param_name()
}

// parse type
Expand Down Expand Up @@ -284,12 +284,11 @@ fn parse_call_def(item_fn: &ItemFn) -> Result<(usize, BenchmarkCallDef)> {
Ok(match &call_defs[..] {
[(i, call_def)] => (*i, call_def.clone()), // = 1
[] => return missing_call(item_fn),
_ => {
_ =>
return Err(Error::new(
call_defs[1].1.attr_span(),
"Only one #[extrinsic_call] or #[block] attribute is allowed per benchmark.",
))
},
)),
})
}

Expand All @@ -303,9 +302,7 @@ impl BenchmarkDef {
let (verify_stmts, last_stmt) = match item_fn.sig.output {
ReturnType::Default =>
// no return type, last_stmt should be None
{
(Vec::from(&item_fn.block.stmts[(i + 1)..item_fn.block.stmts.len()]), None)
},
(Vec::from(&item_fn.block.stmts[(i + 1)..item_fn.block.stmts.len()]), None),
ReturnType::Type(_, _) => {
// defined return type, last_stmt should be Result<(), BenchmarkError>
// compatible and should not be included in verify_stmts
Expand All @@ -317,7 +314,7 @@ impl BenchmarkDef {
defined a return type. You should return something compatible \
with Result<(), BenchmarkError> (i.e. `Ok(())`) as the last statement \
or change your signature to a blank return type.",
));
))
}
let Some(stmt) = item_fn.block.stmts.last() else { return missing_call(item_fn) };
(
Expand Down Expand Up @@ -868,9 +865,8 @@ fn expand_benchmark(
},
)
},
BenchmarkCallDef::Block { block, attr_span: _ } => {
(quote!(), quote!(#block), quote!(#block))
},
BenchmarkCallDef::Block { block, attr_span: _ } =>
(quote!(), quote!(#block), quote!(#block)),
};

let vis = benchmark_def.fn_vis;
Expand Down

0 comments on commit 5312b58

Please sign in to comment.