Merge branch 'master' into fix/doc-comment-runtimeerror

This commit is contained in:
Ivan Enderlin 2020-04-30 09:47:56 +02:00 committed by GitHub
commit 3feaa7fd3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 9 additions and 19 deletions

View File

@ -206,7 +206,7 @@ pub unsafe extern "C" fn wasmer_import_object_iterate_functions(
return std::ptr::null_mut(); return std::ptr::null_mut();
} }
let import_object: &ImportObject = &*(import_object as *const ImportObject); 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 { if let Export::Function { .. } = e {
true true
} else { } else {

View File

@ -54,6 +54,7 @@ impl IsExport for Export {
/// n /// n
/// } /// }
/// ``` /// ```
#[derive(Clone)]
pub struct ImportObject { pub struct ImportObject {
map: Arc<Mutex<HashMap<String, Box<dyn LikeNamespace + Send>>>>, map: Arc<Mutex<HashMap<String, Box<dyn LikeNamespace + Send>>>>,
pub(crate) state_creator: pub(crate) state_creator:
@ -158,15 +159,6 @@ impl ImportObject {
.and_then(|ns| f(ns)) .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)> { fn get_objects(&self) -> VecDeque<(String, String, Export)> {
let mut out = VecDeque::new(); let mut out = VecDeque::new();
let guard = self.map.lock().unwrap(); let guard = self.map.lock().unwrap();

View File

@ -103,7 +103,7 @@ impl Instance {
module, module,
inner, inner,
exports, exports,
import_object: imports.clone_ref(), import_object: imports.clone(),
}; };
if let Some(start_index) = instance.module.info.start_func { if let Some(start_index) = instance.module.info.start_func {

View File

@ -1979,12 +1979,10 @@ pub fn path_remove_directory(
let host_path_to_remove = match &state.fs.inodes[inode].kind { let host_path_to_remove = match &state.fs.inodes[inode].kind {
Kind::Dir { entries, path, .. } => { Kind::Dir { entries, path, .. } => {
if !entries.is_empty() { if !entries.is_empty()
|| wasi_try!(std::fs::read_dir(path).ok(), __WASI_EIO).count() != 0
{
return __WASI_ENOTEMPTY; return __WASI_ENOTEMPTY;
} else {
if wasi_try!(std::fs::read_dir(path).ok(), __WASI_EIO).count() != 0 {
return __WASI_ENOTEMPTY;
}
} }
path.clone() path.clone()
} }

View File

@ -21,7 +21,7 @@ impl Cache {
if cache_dir.exists() { if cache_dir.exists() {
fs::remove_dir_all(cache_dir.clone()).expect("Can't remove cache dir"); 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 => { Cache::Dir => {
println!("{}", get_cache_dir().to_string_lossy()); println!("{}", get_cache_dir().to_string_lossy());

View File

@ -70,7 +70,7 @@ pub fn build_ignores_from_textfile(path: PathBuf) -> anyhow::Result<Ignores> {
} else { } else {
(line, None) (line, None)
}; };
if line.len() == 0 { if line.is_empty() {
continue; continue;
} }

View File

@ -292,7 +292,7 @@ impl Wast {
let compiler = compiler_for_backend(self.backend).expect("backend not found"); let compiler = compiler_for_backend(self.backend).expect("backend not found");
let module = compile_with_config_with(module, config, &*compiler)?; 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() { for import in module.imports() {
let module_name = import.namespace; let module_name = import.namespace;