From f868e730befb174b500c9e7325be9b931474bd5d Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Thu, 13 Oct 2022 18:47:45 -0700 Subject: feat(tvix/eval): eliminate the only `unsafe` in the codebase Maybe I misunderstood this part of the code, but the use of `unsafe` appears unnecessary here? In any event it is the one and only `unsafe` in the codebase. Hopefully getting to "no `unsafe` anywhere" is worth the extra never-taken branch caused by unwrap() instead of unwrap_unchecked()? Signed-off-by: Adam Joseph Change-Id: I33fbd5aad9d8307ea82c24b6220412783e1973c6 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7011 Tested-by: BuildkiteCI Reviewed-by: tazjin --- tvix/eval/src/vm.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tvix/eval/src/vm.rs b/tvix/eval/src/vm.rs index 50dabf1ee8d5..e1f9d3096b89 100644 --- a/tvix/eval/src/vm.rs +++ b/tvix/eval/src/vm.rs @@ -741,11 +741,9 @@ impl<'o> VM<'o> { // Iterate over the captured with stack if one exists. This is // extra tricky to do without a lot of cloning. for idx in (0..self.frame().upvalues.with_stack_len()).rev() { - // This is safe because having an index here guarantees + // This will not panic because having an index here guarantees // that the stack is present. - let with = - unsafe { self.frame().upvalues.with_stack().unwrap_unchecked()[idx].clone() }; - + let with = self.frame().upvalues.with_stack().unwrap()[idx].clone(); if let Value::Thunk(thunk) = &with { fallible!(self, thunk.force(self)); } -- cgit 1.4.1