mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-30 00:17:56 +00:00
Apply some clippy lints (#11154)
* Apply some clippy hints * Revert clippy ci changes * Update client/cli/src/commands/generate.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/cli/src/commands/inspect_key.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/db/src/bench.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/db/src/bench.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/service/src/client/block_rules.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/service/src/client/block_rules.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/network/src/transactions.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/network/src/protocol.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Revert due to missing `or_default` function. * Fix compilation and simplify code * Undo change that corrupts benchmark. * fix clippy * Update client/service/test/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/state-db/src/noncanonical.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/state-db/src/noncanonical.rs remove leftovers! * Update client/tracing/src/logging/directives.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update utils/fork-tree/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * added needed ref * Update frame/referenda/src/benchmarking.rs * Simplify byte-vec creation * let's just not overlap the ranges * Correction * cargo fmt * Update utils/frame/benchmarking-cli/src/shared/stats.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update utils/frame/benchmarking-cli/src/pallet/command.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update utils/frame/benchmarking-cli/src/pallet/command.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Giles Cope <gilescope@gmail.com>
This commit is contained in:
committed by
GitHub
parent
a990473cf9
commit
b581604aa7
@@ -39,7 +39,7 @@ impl DataSegmentsSnapshot {
|
||||
.map(|mut segment| {
|
||||
// Just replace contents of the segment since the segments will be discarded later
|
||||
// anyway.
|
||||
let contents = mem::replace(segment.value_mut(), vec![]);
|
||||
let contents = mem::take(segment.value_mut());
|
||||
|
||||
let init_expr = match segment.offset() {
|
||||
Some(offset) => offset.code(),
|
||||
|
||||
@@ -187,9 +187,7 @@ impl RuntimeBlob {
|
||||
}
|
||||
|
||||
/// Returns an iterator of all globals which were exported by [`expose_mutable_globals`].
|
||||
pub(super) fn exported_internal_global_names<'module>(
|
||||
&'module self,
|
||||
) -> impl Iterator<Item = &'module str> {
|
||||
pub(super) fn exported_internal_global_names(&self) -> impl Iterator<Item = &str> {
|
||||
let exports = self.raw_module.export_section().map(|es| es.entries()).unwrap_or(&[]);
|
||||
exports.iter().filter_map(|export| match export.internal() {
|
||||
Internal::Global(_) if export.field().starts_with("exported_internal_global") =>
|
||||
|
||||
@@ -264,8 +264,8 @@ fn decode_environment_definition(
|
||||
let memory_ref = memories
|
||||
.get(memory_idx as usize)
|
||||
.cloned()
|
||||
.ok_or_else(|| InstantiationError::EnvironmentDefinitionCorrupted)?
|
||||
.ok_or_else(|| InstantiationError::EnvironmentDefinitionCorrupted)?;
|
||||
.ok_or(InstantiationError::EnvironmentDefinitionCorrupted)?
|
||||
.ok_or(InstantiationError::EnvironmentDefinitionCorrupted)?;
|
||||
memories_map.insert((module, field), memory_ref);
|
||||
},
|
||||
}
|
||||
@@ -458,7 +458,7 @@ impl<DT: Clone> Store<DT> {
|
||||
};
|
||||
|
||||
let mem_idx = memories.len();
|
||||
memories.push(Some(memory.clone()));
|
||||
memories.push(Some(memory));
|
||||
|
||||
Ok(mem_idx as u32)
|
||||
}
|
||||
@@ -472,7 +472,7 @@ impl<DT: Clone> Store<DT> {
|
||||
pub fn instance(&self, instance_idx: u32) -> Result<Rc<SandboxInstance>> {
|
||||
self.instances
|
||||
.get(instance_idx as usize)
|
||||
.ok_or_else(|| "Trying to access a non-existent instance")?
|
||||
.ok_or("Trying to access a non-existent instance")?
|
||||
.as_ref()
|
||||
.map(|v| v.0.clone())
|
||||
.ok_or_else(|| "Trying to access a torndown instance".into())
|
||||
@@ -488,7 +488,7 @@ impl<DT: Clone> Store<DT> {
|
||||
self.instances
|
||||
.get(instance_idx as usize)
|
||||
.as_ref()
|
||||
.ok_or_else(|| "Trying to access a non-existent instance")?
|
||||
.ok_or("Trying to access a non-existent instance")?
|
||||
.as_ref()
|
||||
.map(|v| v.1.clone())
|
||||
.ok_or_else(|| "Trying to access a torndown instance".into())
|
||||
@@ -504,7 +504,7 @@ impl<DT: Clone> Store<DT> {
|
||||
self.memories
|
||||
.get(memory_idx as usize)
|
||||
.cloned()
|
||||
.ok_or_else(|| "Trying to access a non-existent sandboxed memory")?
|
||||
.ok_or("Trying to access a non-existent sandboxed memory")?
|
||||
.ok_or_else(|| "Trying to access a torndown sandboxed memory".into())
|
||||
}
|
||||
|
||||
@@ -564,7 +564,7 @@ impl<DT: Clone> Store<DT> {
|
||||
|
||||
#[cfg(feature = "wasmer-sandbox")]
|
||||
BackendContext::Wasmer(ref context) =>
|
||||
wasmer_instantiate(&context, wasm, guest_env, state, sandbox_context)?,
|
||||
wasmer_instantiate(context, wasm, guest_env, state, sandbox_context)?,
|
||||
};
|
||||
|
||||
Ok(UnregisteredInstance { sandbox_instance })
|
||||
|
||||
@@ -113,7 +113,7 @@ pub fn instantiate(
|
||||
type Exports = HashMap<String, wasmer::Exports>;
|
||||
let mut exports_map = Exports::new();
|
||||
|
||||
for import in module.imports().into_iter() {
|
||||
for import in module.imports() {
|
||||
match import.ty() {
|
||||
// Nothing to do here
|
||||
wasmer::ExternType::Global(_) | wasmer::ExternType::Table(_) => (),
|
||||
@@ -121,7 +121,7 @@ pub fn instantiate(
|
||||
wasmer::ExternType::Memory(_) => {
|
||||
let exports = exports_map
|
||||
.entry(import.module().to_string())
|
||||
.or_insert(wasmer::Exports::new());
|
||||
.or_insert_with(wasmer::Exports::new);
|
||||
|
||||
let memory = guest_env
|
||||
.imports
|
||||
@@ -173,7 +173,7 @@ pub fn instantiate(
|
||||
|
||||
let exports = exports_map
|
||||
.entry(import.module().to_string())
|
||||
.or_insert(wasmer::Exports::new());
|
||||
.or_insert_with(wasmer::Exports::new);
|
||||
|
||||
exports.insert(import.name(), wasmer::Extern::Function(function));
|
||||
},
|
||||
|
||||
@@ -78,7 +78,7 @@ impl ImportResolver for Imports {
|
||||
// Here we use inner memory reference only to resolve the imports
|
||||
// without accessing the memory contents. All subsequent memory accesses
|
||||
// should happen through the wrapper, that enforces the memory access protocol.
|
||||
let mem = wrapper.0.clone();
|
||||
let mem = wrapper.0;
|
||||
|
||||
Ok(mem)
|
||||
}
|
||||
@@ -247,7 +247,7 @@ impl<'a> wasmi::Externals for GuestExternals<'a> {
|
||||
serialized_result_val_ptr,
|
||||
"Can't deallocate memory for dispatch thunk's result",
|
||||
)
|
||||
.and_then(|_| serialized_result_val)
|
||||
.and(serialized_result_val)
|
||||
.and_then(|serialized_result_val| {
|
||||
let result_val = std::result::Result::<ReturnValue, HostError>::decode(&mut serialized_result_val.as_slice())
|
||||
.map_err(|_| trap("Decoding Result<ReturnValue, HostError> failed!"))?;
|
||||
|
||||
Reference in New Issue
Block a user