Skip to content

Commit 7a49e18

Browse files
committed
update safety docss
1 parent 2bf805a commit 7a49e18

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

crates/wasmi/src/instance/cache.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,9 @@ impl AnyHandleAndEntity {
9797
///
9898
/// # Safety
9999
///
100-
/// The caller must ensure that `self` stores a `T` handle.
101-
/// Debug builds validate this against the stored handle kind tag.
100+
/// The caller must ensure that `this` points to a live entry that stores a `T` handle and
101+
/// that is not mutably accessed for the duration of the call.
102+
/// Debug builds validate the handle kind against the stored handle kind tag.
102103
#[inline]
103104
pub fn into_typed_ptr<T: HasHandleKind>(
104105
this: NonNull<AnyHandleAndEntity>,
@@ -168,6 +169,11 @@ impl<T: Handle<Entity: Sized>> HandleAndEntity<T> {
168169
/// Maps `this` to the internal pointer to the cached entity of the pointee.
169170
///
170171
/// The returned pointer is only sound to dereference once the cache has been warmed up.
172+
///
173+
/// # Safety
174+
///
175+
/// The caller must ensure that `this` points to a live entry that is not accessed through
176+
/// any other pointer for the duration of the call.
171177
#[inline]
172178
pub fn map_entity(this: NonNull<Self>) -> NonNull<<T as Handle>::Entity> {
173179
let mut this = this;

0 commit comments

Comments
 (0)