Fix linting errors

This commit is contained in:
Syrus Akbary
2023-03-02 14:26:06 -08:00
parent 7440c428a7
commit 61ca01d341
13 changed files with 32 additions and 67 deletions

View File

@@ -249,12 +249,12 @@ impl AsJs for Extern {
impl AsJs for Instance {
type DefinitionType = crate::module::Module;
fn as_jsvalue(&self, store: &impl AsStoreRef) -> wasm_bindgen::JsValue {
fn as_jsvalue(&self, _store: &impl AsStoreRef) -> wasm_bindgen::JsValue {
self._inner._handle.clone().into()
}
fn from_jsvalue(
mut store: &mut impl AsStoreMut,
store: &mut impl AsStoreMut,
module: &Self::DefinitionType,
value: &JsValue,
) -> Result<Self, JsError> {

View File

@@ -1,12 +1,8 @@
#[cfg(feature = "core")]
use crate::alloc::borrow::Cow;
use crate::js::lib::std::string::String;
pub use crate::js::trap::RuntimeError;
#[cfg(feature = "std")]
use std::borrow::Cow;
#[cfg(feature = "std")]
use thiserror::Error;
use wasmer_types::{CompileError, ImportError};
use wasmer_types::ImportError;
/// The WebAssembly.LinkError object indicates an error during
/// module instantiation (besides traps from the start function).

View File

@@ -2,21 +2,20 @@ use std::any::Any;
use crate::js::vm::VMExternRef;
use crate::store::{AsStoreMut, AsStoreRef};
use wasmer_types::RawValue;
#[derive(Debug, Clone)]
#[repr(transparent)]
pub struct ExternRef;
impl ExternRef {
pub fn new<T>(store: &mut impl AsStoreMut, value: T) -> Self
pub fn new<T>(_store: &mut impl AsStoreMut, _value: T) -> Self
where
T: Any + Send + Sync + 'static + Sized,
{
unimplemented!("ExternRef is not yet supported in Javascript");
}
pub fn downcast<'a, T>(&self, store: &'a impl AsStoreRef) -> Option<&'a T>
pub fn downcast<'a, T>(&self, _store: &'a impl AsStoreRef) -> Option<&'a T>
where
T: Any + Send + Sync + 'static + Sized,
{
@@ -28,13 +27,13 @@ impl ExternRef {
}
pub(crate) unsafe fn from_vm_externref(
store: &mut impl AsStoreMut,
vm_externref: VMExternRef,
_store: &mut impl AsStoreMut,
_vm_externref: VMExternRef,
) -> Self {
unimplemented!("ExternRef is not yet supported in Javascript");
}
pub fn is_from_store(&self, store: &impl AsStoreRef) -> bool {
pub fn is_from_store(&self, _store: &impl AsStoreRef) -> bool {
true
}
}

View File

@@ -1,5 +1,4 @@
use crate::errors::RuntimeError;
use crate::exports::{ExportError, Exportable};
use crate::externals::function::{HostFunction, HostFunctionKind, WithEnv, WithoutEnv};
use crate::function_env::{FunctionEnv, FunctionEnvMut};
use crate::js::as_js::{param_from_js, AsJs}; /* ValFuncRef */
@@ -8,15 +7,12 @@ use crate::js::vm::{VMExtern, VMFuncRef, VMFunction, VMFunctionBody, VMFunctionE
use crate::native_type::{FromToNativeWasmType, IntoResult, NativeWasmTypeInto, WasmTypeList};
use crate::store::{AsStoreMut, AsStoreRef, StoreMut};
use crate::value::Value;
use crate::Extern;
use crate::TypedFunction;
use std::error::Error;
use std::fmt;
use std::iter::FromIterator;
use std::marker::PhantomData;
use std::panic::{self, AssertUnwindSafe};
use wasmer_types::{FunctionType, NativeWasmType, RawValue, Type};
use wasmer_types::{FunctionType, NativeWasmType, RawValue};
use js_sys::{Array, Function as JSFunction};
use wasm_bindgen::prelude::*;
@@ -198,8 +194,8 @@ impl Function {
pub fn call_raw(
&self,
store: &mut impl AsStoreMut,
params: Vec<RawValue>,
_store: &mut impl AsStoreMut,
_params: Vec<RawValue>,
) -> Result<Box<[Value]>, RuntimeError> {
// There is no optimal call_raw in JS, so we just
// simply rely the call
@@ -275,11 +271,14 @@ impl Function {
Self { handle: internal }
}
pub(crate) fn vm_funcref(&self, store: &impl AsStoreRef) -> VMFuncRef {
pub(crate) fn vm_funcref(&self, _store: &impl AsStoreRef) -> VMFuncRef {
unimplemented!();
}
pub(crate) unsafe fn from_vm_funcref(store: &mut impl AsStoreMut, funcref: VMFuncRef) -> Self {
pub(crate) unsafe fn from_vm_funcref(
_store: &mut impl AsStoreMut,
_funcref: VMFuncRef,
) -> Self {
unimplemented!();
}

View File

@@ -1,8 +1,6 @@
use crate::exports::{ExportError, Exportable};
use crate::js::vm::{VMExtern, VMMemory};
use crate::mem_access::MemoryAccessError;
use crate::store::{AsStoreMut, AsStoreRef, StoreObjects};
use crate::Extern;
use crate::MemoryType;
use std::marker::PhantomData;
use std::mem::MaybeUninit;
@@ -84,15 +82,6 @@ impl Memory {
Ok(js_memory)
}
pub fn new_raw(
store: &mut impl AsStoreMut,
js_memory: js_sys::WebAssembly::Memory,
ty: MemoryType,
) -> Result<Self, MemoryError> {
let vm_memory = VMMemory::new(js_memory, ty);
Ok(Self::from_vm_extern(store, vm_memory))
}
pub fn new_from_existing(new_store: &mut impl AsStoreMut, memory: VMMemory) -> Self {
Self::from_vm_extern(new_store, memory)
}
@@ -173,6 +162,7 @@ impl Memory {
true
}
#[allow(unused)]
pub fn duplicate(&mut self, _store: &impl AsStoreRef) -> Result<VMMemory, MemoryError> {
self.handle.duplicate()
}

View File

@@ -254,6 +254,7 @@ impl<'a> MemoryView<'a> {
}
/// Copies the memory and returns it as a vector of bytes
#[allow(unused)]
pub fn copy_to_vec(&self) -> Result<Vec<u8>, MemoryAccessError> {
let mut new_memory = Vec::new();
let mut offset = 0;

View File

@@ -3,7 +3,6 @@ use crate::store::{AsStoreMut, AsStoreRef};
use crate::value::Value;
use crate::vm::VMExternTable;
use crate::vm::{VMExtern, VMFunction, VMTable};
use crate::Extern;
use crate::{FunctionType, TableType};
use js_sys::Function;

View File

@@ -2,11 +2,10 @@ use crate::errors::InstantiationError;
use crate::exports::Exports;
use crate::imports::Imports;
use crate::js::as_js::AsJs;
use crate::js::vm::{VMExtern, VMInstance};
use crate::js::vm::VMInstance;
use crate::module::Module;
use crate::store::{AsStoreMut, AsStoreRef};
use crate::store::AsStoreMut;
use crate::Extern;
use crate::{LinkError, RuntimeError};
use js_sys::WebAssembly;
#[derive(Clone, PartialEq, Eq)]

View File

@@ -2,7 +2,6 @@ use crate::errors::InstantiationError;
use crate::errors::RuntimeError;
use crate::imports::Imports;
use crate::js::AsJs;
use crate::module::IoCompileError;
use crate::store::AsStoreMut;
use crate::vm::VMInstance;
use crate::Extern;
@@ -10,11 +9,7 @@ use crate::IntoBytes;
use crate::{AsEngineRef, ExportType, ImportType};
use bytes::Bytes;
use js_sys::{Reflect, Uint8Array, WebAssembly};
use std::fmt;
use std::io;
use std::path::Path;
#[cfg(feature = "std")]
use thiserror::Error;
#[cfg(feature = "tracing")]
use tracing::{debug, warn};
use wasm_bindgen::JsValue;
@@ -53,14 +48,6 @@ pub struct Module {
unsafe impl Send for Module {}
impl Module {
/// Creates a new WebAssembly module from a file path.
pub fn from_file(
_engine: &impl AsEngineRef,
_file: impl AsRef<Path>,
) -> Result<Self, IoCompileError> {
unimplemented!();
}
pub(crate) fn from_binary(
_engine: &impl AsEngineRef,
binary: &[u8],
@@ -234,10 +221,10 @@ impl Module {
pub unsafe fn deserialize(
_engine: &impl AsEngineRef,
bytes: impl IntoBytes,
_bytes: impl IntoBytes,
) -> Result<Self, DeserializeError> {
#[cfg(feature = "js-serializable-module")]
return Self::from_binary(_engine, &bytes.into_bytes())
return Self::from_binary(_engine, &_bytes.into_bytes())
.map_err(|e| DeserializeError::Compiler(e));
#[cfg(not(feature = "js-serializable-module"))]
@@ -330,6 +317,7 @@ impl Module {
///
/// Returns an error if the hints doesn't match the shape of
/// import or export types of the module.
#[allow(unused)]
pub fn set_type_hints(&mut self, type_hints: ModuleTypeHints) -> Result<(), String> {
let exports = WebAssembly::Module::exports(&self.module);
// Check exports
@@ -448,13 +436,13 @@ impl From<WebAssembly::Module> for Module {
impl<T: IntoBytes> From<(WebAssembly::Module, T)> for crate::module::Module {
fn from(module_and_binary: (WebAssembly::Module, T)) -> crate::module::Module {
let (module, binary) = module_and_binary;
let (module, _binary) = module_and_binary;
let module = Module {
module,
name: None,
type_hints: None,
#[cfg(feature = "js-serializable-module")]
raw_bytes: Some(binary.into_bytes()),
raw_bytes: Some(_binary.into_bytes()),
};
crate::module::Module(module.into())
}

View File

@@ -176,11 +176,13 @@ mod objects {
}
/// Returns the ID of the context associated with the handle.
#[allow(unused)]
pub fn store_id(&self) -> StoreId {
self.id
}
/// Overrides the store id with a new ID
#[allow(unused)]
pub fn set_store_id(&mut self, id: StoreId) {
self.id = id;
}

View File

@@ -7,12 +7,10 @@
//! let add_one = instance.exports.get_function("function_name")?;
//! let add_one_native: TypedFunction<i32, i32> = add_one.typed().unwrap();
//! ```
use std::marker::PhantomData;
use crate::native_type::NativeWasmTypeInto;
use crate::{AsStoreMut, AsStoreRef, TypedFunction};
use crate::Value;
use crate::{AsStoreMut, TypedFunction};
use crate::{FromToNativeWasmType, RuntimeError, WasmTypeList};
use crate::{Function, Value};
// use std::panic::{catch_unwind, AssertUnwindSafe};
use crate::js::as_js::{param_from_js, AsJs};
use js_sys::Array;

View File

@@ -5,8 +5,6 @@
/// once the type reflection is added to the WebAssembly JS API.
/// https://github.com/WebAssembly/js-types/
use crate::js::wasm_bindgen_polyfill::Global as JsGlobal;
use crate::store::{AsStoreMut, AsStoreRef};
use crate::MemoryView;
use js_sys::Function as JsFunction;
use js_sys::WebAssembly;
use js_sys::WebAssembly::{Memory as JsMemory, Table as JsTable};
@@ -18,7 +16,7 @@ use tracing::trace;
use wasm_bindgen::{JsCast, JsValue};
use wasmer_types::RawValue;
use wasmer_types::{
ExternType, FunctionType, GlobalType, MemoryError, MemoryType, Pages, TableType, WASM_PAGE_SIZE,
FunctionType, GlobalType, MemoryError, MemoryType, Pages, TableType, WASM_PAGE_SIZE,
};
/// Represents linear memory that is managed by the javascript runtime
@@ -239,7 +237,7 @@ impl VMExternRef {
///
/// # Safety
/// `raw` must be a valid `VMExternRef` instance.
pub unsafe fn from_raw(raw: RawValue) -> Option<Self> {
pub unsafe fn from_raw(_raw: RawValue) -> Option<Self> {
unimplemented!();
}
}
@@ -261,7 +259,7 @@ impl VMFuncRef {
///
/// # Safety
/// `raw.funcref` must be a valid pointer.
pub unsafe fn from_raw(raw: RawValue) -> Option<Self> {
pub unsafe fn from_raw(_raw: RawValue) -> Option<Self> {
unimplemented!();
}
}

View File

@@ -258,10 +258,6 @@ impl<'a> StoreMut<'a> {
a.inner.objects.id() == b.inner.objects.id()
}
pub(crate) fn engine_and_objects_mut(&mut self) -> (&Engine, &mut StoreObjects) {
(&self.inner.engine, &mut self.inner.objects)
}
pub(crate) fn as_raw(&self) -> *mut StoreInner {
self.inner as *const StoreInner as *mut StoreInner
}