Skip to content

Commit 7aea45a

Browse files
authored
Remove unsafe from Instance::from_wasmtime (bytecodealliance#10935)
* Remove `unsafe` from `Instance::from_wasmtime` I mistakenly thought that this would be an `unsafe` function due to reasons that aren't applicable, and I'm not aware of any reason why this function should be `unsafe`, so mark it safe. * Review comments
1 parent aad93a4 commit 7aea45a

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

crates/wasmtime/src/runtime/component/instance.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,7 @@ const _: () = {
5050

5151
impl Instance {
5252
/// Creates a raw `Instance` from the internal identifiers within the store.
53-
///
54-
/// # Safety
55-
///
56-
/// The safety of this function relies on `id` belonging to the instance
57-
/// within `store`.
58-
pub(crate) unsafe fn from_wasmtime(store: &StoreOpaque, id: ComponentInstanceId) -> Instance {
53+
pub(crate) fn from_wasmtime(store: &StoreOpaque, id: ComponentInstanceId) -> Instance {
5954
Instance {
6055
id: StoreComponentInstanceId::new(store.id(), id),
6156
}
@@ -883,10 +878,7 @@ impl<T: 'static> InstancePre<T> {
883878
.decrement_component_instance_count();
884879
e
885880
})?;
886-
// SAFETY: `from_wasmtime` requires that `id` belongs to the store
887-
// provided, and it was just inserted above so the condition should be
888-
// satisfied.
889-
let instance = unsafe { Instance::from_wasmtime(store.0, instantiator.id) };
881+
let instance = Instance::from_wasmtime(store.0, instantiator.id);
890882
store.0.push_component_instance(instance);
891883
Ok(instance)
892884
}

0 commit comments

Comments
 (0)