Skip to content

Commit d862c8c

Browse files
committed
refactor(data_structures)!: remove PointerExt trait
1 parent 2d7df35 commit d862c8c

File tree

19 files changed

+24
-218
lines changed

19 files changed

+24
-218
lines changed

Cargo.lock

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ indexmap = "2"
154154
proc-macro2 = "1"
155155
quote = "1"
156156
rustc-hash = "2"
157-
rustversion = "1"
158157
serde = "1"
159158
serde_json = "1"
160159
syn = { version = "2", default-features = false }

crates/oxc_allocator/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ doctest = true
2020

2121
[dependencies]
2222
oxc_ast_macros = { workspace = true, optional = true }
23-
oxc_data_structures = { workspace = true, features = ["assert_unchecked", "pointer_ext"] }
23+
oxc_data_structures = { workspace = true, features = ["assert_unchecked"] }
2424
oxc_estree = { workspace = true, optional = true }
2525

2626
allocator-api2 = { workspace = true }

crates/oxc_allocator/src/from_raw_parts.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ use std::{
1515

1616
use bumpalo::Bump;
1717

18-
use oxc_data_structures::pointer_ext::PointerExt;
19-
2018
use crate::Allocator;
2119

2220
/// Minimum alignment for allocator chunks. This is hard-coded on `bumpalo`.
@@ -166,7 +164,7 @@ impl Allocator {
166164
let cursor_ptr = self.cursor_ptr();
167165
// SAFETY: Cursor pointer is always `>=` data pointer.
168166
// Both pointers are within same allocation, and derived from the same original pointer.
169-
let free_capacity = unsafe { cursor_ptr.offset_from_usize(data_ptr) };
167+
let free_capacity = unsafe { cursor_ptr.offset_from_unsigned(data_ptr) };
170168

171169
// Check sufficient capacity to write `alloc_bytes` bytes, without overwriting data already
172170
// stored in allocator.

crates/oxc_allocator/src/string_builder.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::{
1111
slice, str,
1212
};
1313

14-
use oxc_data_structures::{assert_unchecked, pointer_ext::PointerExt};
14+
use oxc_data_structures::assert_unchecked;
1515

1616
use crate::{Allocator, alloc::Alloc};
1717

@@ -245,7 +245,7 @@ impl<'a> StringBuilder<'a> {
245245
#[inline(always)]
246246
pub fn len(&self) -> usize {
247247
// SAFETY: `end_ptr` is always equal to or after `start_ptr`
248-
unsafe { self.end_ptr.offset_from_usize(self.start_ptr) }
248+
unsafe { self.end_ptr.offset_from_unsigned(self.start_ptr) }
249249
}
250250

251251
/// Returns `true` if string is empty.
@@ -258,7 +258,7 @@ impl<'a> StringBuilder<'a> {
258258
#[inline(always)]
259259
pub fn capacity(&self) -> usize {
260260
// SAFETY: `end_capacity_ptr` is always equal to or after `start_ptr`
261-
unsafe { self.end_capacity_ptr.offset_from_usize(self.start_ptr) }
261+
unsafe { self.end_capacity_ptr.offset_from_unsigned(self.start_ptr) }
262262
}
263263

264264
/// Consume [`StringBuilder`] and produce a `&'a str` with lifetime of the arena.
@@ -437,7 +437,7 @@ impl<'a> StringBuilder<'a> {
437437
#[inline(always)]
438438
pub fn reserve(&mut self, additional: usize) {
439439
// SAFETY: `end_capacity` is always equal to or after `end`
440-
let free_bytes = unsafe { self.end_capacity_ptr.offset_from_usize(self.end_ptr) };
440+
let free_bytes = unsafe { self.end_capacity_ptr.offset_from_unsigned(self.end_ptr) };
441441
if free_bytes < additional {
442442
// Insufficient capacity for `additional` bytes. Grow the allocation.
443443
// SAFETY: We just checked allocation is full to capacity.

crates/oxc_ast_visit/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ doctest = false
2121
[dependencies]
2222
oxc_allocator = { workspace = true }
2323
oxc_ast = { workspace = true }
24-
oxc_data_structures = { workspace = true, features = ["pointer_ext"], optional = true }
2524
oxc_span = { workspace = true }
2625
oxc_syntax = { workspace = true }
2726

@@ -30,7 +29,6 @@ default = []
3029
serialize = [
3130
"oxc_allocator/serialize",
3231
"oxc_ast/serialize",
33-
"oxc_data_structures",
3432
"oxc_span/serialize",
3533
"oxc_syntax/serialize",
3634
]

crates/oxc_ast_visit/src/utf8_to_utf16.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
use std::{cmp::min, slice};
44

55
use oxc_ast::ast::{Comment, Program};
6-
use oxc_data_structures::pointer_ext::PointerExt;
76
use oxc_span::Span;
87
use oxc_syntax::module_record::{ModuleRecord, VisitMutModuleRecord};
98

@@ -552,7 +551,7 @@ fn build_translations(source_text: &str, translations: &mut Vec<Translation>) {
552551
if chunk.contains_unicode() {
553552
// SAFETY: `ptr` is equal to or after `start_ptr`. Both are within bounds of `bytes`.
554553
// `ptr` is derived from `start_ptr`.
555-
let offset = unsafe { ptr.offset_from_usize(start_ptr) };
554+
let offset = unsafe { ptr.offset_from_unsigned(start_ptr) };
556555
process_slice(chunk.as_slice(), offset);
557556
}
558557

@@ -573,7 +572,7 @@ fn build_translations(source_text: &str, translations: &mut Vec<Translation>) {
573572
let last_chunk = unsafe { slice::from_raw_parts(ptr, remaining_len) };
574573
// SAFETY: `ptr` is after `start_ptr`. Both are within bounds of `bytes`.
575574
// `ptr` is derived from `start_ptr`.
576-
let offset = unsafe { ptr.offset_from_usize(start_ptr) };
575+
let offset = unsafe { ptr.offset_from_unsigned(start_ptr) };
577576
process_slice(last_chunk, offset);
578577
}
579578
}

crates/oxc_codegen/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ doctest = true
2222
[dependencies]
2323
oxc_allocator = { workspace = true }
2424
oxc_ast = { workspace = true }
25-
oxc_data_structures = { workspace = true, features = ["code_buffer", "pointer_ext", "slice_iter_ext", "stack"] }
25+
oxc_data_structures = { workspace = true, features = ["code_buffer", "slice_iter_ext", "stack"] }
2626
oxc_index = { workspace = true }
2727
oxc_semantic = { workspace = true }
2828
oxc_sourcemap = { workspace = true }

crates/oxc_codegen/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use std::{borrow::Cow, cmp, slice};
99

1010
use cow_utils::CowUtils;
11-
use oxc_data_structures::pointer_ext::PointerExt;
1211

1312
mod binary_expr_visitor;
1413
mod comment;
@@ -280,7 +279,7 @@ impl<'a> Codegen<'a> {
280279
// `index` is on `<`, so `index + 1` is in bounds and a UTF-8 char boundary.
281280
// `consumed` is always less than `index + 1` as it's set on a previous round.
282281
unsafe {
283-
let index = ptr.offset_from_usize(bytes.as_ptr());
282+
let index = ptr.offset_from_unsigned(bytes.as_ptr());
284283
let before = bytes.get_unchecked(consumed..=index);
285284
self.code.print_bytes_unchecked(before);
286285

crates/oxc_codegen/src/str.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
use std::slice;
22

33
use oxc_ast::ast::StringLiteral;
4-
use oxc_data_structures::{
5-
assert_unchecked, pointer_ext::PointerExt, slice_iter_ext::SliceIterExt,
6-
};
4+
use oxc_data_structures::{assert_unchecked, slice_iter_ext::SliceIterExt};
75
use oxc_syntax::identifier::{LS, NBSP, PS};
86

97
use crate::Codegen;
@@ -186,7 +184,7 @@ impl PrintStringState<'_> {
186184
// and the iterator only advances, so current position of `bytes` must be on or after `chunk_start`
187185
let len = unsafe {
188186
let bytes_ptr = self.bytes.as_slice().as_ptr();
189-
bytes_ptr.offset_from_usize(self.chunk_start)
187+
bytes_ptr.offset_from_unsigned(self.chunk_start)
190188
};
191189

192190
// SAFETY: `chunk_start` is within bounds of original `&str`.

0 commit comments

Comments
 (0)