diff --git a/lib/api/src/sys/store.rs b/lib/api/src/sys/store.rs index f97456eb420..542ef61f7e2 100644 --- a/lib/api/src/sys/store.rs +++ b/lib/api/src/sys/store.rs @@ -242,7 +242,7 @@ impl<'a> StoreRef<'a> { self.inner .trap_handler .as_ref() - .map(|handler| &*handler as *const _) + .map(|handler| handler as *const _) } } diff --git a/lib/cli/src/commands/compile.rs b/lib/cli/src/commands/compile.rs index 25eb347c5d0..a89fbbaf39d 100644 --- a/lib/cli/src/commands/compile.rs +++ b/lib/cli/src/commands/compile.rs @@ -72,7 +72,7 @@ impl Compile { println!("Target: {}", target.triple()); let module = Module::from_file(&store, &self.path)?; - let _ = module.serialize_to_file(&self.output)?; + module.serialize_to_file(&self.output)?; eprintln!( "✔ File compiled successfully to `{}`.", self.output.display(), diff --git a/lib/cli/src/commands/create_exe.rs b/lib/cli/src/commands/create_exe.rs index 21e90d9ec96..e2ada9eb064 100644 --- a/lib/cli/src/commands/create_exe.rs +++ b/lib/cli/src/commands/create_exe.rs @@ -14,6 +14,12 @@ use structopt::StructOpt; use wasmer::*; use wasmer_object::{emit_serialized, get_object_for_target}; +/// The `prefixer` returns the a String to prefix each of the +/// functions in the static object generated by the +/// so we can assure no collisions. +#[cfg(feature = "static-artifact-create")] +pub type PrefixerFn = Box String + Send>; + const WASMER_MAIN_C_SOURCE: &[u8] = include_bytes!("wasmer_create_exe_main.c"); #[cfg(feature = "static-artifact-create")] const WASMER_STATIC_MAIN_C_SOURCE: &[u8] = include_bytes!("wasmer_static_create_exe_main.c"); @@ -135,7 +141,7 @@ impl CreateExe { let features = engine_inner.features(); let tunables = store.tunables(); let data: Vec = fs::read(wasm_module_path)?; - let prefixer: Option String + Send>> = None; + let prefixer: Option = None; let (module_info, obj, metadata_length, symbol_registry) = Artifact::generate_object( compiler, &data, prefixer, &target, tunables, features, diff --git a/lib/cli/src/commands/create_obj.rs b/lib/cli/src/commands/create_obj.rs index 578c49718f3..9acff206182 100644 --- a/lib/cli/src/commands/create_obj.rs +++ b/lib/cli/src/commands/create_obj.rs @@ -2,7 +2,7 @@ //! Create a standalone native executable for a given Wasm file. use super::ObjectFormat; -use crate::store::CompilerOptions; +use crate::{commands::PrefixerFn, store::CompilerOptions}; use anyhow::{Context, Result}; use std::env; use std::fs; @@ -114,7 +114,7 @@ impl CreateObj { let features = engine_inner.features(); let tunables = store.tunables(); let data: Vec = fs::read(wasm_module_path)?; - let prefixer: Option String + Send>> = None; + let prefixer: Option = None; let (module_info, obj, metadata_length, symbol_registry) = Artifact::generate_object( compiler, &data, prefixer, &target, tunables, features, diff --git a/lib/compiler-singlepass/src/emitter_arm64.rs b/lib/compiler-singlepass/src/emitter_arm64.rs index cb8ecd7055e..18946e89351 100644 --- a/lib/compiler-singlepass/src/emitter_arm64.rs +++ b/lib/compiler-singlepass/src/emitter_arm64.rs @@ -663,7 +663,7 @@ impl EmitterARM64 for Assembler { addr: GPR, offset: i32, ) -> Result<(), CodegenError> { - assert!((offset >= -255) && (offset <= 255)); + assert!((-255..=255).contains(&offset)); match (sz, reg) { (Size::S64, Location::GPR(reg)) => { let reg = reg.into_index() as u32; @@ -702,7 +702,7 @@ impl EmitterARM64 for Assembler { addr: GPR, offset: i32, ) -> Result<(), CodegenError> { - assert!((offset >= -255) && (offset <= 255)); + assert!((-255..=255).contains(&offset)); match (sz, reg) { (Size::S64, Location::GPR(reg)) => { let reg = reg.into_index() as u32; diff --git a/lib/compiler/src/engine/artifact.rs b/lib/compiler/src/engine/artifact.rs index 2c55d1260b0..a741577b552 100644 --- a/lib/compiler/src/engine/artifact.rs +++ b/lib/compiler/src/engine/artifact.rs @@ -59,6 +59,9 @@ pub struct UniversalArtifact { finished_function_lengths: BoxedSlice, } +#[cfg(feature = "static-artifact-create")] +pub type PrefixerFn = Box String + Send>; + /// Stores functions etc as symbols and data meant to be stored in object files and /// executables. #[cfg(feature = "static-artifact-create")] @@ -541,7 +544,7 @@ impl Artifact { pub fn generate_object<'data>( compiler: &dyn Compiler, data: &[u8], - prefixer: Option String + Send>>, + prefixer: Option, target: &'data Target, tunables: &dyn Tunables, features: &Features, diff --git a/lib/compiler/src/translator/state.rs b/lib/compiler/src/translator/state.rs index cb839eeffd1..df1d2d57118 100644 --- a/lib/compiler/src/translator/state.rs +++ b/lib/compiler/src/translator/state.rs @@ -53,7 +53,7 @@ impl ModuleTranslationState { wasmparser::TypeOrFuncType::FuncType(ty_index) => { let sig_idx = SignatureIndex::from_u32(ty_index); let (ref params, ref results) = self.wasm_types[sig_idx]; - (&*params, &*results) + (params, results) } }) } diff --git a/lib/emscripten/src/lib.rs b/lib/emscripten/src/lib.rs index 01d74db7ded..fa3c65983f6 100644 --- a/lib/emscripten/src/lib.rs +++ b/lib/emscripten/src/lib.rs @@ -562,7 +562,7 @@ pub fn emscripten_call_main( .get::(function_name) .map_err(|e| RuntimeError::new(e.to_string()))?; let num_params = main_func.ty(&env).params().len(); - let _result = match num_params { + match num_params { 2 => { let mut new_args = vec![path]; new_args.extend(args); diff --git a/lib/emscripten/src/varargs.rs b/lib/emscripten/src/varargs.rs index 4d8b96485b0..e428f300f77 100644 --- a/lib/emscripten/src/varargs.rs +++ b/lib/emscripten/src/varargs.rs @@ -21,10 +21,7 @@ impl VarArgs { // pub fn getStr<'a>(&mut self, ctx: &mut Ctx) -> &'a CStr { pub fn get_str(&mut self, ctx: &FunctionEnvMut) -> *const c_char { let ptr_addr: u32 = self.get(ctx); - let ptr = - emscripten_memory_pointer!(ctx.data().memory_view(0, &ctx), ptr_addr) as *const c_char; - ptr - // unsafe { CStr::from_ptr(ptr) } + emscripten_memory_pointer!(ctx.data().memory_view(0, &ctx), ptr_addr) as *const c_char } } diff --git a/lib/middlewares/src/metering.rs b/lib/middlewares/src/metering.rs index eea3efb149d..f6024a59524 100644 --- a/lib/middlewares/src/metering.rs +++ b/lib/middlewares/src/metering.rs @@ -109,7 +109,7 @@ pub struct FunctionMetering u64 + Send + Sync> { /// # Example /// /// See the [`get_remaining_points`] function to get an example. -#[derive(Debug, PartialEq)] +#[derive(Debug, Eq, PartialEq)] pub enum MeteringPoints { /// The given number of metering points is left for the execution. /// If the value is 0, all points are consumed but the execution diff --git a/lib/vm/src/instance/mod.rs b/lib/vm/src/instance/mod.rs index 812a3166191..bf0be8a295b 100644 --- a/lib/vm/src/instance/mod.rs +++ b/lib/vm/src/instance/mod.rs @@ -773,7 +773,7 @@ impl Instance { /// /// This is more or less a public facade of the private `Instance`, /// providing useful higher-level API. -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, Eq, PartialEq)] pub struct InstanceHandle { /// The layout of `Instance` (which can vary). instance_layout: Layout, diff --git a/lib/vm/src/memory.rs b/lib/vm/src/memory.rs index 098dd8501b6..787d5f390b5 100644 --- a/lib/vm/src/memory.rs +++ b/lib/vm/src/memory.rs @@ -15,7 +15,7 @@ use thiserror::Error; use wasmer_types::{Bytes, MemoryStyle, MemoryType, Pages}; /// Error type describing things that can go wrong when operating on Wasm Memories. -#[derive(Error, Debug, Clone, PartialEq, Hash)] +#[derive(Error, Debug, Clone, Eq, PartialEq, Hash)] pub enum MemoryError { /// Low level error with mmap. #[error("Error when allocating memory: {0}")] diff --git a/lib/vm/src/sig_registry.rs b/lib/vm/src/sig_registry.rs index 121c808b846..08edf97e5bd 100644 --- a/lib/vm/src/sig_registry.rs +++ b/lib/vm/src/sig_registry.rs @@ -41,7 +41,8 @@ impl SignatureRegistry { pub fn register(&self, sig: &FunctionType) -> VMSharedSignatureIndex { let mut inner = self.inner.write().unwrap(); let len = inner.signature2index.len(); - match inner.signature2index.entry(sig.clone()) { + let entry = inner.signature2index.entry(sig.clone()); + match entry { hash_map::Entry::Occupied(entry) => *entry.get(), hash_map::Entry::Vacant(entry) => { // Keep `signature_hash` len under 2**32 -- VMSharedSignatureIndex::new(std::u32::MAX) diff --git a/lib/vm/src/vmcontext.rs b/lib/vm/src/vmcontext.rs index edc3bf4d40e..bb1cb6cc9fc 100644 --- a/lib/vm/src/vmcontext.rs +++ b/lib/vm/src/vmcontext.rs @@ -163,7 +163,7 @@ mod test_vmdynamicfunction_import_context { } /// A function kind is a calling convention into and out of wasm code. -#[derive(Debug, Copy, Clone, PartialEq)] +#[derive(Debug, Copy, Clone, Eq, PartialEq)] #[repr(C)] pub enum VMFunctionKind { /// A static function has the native signature: diff --git a/lib/wasi/src/lib.rs b/lib/wasi/src/lib.rs index 7fcf37dff39..4daeb25a47d 100644 --- a/lib/wasi/src/lib.rs +++ b/lib/wasi/src/lib.rs @@ -128,7 +128,8 @@ impl WasiThread { /// Waits for the thread to exit (false = timeout) pub fn join(&self, timeout: Duration) -> bool { let guard = self.join.lock().unwrap(); - match guard.recv_timeout(timeout) { + let timeout = guard.recv_timeout(timeout); + match timeout { Ok(_) => true, Err(mpsc::RecvTimeoutError::Disconnected) => true, Err(mpsc::RecvTimeoutError::Timeout) => false, diff --git a/lib/wasi/src/state/builder.rs b/lib/wasi/src/state/builder.rs index 3cacd30a24e..61e2451d807 100644 --- a/lib/wasi/src/state/builder.rs +++ b/lib/wasi/src/state/builder.rs @@ -101,6 +101,8 @@ fn validate_mapped_dir_alias(alias: &str) -> Result<(), WasiStateCreationError> Ok(()) } +pub type SetupFsFn = Box Result<(), String> + Send>; + // TODO add other WasiFS APIs here like swapping out stdout, for example (though we need to // return stdout somehow, it's unclear what that API should look like) impl WasiStateBuilder { @@ -318,10 +320,7 @@ impl WasiStateBuilder { /// Configure the WASI filesystem before running. // TODO: improve ergonomics on this function - pub fn setup_fs( - &mut self, - setup_fs_fn: Box Result<(), String> + Send>, - ) -> &mut Self { + pub fn setup_fs(&mut self, setup_fs_fn: SetupFsFn) -> &mut Self { self.setup_fs_fn = Some(setup_fs_fn); self diff --git a/lib/wasi/src/state/mod.rs b/lib/wasi/src/state/mod.rs index e81223d3c02..4b1a75a718d 100644 --- a/lib/wasi/src/state/mod.rs +++ b/lib/wasi/src/state/mod.rs @@ -654,7 +654,8 @@ impl WasiFs { for c in path.components() { let segment_name = c.as_os_str().to_string_lossy().to_string(); let guard = inodes.arena[cur_inode].read(); - match guard.deref() { + let deref = guard.deref(); + match deref { Kind::Dir { ref entries, .. } | Kind::Root { ref entries } => { if let Some(_entry) = entries.get(&segment_name) { // TODO: this should be fixed @@ -678,7 +679,8 @@ impl WasiFs { // reborrow to insert { let mut guard = inodes.arena[cur_inode].write(); - match guard.deref_mut() { + let deref_mut = guard.deref_mut(); + match deref_mut { Kind::Dir { ref mut entries, .. } @@ -725,7 +727,8 @@ impl WasiFs { let base_inode = self.get_fd_inode(base).map_err(fs_error_from_wasi_err)?; let guard = inodes.arena[base_inode].read(); - match guard.deref() { + let deref = guard.deref(); + match deref { Kind::Dir { ref entries, .. } | Kind::Root { ref entries } => { if let Some(_entry) = entries.get(&name) { // TODO: eventually change the logic here to allow overwrites @@ -745,7 +748,8 @@ impl WasiFs { { let mut guard = inodes.arena[base_inode].write(); - match guard.deref_mut() { + let deref_mut = guard.deref_mut(); + match deref_mut { Kind::Dir { ref mut entries, .. } @@ -790,7 +794,8 @@ impl WasiFs { _ => { let base_inode = self.get_fd_inode(fd).map_err(fs_error_from_wasi_err)?; let mut guard = inodes.arena[base_inode].write(); - match guard.deref_mut() { + let deref_mut = guard.deref_mut(); + match deref_mut { Kind::File { ref mut handle, .. } => { std::mem::swap(handle, &mut ret); } @@ -810,7 +815,8 @@ impl WasiFs { ) -> Result<__wasi_filesize_t, __wasi_errno_t> { let inode = self.get_fd_inode(fd)?; let mut guard = inodes.arena[inode].write(); - match guard.deref_mut() { + let deref_mut = guard.deref_mut(); + match deref_mut { Kind::File { handle, .. } => { if let Some(h) = handle { let new_size = h.size(); @@ -899,7 +905,8 @@ impl WasiFs { // loading inodes as necessary 'symlink_resolution: while symlink_count < MAX_SYMLINKS { let mut guard = inodes.arena[cur_inode].write(); - match guard.deref_mut() { + let deref_mut = guard.deref_mut(); + match deref_mut { Kind::Buffer { .. } => unimplemented!("state::get_inode_at_path for buffers"), Kind::Dir { ref mut entries, @@ -1165,10 +1172,12 @@ impl WasiFs { let mut res = BaseFdAndRelPath::None; // for each preopened directory let preopen_fds = self.preopen_fds.read().unwrap(); - for po_fd in preopen_fds.deref() { + let deref = preopen_fds.deref(); + for po_fd in deref { let po_inode = self.fd_map.read().unwrap()[po_fd].inode; let guard = inodes.arena[po_inode].read(); - let po_path = match guard.deref() { + let deref = guard.deref(); + let po_path = match deref { Kind::Dir { path, .. } => &**path, Kind::Root { .. } => Path::new("/"), _ => unreachable!("Preopened FD that's not a directory or the root"), @@ -1210,7 +1219,8 @@ impl WasiFs { while cur_inode != base_inode { counter += 1; let guard = inodes.arena[cur_inode].read(); - match guard.deref() { + let deref = guard.deref(); + match deref { Kind::Dir { parent, .. } => { if let Some(p) = parent { cur_inode = *p; @@ -1345,8 +1355,9 @@ impl WasiFs { debug!("fdstat: {:?}", fd); let guard = inodes.arena[fd.inode].read(); + let deref = guard.deref(); Ok(__wasi_fdstat_t { - fs_filetype: match guard.deref() { + fs_filetype: match deref { Kind::File { .. } => __WASI_FILETYPE_REGULAR_FILE, Kind::Dir { .. } => __WASI_FILETYPE_DIRECTORY, Kind::Symlink { .. } => __WASI_FILETYPE_SYMBOLIC_LINK, @@ -1408,7 +1419,8 @@ impl WasiFs { } let mut guard = inodes.arena[fd.inode].write(); - match guard.deref_mut() { + let deref_mut = guard.deref_mut(); + match deref_mut { Kind::File { handle: Some(file), .. } => file.flush().map_err(|_| __WASI_EIO)?, @@ -1643,7 +1655,8 @@ impl WasiFs { let base_po_inode = &self.fd_map.read().unwrap()[base_po_dir].inode; let base_po_inode_v = &inodes.arena[*base_po_inode]; let guard = base_po_inode_v.read(); - match guard.deref() { + let deref = guard.deref(); + match deref { Kind::Root { .. } => { self.fs_backing.symlink_metadata(path_to_symlink).map_err(fs_error_into_wasi_err)? } @@ -1685,7 +1698,8 @@ impl WasiFs { let is_preopened = inodeval.is_preopened; let mut guard = inodeval.write(); - match guard.deref_mut() { + let deref_mut = guard.deref_mut(); + match deref_mut { Kind::File { ref mut handle, .. } => { let mut empty_handle = None; std::mem::swap(handle, &mut empty_handle); @@ -1707,14 +1721,16 @@ impl WasiFs { if let Some(p) = *parent { drop(guard); let mut guard = inodes.arena[p].write(); - match guard.deref_mut() { + let deref_mut = guard.deref_mut(); + match deref_mut { Kind::Dir { entries, .. } | Kind::Root { entries } => { self.fd_map.write().unwrap().remove(&fd).unwrap(); if is_preopened { let mut idx = None; { let preopen_fds = self.preopen_fds.read().unwrap(); - for (i, po_fd) in preopen_fds.iter().enumerate() { + let preopen_fds_iter = preopen_fds.iter().enumerate(); + for (i, po_fd) in preopen_fds_iter { if *po_fd == fd { idx = Some(i); break; diff --git a/lib/wasi/src/state/types.rs b/lib/wasi/src/state/types.rs index f5828c8ee59..462a008f19f 100644 --- a/lib/wasi/src/state/types.rs +++ b/lib/wasi/src/state/types.rs @@ -392,7 +392,8 @@ impl Read for Pipe { fn read(&mut self, buf: &mut [u8]) -> io::Result { let mut buffer = self.buffer.lock().unwrap(); let amt = std::cmp::min(buf.len(), buffer.len()); - for (i, byte) in buffer.drain(..amt).enumerate() { + let buf_iter = buffer.drain(..amt).enumerate(); + for (i, byte) in buf_iter { buf[i] = byte; } Ok(amt) diff --git a/lib/wasi/src/syscalls/mod.rs b/lib/wasi/src/syscalls/mod.rs index 4925fb72eb4..871feb32a47 100644 --- a/lib/wasi/src/syscalls/mod.rs +++ b/lib/wasi/src/syscalls/mod.rs @@ -164,7 +164,8 @@ where let inode = &inodes.arena[inode_idx]; let mut guard = inode.read(); - match guard.deref() { + let deref = guard.deref(); + match deref { Kind::Socket { socket } => actor(socket)?, _ => { return Err(__WASI_ENOTSOCK); @@ -197,7 +198,8 @@ where let inode = &inodes.arena[inode_idx]; let mut guard = inode.write(); - match guard.deref_mut() { + let deref_mut = guard.deref_mut(); + match deref_mut { Kind::Socket { socket } => actor(socket)?, _ => { return Err(__WASI_ENOTSOCK); @@ -231,7 +233,8 @@ where let inode = &inodes.arena[inode_idx]; let mut guard = inode.write(); - match guard.deref_mut() { + let deref_mut = guard.deref_mut(); + match deref_mut { Kind::Socket { socket } => { let new_socket = actor(socket)?; @@ -520,7 +523,8 @@ pub fn fd_allocate( let new_size = wasi_try!(offset.checked_add(len).ok_or(__WASI_EINVAL)); { let mut guard = inodes.arena[inode].write(); - match guard.deref_mut() { + let deref_mut = guard.deref_mut(); + match deref_mut { Kind::File { handle, .. } => { if let Some(handle) = handle { wasi_try!(handle.set_len(new_size).map_err(fs_error_into_wasi_err)); @@ -729,7 +733,8 @@ pub fn fd_filestat_set_size( { let mut guard = inodes.arena[inode].write(); - match guard.deref_mut() { + let deref_mut = guard.deref_mut(); + match deref_mut { Kind::File { handle, .. } => { if let Some(handle) = handle { wasi_try!(handle.set_len(st_size).map_err(fs_error_into_wasi_err)); @@ -868,7 +873,8 @@ pub fn fd_pread( return Ok(__WASI_EACCES); } let mut guard = inodes.arena[inode].write(); - match guard.deref_mut() { + let deref_mut = guard.deref_mut(); + match deref_mut { Kind::File { handle, .. } => { if let Some(h) = handle { wasi_try_ok!( @@ -955,7 +961,8 @@ pub fn fd_prestat_dir_name( trace!("=> inode: {:?}", inode_val); let guard = inode_val.read(); - match guard.deref() { + let deref = guard.deref(); + match deref { Kind::Dir { .. } | Kind::Root { .. } => { // TODO: verify this: null termination, etc let path_len: u64 = path_len.into(); @@ -1050,7 +1057,8 @@ pub fn fd_pwrite( let inode = &inodes.arena[inode_idx]; let mut guard = inode.write(); - match guard.deref_mut() { + let deref_mut = guard.deref_mut(); + match deref_mut { Kind::File { handle, .. } => { if let Some(handle) = handle { wasi_try_ok!( @@ -1149,7 +1157,8 @@ pub fn fd_read( let bytes_read = { let mut guard = inode.write(); - match guard.deref_mut() { + let deref_mut = guard.deref_mut(); + match deref_mut { Kind::File { handle, .. } => { if let Some(handle) = handle { wasi_try_ok!( @@ -1286,7 +1295,8 @@ pub fn fd_readdir( let entries: Vec<(String, u8, u64)> = { let guard = inodes.arena[working_dir.inode].read(); - match guard.deref() { + let deref = guard.deref(); + match deref { Kind::Dir { path, entries, .. } => { debug!("Reading dir {:?}", path); // TODO: refactor this code @@ -1517,7 +1527,8 @@ pub fn fd_seek( use std::io::SeekFrom; let inode_idx = fd_entry.inode; let mut guard = inodes.arena[inode_idx].write(); - match guard.deref_mut() { + let deref_mut = guard.deref_mut(); + match deref_mut { Kind::File { ref mut handle, .. } => { if let Some(handle) = handle { let end = @@ -1587,7 +1598,8 @@ pub fn fd_sync(ctx: FunctionEnvMut<'_, WasiEnv>, fd: __wasi_fd_t) -> __wasi_errn // TODO: implement this for more than files { let mut guard = inodes.arena[inode].write(); - match guard.deref_mut() { + let deref_mut = guard.deref_mut(); + match deref_mut { Kind::File { handle, .. } => { if let Some(h) = handle { wasi_try!(h.sync_to_disk().map_err(fs_error_into_wasi_err)); @@ -1703,7 +1715,8 @@ pub fn fd_write( let bytes_written = { let mut guard = inode.write(); - match guard.deref_mut() { + let deref_mut = guard.deref_mut(); + match deref_mut { Kind::File { handle, .. } => { if let Some(handle) = handle { wasi_try_ok!( @@ -1873,7 +1886,8 @@ pub fn path_create_directory( for comp in &path_vec { debug!("Creating dir {}", comp); let mut guard = inodes.arena[cur_dir_inode].write(); - match guard.deref_mut() { + let deref_mut = guard.deref_mut(); + match deref_mut { Kind::Dir { ref mut entries, path, @@ -2175,7 +2189,8 @@ pub fn path_link( } { let mut guard = inodes.arena[target_parent_inode].write(); - match guard.deref_mut() { + let deref_mut = guard.deref_mut(); + match deref_mut { Kind::Dir { entries, .. } => { if entries.contains_key(&new_entry_name) { return __WASI_EEXIST; @@ -2280,7 +2295,8 @@ pub fn path_open( let inode = if let Ok(inode) = maybe_inode { // Happy path, we found the file we're trying to open let mut guard = inodes.arena[inode].write(); - match guard.deref_mut() { + let deref_mut = guard.deref_mut(); + match deref_mut { Kind::File { ref mut handle, path, @@ -2367,7 +2383,8 @@ pub fn path_open( )); let new_file_host_path = { let guard = inodes.arena[parent_inode].read(); - match guard.deref() { + let deref = guard.deref(); + match deref { Kind::Dir { path, .. } => { let mut new_path = path.clone(); new_path.push(&new_entity_name); @@ -2539,7 +2556,8 @@ pub fn path_remove_directory( let host_path_to_remove = { let guard = inodes.arena[inode].read(); - match guard.deref() { + let deref = guard.deref(); + match deref { Kind::Dir { entries, path, .. } => { if !entries.is_empty() || wasi_try!(state.fs_read_dir(path)).count() != 0 { return __WASI_ENOTEMPTY; @@ -2553,7 +2571,8 @@ pub fn path_remove_directory( { let mut guard = inodes.arena[parent_inode].write(); - match guard.deref_mut() { + let deref_mut = guard.deref_mut(); + match deref_mut { Kind::Dir { ref mut entries, .. } => { @@ -2641,7 +2660,8 @@ pub fn path_rename( let host_adjusted_target_path = { let guard = inodes.arena[target_parent_inode].read(); - match guard.deref() { + let deref = guard.deref(); + match deref { Kind::Dir { entries, path, .. } => { if entries.contains_key(&target_entry_name) { return __WASI_EEXIST; @@ -2662,7 +2682,8 @@ pub fn path_rename( let source_entry = { let mut guard = inodes.arena[source_parent_inode].write(); - match guard.deref_mut() { + let deref_mut = guard.deref_mut(); + match deref_mut { Kind::Dir { entries, .. } => { wasi_try!(entries.remove(&source_entry_name).ok_or(__WASI_ENOENT)) } @@ -2678,7 +2699,8 @@ pub fn path_rename( { let mut guard = inodes.arena[source_entry].write(); - match guard.deref_mut() { + let deref_mut = guard.deref_mut(); + match deref_mut { Kind::File { handle, ref path, .. } => { @@ -2800,7 +2822,8 @@ pub fn path_symlink( // short circuit if anything is wrong, before we create an inode { let guard = inodes.arena[target_parent_inode].read(); - match guard.deref() { + let deref = guard.deref(); + match deref { Kind::Dir { entries, .. } => { if entries.contains_key(&entry_name) { return __WASI_EEXIST; @@ -2891,7 +2914,8 @@ pub fn path_unlink_file( let removed_inode = { let mut guard = inodes.arena[parent_inode].write(); - match guard.deref_mut() { + let deref_mut = guard.deref_mut(); + match deref_mut { Kind::Dir { ref mut entries, .. } => { @@ -2916,7 +2940,8 @@ pub fn path_unlink_file( if st_nlink == 0 { { let mut guard = inodes.arena[removed_inode].write(); - match guard.deref_mut() { + let deref_mut = guard.deref_mut(); + match deref_mut { Kind::File { handle, path, .. } => { if let Some(h) = handle { wasi_try!(h.unlink().map_err(fs_error_into_wasi_err)); @@ -3076,7 +3101,8 @@ pub fn poll_oneoff( { let guard = inodes.arena[inode].read(); - match guard.deref() { + let deref = guard.deref(); + match deref { Kind::File { handle, .. } => { if let Some(h) = handle { crate::state::InodeValFileReadGuard { guard } @@ -3103,6 +3129,7 @@ pub fn poll_oneoff( } } + #[allow(clippy::significant_drop_in_scrutinee)] let fds = { let mut f = vec![]; for fd in fd_guards.iter() { @@ -5460,7 +5487,8 @@ pub unsafe fn sock_send_file( let bytes_read = { let mut guard = inode.write(); - match guard.deref_mut() { + let deref_mut = guard.deref_mut(); + match deref_mut { Kind::File { handle, .. } => { if let Some(handle) = handle { wasi_try_ok!(