Remove unsafety from Trap API (#779)

* Remove unsafety from `Trap` API

This commit removes the `unsafe impl Send` for `Trap` by removing the
internal `HostRef` and leaving `HostRef` entirely as an implementation
detail of the C API.

cc #708

* Run rustfmt
This commit is contained in:
Alex Crichton
2020-01-08 14:41:47 -06:00
committed by GitHub
parent 06be4b1495
commit c975a92a3a
9 changed files with 86 additions and 130 deletions

View File

@@ -1,7 +1,6 @@
use crate::r#ref::HostRef;
use crate::runtime::Store;
use crate::trampoline::{generate_func_export, take_api_trap};
use crate::trap::{Trap, TrapInfo};
use crate::trap::Trap;
use crate::types::FuncType;
use crate::values::Val;
use std::rc::Rc;
@@ -158,9 +157,9 @@ impl WrappedCallable for WasmtimeFn {
values_vec.as_mut_ptr() as *mut u8,
)
} {
let trap = take_api_trap()
.unwrap_or_else(|| HostRef::new(TrapInfo::new(format!("call error: {}", message))));
return Err(trap.into());
let trap =
take_api_trap().unwrap_or_else(|| Trap::new(format!("call error: {}", message)));
return Err(trap);
}
// Load the return values out of `values_vec`.