Clippy fixes (#692)
This commit is contained in:
@@ -167,7 +167,7 @@ impl Func {
|
||||
} else {
|
||||
panic!("expected function export")
|
||||
};
|
||||
let callable = WasmtimeFn::new(store, instance_handle, export.clone());
|
||||
let callable = WasmtimeFn::new(store, instance_handle, export);
|
||||
Func::from_wrapped(store, ty, Rc::new(callable))
|
||||
}
|
||||
}
|
||||
@@ -435,8 +435,10 @@ impl Memory {
|
||||
}
|
||||
}
|
||||
|
||||
// Marked unsafe due to posibility that wasmtime can resize internal memory
|
||||
// from other threads.
|
||||
/// Returns a mutable slice the current memory.
|
||||
/// # Safety
|
||||
/// Marked unsafe due to posibility that wasmtime can resize internal memory
|
||||
/// from other threads.
|
||||
pub unsafe fn data(&self) -> &mut [u8] {
|
||||
let definition = &*self.wasmtime_memory_definition();
|
||||
slice::from_raw_parts_mut(definition.base, definition.current_length)
|
||||
|
||||
@@ -15,7 +15,7 @@ fn into_memory_type(mt: wasmparser::MemoryType) -> MemoryType {
|
||||
MemoryType::new(Limits::new(mt.limits.initial, mt.limits.maximum))
|
||||
}
|
||||
|
||||
fn into_global_type(gt: &wasmparser::GlobalType) -> GlobalType {
|
||||
fn into_global_type(gt: wasmparser::GlobalType) -> GlobalType {
|
||||
let mutability = if gt.mutable {
|
||||
Mutability::Var
|
||||
} else {
|
||||
@@ -24,6 +24,8 @@ fn into_global_type(gt: &wasmparser::GlobalType) -> GlobalType {
|
||||
GlobalType::new(into_valtype(>.content_type), mutability)
|
||||
}
|
||||
|
||||
// `into_valtype` is used for `map` which requires `&T`.
|
||||
#[allow(clippy::trivially_copy_pass_by_ref)]
|
||||
fn into_valtype(ty: &wasmparser::Type) -> ValType {
|
||||
use wasmparser::Type::*;
|
||||
match ty {
|
||||
@@ -91,7 +93,7 @@ fn read_imports_and_exports(binary: &[u8]) -> Result<(Box<[ImportType]>, Box<[Ex
|
||||
let section = section.get_global_section_reader()?;
|
||||
globals.reserve_exact(section.get_count() as usize);
|
||||
for entry in section {
|
||||
globals.push(into_global_type(&entry?.ty));
|
||||
globals.push(into_global_type(entry?.ty));
|
||||
}
|
||||
}
|
||||
SectionCode::Table => {
|
||||
@@ -123,7 +125,7 @@ fn read_imports_and_exports(binary: &[u8]) -> Result<(Box<[ImportType]>, Box<[Ex
|
||||
ExternType::Memory(memory)
|
||||
}
|
||||
ImportSectionEntryType::Global(gt) => {
|
||||
let global = into_global_type(>);
|
||||
let global = into_global_type(gt);
|
||||
globals.push(global.clone());
|
||||
ExternType::Global(global)
|
||||
}
|
||||
|
||||
@@ -31,16 +31,14 @@ pub(crate) fn create_handle(
|
||||
|
||||
// Compute indices into the shared signature table.
|
||||
let signatures = signature_registry
|
||||
.and_then(|mut signature_registry| {
|
||||
Some(
|
||||
module
|
||||
.signatures
|
||||
.values()
|
||||
.map(|sig| signature_registry.register_wasmtime_signature(sig))
|
||||
.collect::<PrimaryMap<_, _>>(),
|
||||
)
|
||||
.map(|mut signature_registry| {
|
||||
module
|
||||
.signatures
|
||||
.values()
|
||||
.map(|sig| signature_registry.register_wasmtime_signature(sig))
|
||||
.collect::<PrimaryMap<_, _>>()
|
||||
})
|
||||
.unwrap_or_else(|| PrimaryMap::new());
|
||||
.unwrap_or_else(PrimaryMap::new);
|
||||
|
||||
Ok(InstanceHandle::new(
|
||||
Rc::new(module),
|
||||
|
||||
@@ -89,9 +89,9 @@ unsafe extern "C" fn stub_fn(vmctx: *mut VMContext, call_id: u32, values_vec: *m
|
||||
|
||||
match func.call(&args, &mut returns) {
|
||||
Ok(()) => {
|
||||
for i in 0..returns_len {
|
||||
for (i, r#return) in returns.iter_mut().enumerate() {
|
||||
// TODO check signature.returns[i].value_type ?
|
||||
returns[i].write_value_to(values_vec.add(i));
|
||||
r#return.write_value_to(values_vec.add(i));
|
||||
}
|
||||
0
|
||||
}
|
||||
@@ -172,7 +172,7 @@ fn make_trampoline(
|
||||
|
||||
let callee_args = vec![vmctx_ptr_val, call_id_val, values_vec_ptr_val];
|
||||
|
||||
let new_sig = builder.import_signature(stub_sig.clone());
|
||||
let new_sig = builder.import_signature(stub_sig);
|
||||
|
||||
let callee_value = builder
|
||||
.ins()
|
||||
|
||||
@@ -547,7 +547,7 @@ impl Callable for wasm_func_callback_t {
|
||||
let mut out_results = vec![wasm_val_t::default(); results.len()];
|
||||
let func = self.expect("wasm_func_callback_t fn");
|
||||
let out = unsafe { func(params.as_ptr(), out_results.as_mut_ptr()) };
|
||||
if out != ptr::null_mut() {
|
||||
if !out.is_null() {
|
||||
let trap: Box<wasm_trap_t> = unsafe { Box::from_raw(out) };
|
||||
return Err((*trap).into());
|
||||
}
|
||||
@@ -579,7 +579,7 @@ impl Callable for CallbackWithEnv {
|
||||
let mut out_results = vec![wasm_val_t::default(); results.len()];
|
||||
let func = self.callback.expect("wasm_func_callback_with_env_t fn");
|
||||
let out = unsafe { func(self.env, params.as_ptr(), out_results.as_mut_ptr()) };
|
||||
if out != ptr::null_mut() {
|
||||
if !out.is_null() {
|
||||
let trap: Box<wasm_trap_t> = unsafe { Box::from_raw(out) };
|
||||
return Err((*trap).into());
|
||||
}
|
||||
@@ -827,7 +827,7 @@ pub unsafe extern "C" fn wasm_func_new_with_env(
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn wasm_val_copy(out: *mut wasm_val_t, source: *const wasm_val_t) {
|
||||
*out = match into_valtype((*source).kind) {
|
||||
ValType::I32 | ValType::I64 | ValType::F32 | ValType::F64 => (*source).clone(),
|
||||
ValType::I32 | ValType::I64 | ValType::F32 | ValType::F64 => *source,
|
||||
_ => unimplemented!("wasm_val_copy arg"),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user