Skip to content

Commit 65155f6

Browse files
docs: improve all new safety comments
Signed-off-by: Florian Hartung <florian.hartung@dlr.de>
1 parent 8ccc22a commit 65155f6

File tree

6 files changed

+113
-91
lines changed

6 files changed

+113
-91
lines changed

src/core/reader/types/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,8 @@ impl BlockType {
233233
},
234234
}),
235235
BlockType::Type(type_idx) => {
236-
// SAFETY: Upheld by the caller
236+
// SAFETY: The caller ensures that this `IdxVec` is the same one
237+
// used to validate the `TypeIdx` in `self`.
237238
let func_type = unsafe { func_types.get(*type_idx) };
238239
Ok(func_type.clone())
239240
}

src/execution/const_interpreter_loop.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ pub(crate) fn run_const<T: Config>(
5757

5858
let module_instance = store.modules.get(module);
5959

60-
// SAFETY: Validation guarantees the global index to be valid
61-
// for the current module.
60+
// SAFETY: Validation guarantees the global index to be valid in
61+
// the current module.
6262
let global_addr = *unsafe { module_instance.global_addrs.get(global_idx) };
6363

6464
let global = store.globals.get(global_addr);
@@ -100,7 +100,7 @@ pub(crate) fn run_const<T: Config>(
100100
// index next.
101101
let func_idx = unsafe { FuncIdx::read_unchecked(wasm) };
102102
// SAFETY: Validation guarantees the function index to be valid
103-
// for the current module.
103+
// in the current module.
104104
let func_addr = unsafe { store.modules.get(module).func_addrs.get(func_idx) };
105105
stack.push_value::<T>(Value::Ref(Ref::Func(*func_addr)))?;
106106
}

0 commit comments

Comments
 (0)