declone and close the door (#12035)

* declone and close the door

* cargo fmt

* remove brackets
This commit is contained in:
Squirrel
2022-08-15 20:38:36 +01:00
committed by GitHub
parent 9c2a2495fe
commit a68a80fbae
72 changed files with 344 additions and 512 deletions
@@ -107,8 +107,7 @@ impl EntryPoint {
) -> std::result::Result<Self, &'static str> {
let entrypoint = func
.typed::<(u32, u32), u64, _>(ctx)
.map_err(|_| "Invalid signature for direct entry point")?
.clone();
.map_err(|_| "Invalid signature for direct entry point")?;
Ok(Self { call_type: EntryPointType::Direct { entrypoint } })
}
@@ -119,8 +118,7 @@ impl EntryPoint {
) -> std::result::Result<Self, &'static str> {
let dispatcher = dispatcher
.typed::<(u32, u32, u32), u64, _>(ctx)
.map_err(|_| "Invalid signature for wrapped entry point")?
.clone();
.map_err(|_| "Invalid signature for wrapped entry point")?;
Ok(Self { call_type: EntryPointType::Wrapped { func, dispatcher } })
}
}
@@ -214,9 +212,8 @@ impl InstanceWrapper {
Error::from(format!("Exported method {} is not found", method))
})?;
let func = extern_func(&export)
.ok_or_else(|| Error::from(format!("Export {} is not a function", method)))?
.clone();
EntryPoint::direct(func, &self.store).map_err(|_| {
.ok_or_else(|| Error::from(format!("Export {} is not a function", method)))?;
EntryPoint::direct(*func, &self.store).map_err(|_| {
Error::from(format!("Exported function '{}' has invalid signature.", method))
})?
},
@@ -231,10 +228,9 @@ impl InstanceWrapper {
let func = val
.funcref()
.ok_or(Error::TableElementIsNotAFunction(func_ref))?
.ok_or(Error::FunctionRefIsNull(func_ref))?
.clone();
.ok_or(Error::FunctionRefIsNull(func_ref))?;
EntryPoint::direct(func, &self.store).map_err(|_| {
EntryPoint::direct(*func, &self.store).map_err(|_| {
Error::from(format!(
"Function @{} in exported table has invalid signature for direct call.",
func_ref,
@@ -252,10 +248,9 @@ impl InstanceWrapper {
let dispatcher = val
.funcref()
.ok_or(Error::TableElementIsNotAFunction(dispatcher_ref))?
.ok_or(Error::FunctionRefIsNull(dispatcher_ref))?
.clone();
.ok_or(Error::FunctionRefIsNull(dispatcher_ref))?;
EntryPoint::wrapped(dispatcher, func, &self.store).map_err(|_| {
EntryPoint::wrapped(*dispatcher, func, &self.store).map_err(|_| {
Error::from(format!(
"Function @{} in exported table has invalid signature for wrapped call.",
dispatcher_ref,
@@ -315,9 +310,8 @@ fn get_linear_memory(instance: &Instance, ctx: impl AsContextMut) -> Result<Memo
.get_export(ctx, "memory")
.ok_or_else(|| Error::from("memory is not exported under `memory` name"))?;
let memory = extern_memory(&memory_export)
.ok_or_else(|| Error::from("the `memory` export should have memory type"))?
.clone();
let memory = *extern_memory(&memory_export)
.ok_or_else(|| Error::from("the `memory` export should have memory type"))?;
Ok(memory)
}