diff --git a/crates/oxc_index/src/idxslice.rs b/crates/oxc_index/src/idxslice.rs index a4b4bdabd060c..0ccac7be1f98e 100644 --- a/crates/oxc_index/src/idxslice.rs +++ b/crates/oxc_index/src/idxslice.rs @@ -668,7 +668,7 @@ impl IndexSlice { } else { let last = self.last_idx(); let split = self.split_at_mut(last); - Some((&mut split.1[0], split.0)) + Some((&mut split.1[I::from_usize(0)], split.0)) } } } diff --git a/crates/oxc_index/src/indexing.rs b/crates/oxc_index/src/indexing.rs index 6eab0b60ecf24..ddbbc92bc8233 100644 --- a/crates/oxc_index/src/indexing.rs +++ b/crates/oxc_index/src/indexing.rs @@ -109,32 +109,6 @@ impl IdxSliceIndex for core::ops::RangeFull { } } -impl private_slice_index::Sealed for usize {} -// As an ergonomic concession, implement this for `usize` as well, it's too painful without -impl IdxSliceIndex for usize { - type Output = T; - - #[inline] - fn get(self, slice: &IndexSlice) -> Option<&Self::Output> { - slice.raw.get(self) - } - - #[inline] - fn get_mut(self, slice: &mut IndexSlice) -> Option<&mut Self::Output> { - slice.raw.get_mut(self) - } - - #[inline] - fn index(self, slice: &IndexSlice) -> &Self::Output { - &slice.raw[self] - } - - #[inline] - fn index_mut(self, slice: &mut IndexSlice) -> &mut Self::Output { - &mut slice.raw[self] - } -} - /// This trait to function in API signatures where `Vec` or `[T]` use `R: /// RangeBounds`. There are blanket implementations for the basic range /// types in `core::ops` for all Idx types. e.g. `Range`, `RangeFrom = &v[..]; assert_eq!(s, &[0, 1, 2, 3, 4]); @@ -490,8 +488,6 @@ fn test_indexing() { assert_eq!(s, &[0, 1, 2, 3]); } assert_eq!(&mut v[IdxSz::new(3)], &mut 3); - - assert_eq!(&mut v[3], &mut 3); // usize is allowed. } #[test] @@ -510,7 +506,6 @@ fn test_get() { assert_eq!(s.unwrap(), &[0, 1, 2, 3]); assert_eq!(v.get(IdxSz::new(3)), Some(&3)); - assert_eq!(v.get(3), Some(&3)); } #[test] @@ -527,7 +522,6 @@ fn test_get_mut() { let s: Option<&mut IndexSlice> = v.get_mut(..=IdxSz::new(3)); assert_eq!(s.unwrap(), &[0, 1, 2, 3]); assert_eq!(v.get_mut(IdxSz::new(3)), Some(&mut 3)); - assert_eq!(v.get_mut(3), Some(&mut 3)); } #[test]