diff --git a/lib/runtime-c-api/src/import/mod.rs b/lib/runtime-c-api/src/import/mod.rs index c6d724f51..53a535e2c 100644 --- a/lib/runtime-c-api/src/import/mod.rs +++ b/lib/runtime-c-api/src/import/mod.rs @@ -206,7 +206,7 @@ pub unsafe extern "C" fn wasmer_import_object_iterate_functions( return std::ptr::null_mut(); } let import_object: &ImportObject = &*(import_object as *const ImportObject); - let iter_inner = Box::new(import_object.clone_ref().into_iter().filter(|(_, _, e)| { + let iter_inner = Box::new(import_object.clone().into_iter().filter(|(_, _, e)| { if let Export::Function { .. } = e { true } else { diff --git a/lib/runtime-core/src/import.rs b/lib/runtime-core/src/import.rs index e5cd06c4d..2ab520f89 100644 --- a/lib/runtime-core/src/import.rs +++ b/lib/runtime-core/src/import.rs @@ -54,6 +54,7 @@ impl IsExport for Export { /// n /// } /// ``` +#[derive(Clone)] pub struct ImportObject { map: Arc>>>, pub(crate) state_creator: @@ -158,15 +159,6 @@ impl ImportObject { .and_then(|ns| f(ns)) } - /// Create a clone ref of this namespace. - pub fn clone_ref(&self) -> Self { - Self { - map: Arc::clone(&self.map), - state_creator: self.state_creator.clone(), - allow_missing_functions: false, - } - } - fn get_objects(&self) -> VecDeque<(String, String, Export)> { let mut out = VecDeque::new(); let guard = self.map.lock().unwrap(); diff --git a/lib/runtime-core/src/instance.rs b/lib/runtime-core/src/instance.rs index 7fa7a6872..35ca3b084 100644 --- a/lib/runtime-core/src/instance.rs +++ b/lib/runtime-core/src/instance.rs @@ -103,7 +103,7 @@ impl Instance { module, inner, exports, - import_object: imports.clone_ref(), + import_object: imports.clone(), }; if let Some(start_index) = instance.module.info.start_func { diff --git a/lib/wasi/src/syscalls/mod.rs b/lib/wasi/src/syscalls/mod.rs index fcf9536aa..49b48062b 100644 --- a/lib/wasi/src/syscalls/mod.rs +++ b/lib/wasi/src/syscalls/mod.rs @@ -1981,10 +1981,8 @@ pub fn path_remove_directory( Kind::Dir { entries, path, .. } => { if !entries.is_empty() { return __WASI_ENOTEMPTY; - } else { - if wasi_try!(std::fs::read_dir(path).ok(), __WASI_EIO).count() != 0 { - return __WASI_ENOTEMPTY; - } + } else if wasi_try!(std::fs::read_dir(path).ok(), __WASI_EIO).count() != 0 { + return __WASI_ENOTEMPTY; } path.clone() } diff --git a/src/commands/cache.rs b/src/commands/cache.rs index 84afa3cbd..79496a5fd 100644 --- a/src/commands/cache.rs +++ b/src/commands/cache.rs @@ -21,7 +21,7 @@ impl Cache { if cache_dir.exists() { fs::remove_dir_all(cache_dir.clone()).expect("Can't remove cache dir"); } - fs::create_dir_all(cache_dir.clone()).expect("Can't create cache dir"); + fs::create_dir_all(cache_dir).expect("Can't create cache dir"); } Cache::Dir => { println!("{}", get_cache_dir().to_string_lossy()); diff --git a/tests/test-generator/src/lib.rs b/tests/test-generator/src/lib.rs index bd6425d11..cd0ca241f 100644 --- a/tests/test-generator/src/lib.rs +++ b/tests/test-generator/src/lib.rs @@ -70,7 +70,7 @@ pub fn build_ignores_from_textfile(path: PathBuf) -> anyhow::Result { } else { (line, None) }; - if line.len() == 0 { + if line.is_empty() { continue; } diff --git a/tests/wast/src/wast.rs b/tests/wast/src/wast.rs index 1497c5d43..753e51c7b 100644 --- a/tests/wast/src/wast.rs +++ b/tests/wast/src/wast.rs @@ -292,7 +292,7 @@ impl Wast { let compiler = compiler_for_backend(self.backend).expect("backend not found"); let module = compile_with_config_with(module, config, &*compiler)?; - let mut imports = self.import_object.clone_ref(); + let mut imports = self.import_object.clone(); for import in module.imports() { let module_name = import.namespace;