diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index c6577b3920d..d3c0c124e97 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -43,13 +43,18 @@ jobs: - run: cargo test --release env: RUST_BACKTRACE: 1 + RUSTFLAGS: "-D dead-code -D nonstandard-style -D unused-imports -D unused-mut -D unused-variables -D unused-unsafe -D unreachable-patterns -D bad-style -D improper-ctypes -D unused-allocation -D unused-comparisons -D while-true -D unconditional-recursion -D bare-trait-objects -D mutable-borrow-reservation-conflict" # TODO: add `-D missing-docs` - name: Build and Test C API run: | make capi make test-capi-cranelift + env: + RUST_BACKTRACE: 1 + RUSTFLAGS: "-D dead-code -D nonstandard-style -D unused-imports -D unused-mut -D unused-variables -D unused-unsafe -D unreachable-patterns -D bad-style -D improper-ctypes -D unused-allocation -D unused-comparisons -D while-true -D unconditional-recursion -D bare-trait-objects -D mutable-borrow-reservation-conflict" # TODO: add `-D missing-docs` if: matrix.os != 'windows-latest' - name: Build C API on Windows run: make capi if: matrix.os == 'windows-latest' env: RUST_BACKTRACE: 1 + RUSTFLAGS: "-D dead-code -D nonstandard-style -D unused-imports -D unused-mut -D unused-variables -D unused-unsafe -D unreachable-patterns -D bad-style -D improper-ctypes -D unused-allocation -D unused-comparisons -D while-true -D unconditional-recursion -D bare-trait-objects -D mutable-borrow-reservation-conflict" # TODO: add `-D missing-docs` diff --git a/Cargo.lock b/Cargo.lock index 1d3277a2e82..729ce6cdf07 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -569,7 +569,7 @@ dependencies = [ [[package]] name = "inkwell" version = "0.1.0" -source = "git+https://github.com/theDan64/inkwell?rev=af1846fd8aea530cef9a59170715e5c6c64346f6#af1846fd8aea530cef9a59170715e5c6c64346f6" +source = "git+https://github.com/theDan64/inkwell?rev=1bfecc0a095d7ffdfa20a64630864f0297349508#1bfecc0a095d7ffdfa20a64630864f0297349508" dependencies = [ "either", "inkwell_internals", @@ -583,7 +583,7 @@ dependencies = [ [[package]] name = "inkwell_internals" version = "0.1.0" -source = "git+https://github.com/theDan64/inkwell?rev=af1846fd8aea530cef9a59170715e5c6c64346f6#af1846fd8aea530cef9a59170715e5c6c64346f6" +source = "git+https://github.com/theDan64/inkwell?rev=1bfecc0a095d7ffdfa20a64630864f0297349508#1bfecc0a095d7ffdfa20a64630864f0297349508" dependencies = [ "proc-macro2", "quote", diff --git a/build.rs b/build.rs index e05c1729971..deb61c76e77 100644 --- a/build.rs +++ b/build.rs @@ -13,10 +13,6 @@ use test_generator::{ with_features, with_test_module, Testsuite, }; -fn is_truthy_env(name: &str) -> bool { - env::var(name).map(|n| n == "1").unwrap_or_default() -} - fn main() -> anyhow::Result<()> { println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rerun-if-changed=tests/ignores.txt"); diff --git a/lib/api/src/externals.rs b/lib/api/src/externals.rs index a793a15dd20..48fbefb11ad 100644 --- a/lib/api/src/externals.rs +++ b/lib/api/src/externals.rs @@ -7,8 +7,7 @@ use crate::RuntimeError; use crate::{ExternType, FunctionType, GlobalType, MemoryType, TableType, ValType}; use std::cmp::max; use std::slice; -use wasm_common::{Bytes, HostFunction, Pages, ValueType, WasmTypeList, WithEnv, WithoutEnv}; -use wasmer_engine::Engine as _; +use wasm_common::{HostFunction, Pages, ValueType, WasmTypeList, WithEnv, WithoutEnv}; use wasmer_runtime::{ wasmer_call_trampoline, Export, ExportFunction, ExportGlobal, ExportMemory, ExportTable, LinearMemory, MemoryError, Table as RuntimeTable, VMCallerCheckedAnyfunc, VMContext, diff --git a/lib/api/src/module.rs b/lib/api/src/module.rs index 22bba2378b6..9eb0d35b874 100644 --- a/lib/api/src/module.rs +++ b/lib/api/src/module.rs @@ -7,7 +7,7 @@ use std::path::Path; use std::sync::Arc; use thiserror::Error; use wasmer_compiler::{CompileError, WasmError}; -use wasmer_engine::{CompiledModule, DeserializeError, Engine, Resolver, SerializeError}; +use wasmer_engine::{CompiledModule, DeserializeError, Resolver, SerializeError}; use wasmer_runtime::{ExportsIterator, ImportsIterator, InstanceHandle, Module as ModuleInfo}; #[derive(Error, Debug)] @@ -74,6 +74,7 @@ impl Module { /// let bytes: Vec = vec![]; /// let module = Module::new(&store, bytes)?; /// ``` + #[allow(unreachable_code)] pub fn new(store: &Store, bytes: impl AsRef<[u8]>) -> Result { #[cfg(feature = "wat")] { @@ -206,7 +207,7 @@ impl Module { Ok(Self::from_compiled_module(store, compiled)) } - fn from_compiled_module(store: &Store, compiled: Arc) -> Self { + fn from_compiled_module(store: &Store, compiled: Arc) -> Self { Module { store: store.clone(), compiled, diff --git a/lib/api/src/store.rs b/lib/api/src/store.rs index e4eb6af87dc..088ba2a1680 100644 --- a/lib/api/src/store.rs +++ b/lib/api/src/store.rs @@ -1,7 +1,9 @@ +#[cfg(all(feature = "compiler", feature = "engine"))] use crate::tunables::Tunables; -use std::sync::Arc; -#[cfg(feature = "compiler")] +#[cfg(all(feature = "compiler", feature = "engine"))] use wasmer_compiler::CompilerConfig; + +use std::sync::Arc; use wasmer_engine::Engine; #[derive(Clone)] diff --git a/lib/compiler-cranelift/build.rs b/lib/compiler-cranelift/build.rs index 1db75f1c11d..5e03bc2e028 100644 --- a/lib/compiler-cranelift/build.rs +++ b/lib/compiler-cranelift/build.rs @@ -1,3 +1,8 @@ +//! Wasmer Cranelift compiler build script. +//! +//! Sets the git revsion? for $PURPOSE +//! TODO(syrus): explain what's happening here + use std::process::Command; use std::str; diff --git a/lib/compiler-cranelift/src/compiler.rs b/lib/compiler-cranelift/src/compiler.rs index 28f8b1acf97..c4b67edd39f 100644 --- a/lib/compiler-cranelift/src/compiler.rs +++ b/lib/compiler-cranelift/src/compiler.rs @@ -6,26 +6,22 @@ use crate::func_environ::{get_func_name, FuncEnvironment}; use crate::sink::{RelocSink, TrapSink}; use crate::trampoline::{make_wasm_trampoline, FunctionBuilderContext}; use crate::translator::{ - compiled_function_unwind_info, irlibcall_to_libcall, irreloc_to_relocationkind, - signature_to_cranelift_ir, transform_jump_table, FuncTranslator, + compiled_function_unwind_info, signature_to_cranelift_ir, transform_jump_table, FuncTranslator, }; -use cranelift_codegen::ir::{self, ExternalName}; +use cranelift_codegen::ir; use cranelift_codegen::print_errors::pretty_error; use cranelift_codegen::{binemit, isa, Context}; use rayon::prelude::{IntoParallelRefIterator, ParallelIterator}; -use wasm_common::entity::{EntityRef, PrimaryMap}; +use wasm_common::entity::PrimaryMap; use wasm_common::{ - Features, FunctionIndex, FunctionType, LocalFunctionIndex, MemoryIndex, SignatureIndex, - TableIndex, + Features, FunctionType, LocalFunctionIndex, MemoryIndex, SignatureIndex, TableIndex, }; use wasmer_compiler::CompileError; use wasmer_compiler::{ Compilation, CompiledFunction, CompiledFunctionFrameInfo, Compiler, FunctionBody, - FunctionBodyData, SourceLoc, TrapInformation, + FunctionBodyData, }; use wasmer_compiler::{CompilerConfig, ModuleTranslationState, Target}; -use wasmer_compiler::{Relocation, RelocationTarget}; -use wasmer_runtime::TrapCode; use wasmer_runtime::{MemoryPlan, Module, TablePlan}; /// A compiler that compiles a WebAssembly module with Cranelift, translating the Wasm to Cranelift IR, diff --git a/lib/compiler-cranelift/src/sink.rs b/lib/compiler-cranelift/src/sink.rs index f0ba13412d5..9316851f173 100644 --- a/lib/compiler-cranelift/src/sink.rs +++ b/lib/compiler-cranelift/src/sink.rs @@ -1,9 +1,6 @@ //! Support for compiling with Cranelift. -use crate::translator::{ - irlibcall_to_libcall, irreloc_to_relocationkind, signature_to_cranelift_ir, - transform_jump_table, FuncTranslator, -}; +use crate::translator::{irlibcall_to_libcall, irreloc_to_relocationkind}; use cranelift_codegen::binemit; use cranelift_codegen::ir::{self, ExternalName}; use wasm_common::entity::EntityRef; @@ -136,7 +133,7 @@ fn translate_ir_trapcode(trap: ir::TrapCode) -> TrapCode { ir::TrapCode::BadConversionToInteger => TrapCode::BadConversionToInteger, ir::TrapCode::UnreachableCodeReached => TrapCode::UnreachableCodeReached, ir::TrapCode::Interrupt => TrapCode::Interrupt, - ir::TrapCode::User(user_code) => unimplemented!("User trap code not supported"), + ir::TrapCode::User(_user_code) => unimplemented!("User trap code not supported"), // ir::TrapCode::User(user_code) => TrapCode::User(user_code), } } diff --git a/lib/compiler-cranelift/src/trampoline/wasm.rs b/lib/compiler-cranelift/src/trampoline/wasm.rs index 3f4368ab0d2..36f95d4cda4 100644 --- a/lib/compiler-cranelift/src/trampoline/wasm.rs +++ b/lib/compiler-cranelift/src/trampoline/wasm.rs @@ -7,7 +7,7 @@ //! ``` use super::binemit::TrampolineRelocSink; use crate::translator::{ - compiled_function_unwind_info, signature_to_cranelift_ir, transform_jump_table, + compiled_function_unwind_info, signature_to_cranelift_ir, /*transform_jump_table, */ }; use cranelift_codegen::ir::InstBuilder; use cranelift_codegen::isa::TargetIsa; @@ -16,7 +16,7 @@ use cranelift_codegen::Context; use cranelift_codegen::{binemit, ir}; use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext}; use wasm_common::FunctionType; -use wasmer_compiler::{CompileError, CompiledFunction, CompiledFunctionFrameInfo, FunctionBody}; +use wasmer_compiler::{CompileError, FunctionBody}; /// Create a trampoline for invoking a WebAssembly function. pub fn make_wasm_trampoline( diff --git a/lib/compiler-cranelift/src/translator/func_environ.rs b/lib/compiler-cranelift/src/translator/func_environ.rs index 58dd59433a8..dc82a13fef7 100644 --- a/lib/compiler-cranelift/src/translator/func_environ.rs +++ b/lib/compiler-cranelift/src/translator/func_environ.rs @@ -16,6 +16,7 @@ use wasmer_compiler::WasmResult; /// The value of a WebAssembly global variable. #[derive(Clone, Copy)] pub enum GlobalVariable { + #[allow(dead_code)] /// This is a constant global with a value known at compile time. Const(ir::Value), @@ -29,10 +30,12 @@ pub enum GlobalVariable { ty: ir::Type, }, + #[allow(dead_code)] /// This is a global variable that needs to be handled by the environment. Custom, } +#[allow(dead_code)] /// How to return from functions. #[derive(Copy, Clone, PartialEq, Eq, Debug)] pub enum ReturnMode { diff --git a/lib/compiler-cranelift/src/translator/func_state.rs b/lib/compiler-cranelift/src/translator/func_state.rs index 2f17bac3024..aeca8afb690 100644 --- a/lib/compiler-cranelift/src/translator/func_state.rs +++ b/lib/compiler-cranelift/src/translator/func_state.rs @@ -216,8 +216,11 @@ pub struct FuncTranslationState { functions: HashMap, } +// TODO: review this comment it seems to be not true, `FuncTranslationState` is _not_ exposed +// publicly from this crate. // Public methods that are exposed to non-`wasmer_compiler` API consumers. impl FuncTranslationState { + #[allow(dead_code)] /// True if the current translation state expresses reachable code, false if it is unreachable. #[inline] pub fn reachable(&self) -> bool { diff --git a/lib/compiler/src/relocation.rs b/lib/compiler/src/relocation.rs index 7ec09e06c95..eb15a36ecee 100644 --- a/lib/compiler/src/relocation.rs +++ b/lib/compiler/src/relocation.rs @@ -15,7 +15,7 @@ use crate::{Addend, CodeOffset, JumpTable}; use serde::{Deserialize, Serialize}; use std::fmt; use wasm_common::entity::PrimaryMap; -use wasm_common::{FunctionIndex, LocalFunctionIndex}; +use wasm_common::LocalFunctionIndex; use wasmer_runtime::libcalls::LibCall; /// Relocation kinds for every ISA. @@ -106,15 +106,15 @@ impl Relocation { /// The function returns the relocation address and the delta. pub fn for_address(&self, start: usize, target_func_address: u64) -> (usize, u64) { match self.kind { - RelocationKind::Abs8 => unsafe { + RelocationKind::Abs8 => { let reloc_address = start + self.offset as usize; let reloc_addend = self.addend as isize; let reloc_abs = (target_func_address) .checked_add(reloc_addend as u64) .unwrap(); (reloc_address, reloc_abs) - }, - RelocationKind::X86PCRel4 => unsafe { + } + RelocationKind::X86PCRel4 => { let reloc_address = start + self.offset as usize; let reloc_addend = self.addend as isize; let reloc_delta_u32 = (target_func_address as u32) @@ -122,7 +122,7 @@ impl Relocation { .checked_add(reloc_addend as u32) .unwrap(); (reloc_address, reloc_delta_u32 as u64) - }, + } RelocationKind::X86CallPCRel4 => { let reloc_address = start + self.offset as usize; let reloc_addend = self.addend as isize; diff --git a/lib/compiler/src/target.rs b/lib/compiler/src/target.rs index 19c046b735c..28138834886 100644 --- a/lib/compiler/src/target.rs +++ b/lib/compiler/src/target.rs @@ -2,7 +2,6 @@ use enumset::{EnumSet, EnumSetType}; pub use target_lexicon::{Architecture, CallingConvention, OperatingSystem, Triple}; -use crate::std::boxed::Box; #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] use raw_cpuid::CpuId; diff --git a/lib/compiler/src/translator/error.rs b/lib/compiler/src/translator/error.rs index d114adea7a9..c2191d0a839 100644 --- a/lib/compiler/src/translator/error.rs +++ b/lib/compiler/src/translator/error.rs @@ -1,5 +1,4 @@ use crate::WasmError; -use thiserror::Error; use wasmparser::BinaryReaderError; /// Return an `Err(WasmError::Unsupported(msg))` where `msg` the string built by calling `format!` diff --git a/lib/engine-jit/src/engine.rs b/lib/engine-jit/src/engine.rs index 10d55b84680..572031841e3 100644 --- a/lib/engine-jit/src/engine.rs +++ b/lib/engine-jit/src/engine.rs @@ -4,8 +4,8 @@ use crate::{CodeMemory, CompiledModule}; use std::collections::HashMap; use std::sync::{Arc, Mutex}; use wasm_common::entity::PrimaryMap; -use wasm_common::{FunctionType, LocalFunctionIndex, MemoryIndex, SignatureIndex, TableIndex}; -use wasmer_compiler::{Compilation, CompileError, FunctionBody, Target}; +use wasm_common::{FunctionType, LocalFunctionIndex, SignatureIndex}; +use wasmer_compiler::{CompileError, FunctionBody}; #[cfg(feature = "compiler")] use wasmer_compiler::{Compiler, CompilerConfig}; use wasmer_engine::{ @@ -13,8 +13,7 @@ use wasmer_engine::{ SerializeError, Tunables, }; use wasmer_runtime::{ - InstanceHandle, MemoryPlan, Module, SignatureRegistry, TablePlan, VMFunctionBody, - VMSharedSignatureIndex, VMTrampoline, + InstanceHandle, Module, SignatureRegistry, VMFunctionBody, VMSharedSignatureIndex, VMTrampoline, }; /// A WebAssembly `JIT` Engine. @@ -129,7 +128,7 @@ impl Engine for JITEngine { resolver: &dyn Resolver, ) -> Result { let compiled_module = compiled_module.downcast_ref::().unwrap(); - unsafe { compiled_module.instantiate(&self, resolver, Box::new(())) } + compiled_module.instantiate(&self, resolver, Box::new(())) } /// Finish the instantiation of a WebAssembly module @@ -139,7 +138,7 @@ impl Engine for JITEngine { handle: &InstanceHandle, ) -> Result<(), InstantiationError> { let compiled_module = compiled_module.downcast_ref::().unwrap(); - unsafe { compiled_module.finish_instantiation(&handle) } + compiled_module.finish_instantiation(&handle) } /// Serializes a WebAssembly module diff --git a/lib/engine-jit/src/link.rs b/lib/engine-jit/src/link.rs index 714d013c8cb..3df43a92e7a 100644 --- a/lib/engine-jit/src/link.rs +++ b/lib/engine-jit/src/link.rs @@ -13,7 +13,7 @@ use wasmer_runtime::VMFunctionBody; /// Links a module, patching the allocated functions with the /// required relocations and jump tables. pub fn link_module( - module: &Module, + _module: &Module, allocated_functions: &PrimaryMap, jt_offsets: &PrimaryMap, relocations: Relocations, diff --git a/lib/engine-jit/src/module.rs b/lib/engine-jit/src/module.rs index fe0fc24b785..4a3257b43b9 100644 --- a/lib/engine-jit/src/module.rs +++ b/lib/engine-jit/src/module.rs @@ -4,25 +4,23 @@ use crate::engine::{JITEngine, JITEngineInner}; use crate::link::link_module; use crate::serialize::{SerializableCompilation, SerializableModule}; -use serde::{Deserialize, Serialize}; use std::any::Any; use std::sync::{Arc, Mutex}; -use wasm_common::entity::{BoxedSlice, EntityRef, PrimaryMap}; +use wasm_common::entity::{BoxedSlice, PrimaryMap}; use wasm_common::{ - DataInitializer, LocalFunctionIndex, LocalGlobalIndex, LocalMemoryIndex, LocalTableIndex, - MemoryIndex, OwnedDataInitializer, SignatureIndex, TableIndex, + DataInitializer, LocalFunctionIndex, MemoryIndex, OwnedDataInitializer, SignatureIndex, + TableIndex, }; use wasmer_compiler::CompileError; #[cfg(feature = "compiler")] use wasmer_compiler::ModuleEnvironment; use wasmer_engine::{ register_frame_info, resolve_imports, CompiledModule as BaseCompiledModule, DeserializeError, - Engine, GlobalFrameInfoRegistration, InstantiationError, LinkError, Resolver, RuntimeError, - SerializableFunctionFrameInfo, SerializeError, Tunables, + Engine, GlobalFrameInfoRegistration, InstantiationError, Resolver, RuntimeError, + SerializableFunctionFrameInfo, SerializeError, }; use wasmer_runtime::{ - InstanceHandle, LinearMemory, Module, SignatureRegistry, Table, VMFunctionBody, - VMGlobalDefinition, VMSharedSignatureIndex, + InstanceHandle, Module, SignatureRegistry, VMFunctionBody, VMSharedSignatureIndex, }; use wasmer_runtime::{MemoryPlan, TablePlan}; diff --git a/lib/engine/src/engine.rs b/lib/engine/src/engine.rs index 86cf6f15a68..53b15eb73dc 100644 --- a/lib/engine/src/engine.rs +++ b/lib/engine/src/engine.rs @@ -15,7 +15,7 @@ use wasmer_runtime::{InstanceHandle, VMSharedSignatureIndex, VMTrampoline}; /// such as: JIT or Native. pub trait Engine { /// Get the tunables - fn tunables(&self) -> &Tunables; + fn tunables(&self) -> &dyn Tunables; /// Register a signature fn register_signature(&self, func_type: &FunctionType) -> VMSharedSignatureIndex; @@ -30,7 +30,7 @@ pub trait Engine { fn validate(&self, binary: &[u8]) -> Result<(), CompileError>; /// Compile a WebAssembly binary - fn compile(&self, binary: &[u8]) -> Result, CompileError>; + fn compile(&self, binary: &[u8]) -> Result, CompileError>; /// Instantiates a WebAssembly module unsafe fn instantiate( @@ -50,13 +50,13 @@ pub trait Engine { fn serialize(&self, compiled_module: &dyn CompiledModule) -> Result, SerializeError>; /// Deserializes a WebAssembly module - fn deserialize(&self, bytes: &[u8]) -> Result, DeserializeError>; + fn deserialize(&self, bytes: &[u8]) -> Result, DeserializeError>; /// Deserializes a WebAssembly module from a path fn deserialize_from_file( &self, file_ref: &Path, - ) -> Result, DeserializeError> { + ) -> Result, DeserializeError> { // TODO: Return an IoDeserializeError, so we don't need to map the error let bytes = std::fs::read(file_ref).map_err(|e| DeserializeError::Generic(format!("{}", e)))?; diff --git a/lib/engine/src/module.rs b/lib/engine/src/module.rs index a15a6953679..29ee02041bd 100644 --- a/lib/engine/src/module.rs +++ b/lib/engine/src/module.rs @@ -1,6 +1,3 @@ -use crate::error::InstantiationError; -use std::sync::Arc; -use wasmer_runtime::InstanceHandle; use wasmer_runtime::Module; use downcast_rs::{impl_downcast, Downcast}; diff --git a/lib/engine/src/trap/frame_info.rs b/lib/engine/src/trap/frame_info.rs index 5678b9c327e..e0f1e7b118c 100644 --- a/lib/engine/src/trap/frame_info.rs +++ b/lib/engine/src/trap/frame_info.rs @@ -66,7 +66,7 @@ impl ModuleFrameInfo { } fn process_function_debug_info(&mut self, local_index: LocalFunctionIndex) { - let mut func = self.frame_infos.get_mut(local_index).unwrap(); + let func = self.frame_infos.get_mut(local_index).unwrap(); let processed: CompiledFunctionFrameInfo = match func { SerializableFunctionFrameInfo::Processed(_) => { // This should be a no-op on processed info @@ -187,7 +187,8 @@ impl GlobalFrameInfo { pub fn maybe_process_frame(&mut self, pc: usize) -> Option<()> { let module = self.module_info_mut(pc)?; let func = module.function_info(pc)?; - module.process_function_debug_info(func.local_index); + let func_local_index = func.local_index; + module.process_function_debug_info(func_local_index); Some(()) } diff --git a/lib/engine/src/tunables.rs b/lib/engine/src/tunables.rs index 21c8bb64618..78ef182e00e 100644 --- a/lib/engine/src/tunables.rs +++ b/lib/engine/src/tunables.rs @@ -1,8 +1,8 @@ use crate::error::LinkError; use wasm_common::entity::{EntityRef, PrimaryMap}; use wasm_common::{ - GlobalIndex, LocalGlobalIndex, LocalMemoryIndex, LocalTableIndex, MemoryIndex, MemoryType, - TableIndex, TableType, + LocalGlobalIndex, LocalMemoryIndex, LocalTableIndex, MemoryIndex, MemoryType, TableIndex, + TableType, }; use wasmer_runtime::MemoryError; use wasmer_runtime::{LinearMemory, Module, Table, VMGlobalDefinition}; diff --git a/lib/runtime/build.rs b/lib/runtime/build.rs index bd8ebe10f8e..206d9927638 100644 --- a/lib/runtime/build.rs +++ b/lib/runtime/build.rs @@ -1,3 +1,5 @@ +//! Runtime build script compiles C code using setjmp for trap handling. + fn main() { println!("cargo:rerun-if-changed=src/trap/helpers.c"); cc::Build::new() diff --git a/lib/runtime/src/imports.rs b/lib/runtime/src/imports.rs index 7fb510346bd..d311d863bc7 100644 --- a/lib/runtime/src/imports.rs +++ b/lib/runtime/src/imports.rs @@ -1,5 +1,4 @@ use crate::vmcontext::{VMFunctionImport, VMGlobalImport, VMMemoryImport, VMTableImport}; -use std::collections::HashSet; use wasm_common::entity::{BoxedSlice, PrimaryMap}; use wasm_common::{FunctionIndex, GlobalIndex, MemoryIndex, TableIndex}; diff --git a/lib/runtime/src/instance.rs b/lib/runtime/src/instance.rs index 888203766fa..25df0be69f7 100644 --- a/lib/runtime/src/instance.rs +++ b/lib/runtime/src/instance.rs @@ -18,7 +18,7 @@ use more_asserts::assert_lt; use std::alloc::{self, Layout}; use std::any::Any; use std::cell::{Cell, RefCell}; -use std::collections::{HashMap, HashSet}; +use std::collections::HashMap; use std::convert::TryFrom; use std::sync::Arc; use std::{mem, ptr, slice}; diff --git a/lib/wasi/src/state/mod.rs b/lib/wasi/src/state/mod.rs index 3ebbb3b7d29..f0a3e6871b7 100644 --- a/lib/wasi/src/state/mod.rs +++ b/lib/wasi/src/state/mod.rs @@ -19,7 +19,6 @@ mod types; pub use self::builder::*; pub use self::types::*; use crate::syscalls::types::*; -use crate::WasiEnv; use generational_arena::Arena; pub use generational_arena::Index as Inode; use serde::{Deserialize, Serialize}; @@ -52,15 +51,6 @@ const STDOUT_DEFAULT_RIGHTS: __wasi_rights_t = __WASI_RIGHT_FD_DATASYNC | __WASI_RIGHT_POLL_FD_READWRITE; const STDERR_DEFAULT_RIGHTS: __wasi_rights_t = STDOUT_DEFAULT_RIGHTS; -/// Get WasiState from a Ctx -/// -/// # Safety -/// - This function must be called on a `WasiEnv` that was created with `WasiState` -/// in the data field -pub unsafe fn get_wasi_state<'a>(env: &'a mut WasiEnv) -> &'a mut WasiState { - env.state_mut() -} - /// A completely aribtrary "big enough" number used as the upper limit for /// the number of symlinks that can be traversed when resolving a path pub const MAX_SYMLINKS: u32 = 128; diff --git a/lib/wasi/src/utils.rs b/lib/wasi/src/utils.rs index e9a4e4ad8ae..bba0a3a2745 100644 --- a/lib/wasi/src/utils.rs +++ b/lib/wasi/src/utils.rs @@ -1,4 +1,4 @@ -use wasmer::{ExternType, ImportType, Module}; +use wasmer::{ExternType, Module}; #[allow(dead_code)] /// Check if a provided module is compiled for some version of WASI. diff --git a/src/commands/self_update.rs b/src/commands/self_update.rs index a77d4a3d3ba..fdb2196779a 100644 --- a/src/commands/self_update.rs +++ b/src/commands/self_update.rs @@ -1,5 +1,5 @@ //! When wasmer self-update is executed, this is what gets executed -use anyhow::{bail, Context, Result}; +use anyhow::{Context, Result}; #[cfg(not(target_os = "windows"))] use std::process::{Command, Stdio}; use structopt::StructOpt; @@ -35,6 +35,6 @@ impl SelfUpdate { #[cfg(target_os = "windows")] fn inner_execute(&self) -> Result<()> { - bail!("Self update is not supported on Windows. Use install instructions on the Wasmer homepage: https://wasmer.io"); + anyhow::bail!("Self update is not supported on Windows. Use install instructions on the Wasmer homepage: https://wasmer.io"); } }