Skip to content

Commit

Permalink
refactor(index, traverse): remove unnecessary type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
overlookmotel committed Sep 9, 2024
1 parent e38114b commit bd5b80e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions crates/oxc_index/src/idxslice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,14 @@ impl<I: Idx, T> IndexSlice<I, [T]> {
#[inline(always)]
pub fn from_slice(s: &[T]) -> &Self {
// SAFETY: `IndexSlice` is a thin wrapper around `[T]` with the added marker for the index.

unsafe { &*(core::ptr::from_ref::<[T]>(s) as *const Self) }
unsafe { &*(core::ptr::from_ref(s) as *const Self) }
}

/// Construct a new mutable IdxSlice by wrapping an existing mutable slice.
#[inline(always)]
pub fn from_slice_mut(s: &mut [T]) -> &mut Self {
// SAFETY: `IndexSlice` is a thin wrapper around `[T]` with the added marker for the index.

unsafe { &mut *(core::ptr::from_mut::<[T]>(s) as *mut Self) }
unsafe { &mut *(core::ptr::from_mut(s) as *mut Self) }
}

/// Copies `self` into a new `IndexVec`.
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_traverse/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,5 +161,5 @@ pub fn walk_program<'a, Tr: Traverse<'a>>(
ctx: &mut TraverseCtx<'a>,
) {
// SAFETY: Walk functions are constructed to avoid unsoundness
unsafe { walk::walk_program(traverser, std::ptr::from_mut::<Program>(program), ctx) };
unsafe { walk::walk_program(traverser, std::ptr::from_mut(program), ctx) };
}

0 comments on commit bd5b80e

Please sign in to comment.