Unverified Commit 6e7941a7 authored by Michael Müller's avatar Michael Müller Committed by GitHub
Browse files

Fix nightly clippy errors (#948)

parent bd4b51e3
Pipeline #161323 failed with stages
in 9 minutes and 30 seconds
......@@ -423,13 +423,12 @@ impl Engine {
///
/// Panics if the slice is too large and does not fit.
fn set_output(output: &mut &mut [u8], slice: &[u8]) {
if slice.len() > output.len() {
panic!(
"the output buffer is too small! the decoded storage is of size {} bytes, \
but the output buffer has only room for {}.",
slice.len(),
output.len()
);
}
assert!(
slice.len() <= output.len(),
"the output buffer is too small! the decoded storage is of size {} bytes, \
but the output buffer has only room for {}.",
slice.len(),
output.len(),
);
output[..slice.len()].copy_from_slice(slice);
}
......@@ -148,9 +148,7 @@ where
///
/// If there has already been set a caller.
pub fn caller(mut self, caller: T::AccountId) -> Self {
if self.caller.is_some() {
panic!("already has a caller");
}
assert!(self.caller.is_none(), "already has a caller");
self.caller = Some(caller);
self
}
......@@ -161,9 +159,7 @@ where
///
/// If there has already been set a callee.
pub fn callee(mut self, callee: T::AccountId) -> Self {
if self.callee.is_some() {
panic!("already has a callee");
}
assert!(self.callee.is_none(), "already has a callee");
self.callee = Some(callee);
self
}
......@@ -174,9 +170,7 @@ where
///
/// If there has already been set provided gas.
pub fn gas(mut self, gas: u64) -> Self {
if self.gas.is_some() {
panic!("already has provided gas");
}
assert!(self.gas.is_none(), "already has provided gas");
self.gas = Some(gas);
self
}
......@@ -187,9 +181,10 @@ where
///
/// If there has already been set transferred value (endowment).
pub fn transferred_value(mut self, transferred_value: T::Balance) -> Self {
if self.transferred_value.is_some() {
panic!("already has set transferred value (endowment)");
}
assert!(
self.transferred_value.is_none(),
"already has set transferred value (endowment)"
);
self.transferred_value = Some(transferred_value);
self
}
......@@ -200,9 +195,7 @@ where
///
/// If there has already been set call data.
pub fn call_data(mut self, call_data: CallData) -> Self {
if self.call_data.is_some() {
panic!("already has set call data");
}
assert!(self.call_data.is_none(), "already has set call data");
self.call_data = Some(call_data);
self
}
......
......@@ -157,7 +157,7 @@ impl EnvBackend for EnvInstance {
{
self.exec_context()
.map(|exec_ctx| &exec_ctx.call_data)
.map(|call_data| scale::Encode::encode(call_data))
.map(scale::Encode::encode)
.map_err(Into::into)
.and_then(|encoded| {
<T as scale::Decode>::decode(&mut &encoded[..])
......@@ -210,12 +210,12 @@ impl EnvBackend for EnvInstance {
D: FnOnce(&[u8]) -> ::core::result::Result<T, E>,
{
let encoded_input = input.encode();
let (status_code, mut output) = self
let (status_code, output) = self
.chain_extension_handler
.eval(func_id, &encoded_input)
.expect("encountered unexpected missing chain extension method");
status_to_result(status_code)?;
let decoded = decode_to_result(&mut output)?;
let decoded = decode_to_result(output)?;
Ok(decoded)
}
}
......
......@@ -141,9 +141,7 @@ impl Metadata<'_> {
let selector_bytes = constructor.composed_selector().hex_lits();
let constructor = constructor.callable();
let ident = constructor.ident();
let args = constructor
.inputs()
.map(|arg| Self::generate_message_param(arg));
let args = constructor.inputs().map(Self::generate_message_param);
let constr = match trait_ident {
Some(trait_ident) => {
quote_spanned!(span => from_trait_and_name(
......@@ -236,9 +234,7 @@ impl Metadata<'_> {
let message = message.callable();
let mutates = message.receiver().is_ref_mut();
let ident = message.ident();
let args = message
.inputs()
.map(|arg| Self::generate_message_param(arg));
let args = message.inputs().map(Self::generate_message_param);
let ret_ty = Self::generate_return_type(message.output());
let constr = match trait_ident {
Some(trait_ident) => {
......
......@@ -588,7 +588,7 @@ pub fn sanitize_attributes<I, C>(
parent_span: Span,
attrs: I,
is_valid_first: &ir::AttributeArgKind,
mut is_conflicting_attr: C,
is_conflicting_attr: C,
) -> Result<(InkAttribute, Vec<syn::Attribute>), syn::Error>
where
I: IntoIterator<Item = syn::Attribute>,
......@@ -605,7 +605,7 @@ where
is_valid_first,
))
})?;
normalized.ensure_no_conflicts(|arg| is_conflicting_attr(arg))?;
normalized.ensure_no_conflicts(is_conflicting_attr)?;
Ok((normalized, other_attrs))
}
......
......@@ -118,7 +118,7 @@ impl<'a> IterMut<'a> {
/// Returns access for the given bit index with extended but valid lifetimes.
fn get<'b>(&'b mut self, index: u8) -> BitRefMut<'a> {
unsafe { BitRefMut::new(extend_lifetime(&mut self.bits), index) }
unsafe { BitRefMut::new(extend_lifetime(self.bits), index) }
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment