Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ indexmap = "2"
proc-macro2 = "1"
quote = "1"
rustc-hash = "2"
rustversion = "1"
serde = "1"
serde_json = "1"
syn = { version = "2", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_allocator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ doctest = true

[dependencies]
oxc_ast_macros = { workspace = true, optional = true }
oxc_data_structures = { workspace = true, features = ["assert_unchecked", "pointer_ext"] }
oxc_data_structures = { workspace = true, features = ["assert_unchecked"] }
oxc_estree = { workspace = true, optional = true }

allocator-api2 = { workspace = true }
Expand Down
4 changes: 1 addition & 3 deletions crates/oxc_allocator/src/from_raw_parts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ use std::{

use bumpalo::Bump;

use oxc_data_structures::pointer_ext::PointerExt;

use crate::Allocator;

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

// Check sufficient capacity to write `alloc_bytes` bytes, without overwriting data already
// stored in allocator.
Expand Down
8 changes: 4 additions & 4 deletions crates/oxc_allocator/src/string_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::{
slice, str,
};

use oxc_data_structures::{assert_unchecked, pointer_ext::PointerExt};
use oxc_data_structures::assert_unchecked;

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

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

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

/// Consume [`StringBuilder`] and produce a `&'a str` with lifetime of the arena.
Expand Down Expand Up @@ -437,7 +437,7 @@ impl<'a> StringBuilder<'a> {
#[inline(always)]
pub fn reserve(&mut self, additional: usize) {
// SAFETY: `end_capacity` is always equal to or after `end`
let free_bytes = unsafe { self.end_capacity_ptr.offset_from_usize(self.end_ptr) };
let free_bytes = unsafe { self.end_capacity_ptr.offset_from_unsigned(self.end_ptr) };
if free_bytes < additional {
// Insufficient capacity for `additional` bytes. Grow the allocation.
// SAFETY: We just checked allocation is full to capacity.
Expand Down
2 changes: 0 additions & 2 deletions crates/oxc_ast_visit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ doctest = false
[dependencies]
oxc_allocator = { workspace = true }
oxc_ast = { workspace = true }
oxc_data_structures = { workspace = true, features = ["pointer_ext"], optional = true }
oxc_span = { workspace = true }
oxc_syntax = { workspace = true }

Expand All @@ -30,7 +29,6 @@ default = []
serialize = [
"oxc_allocator/serialize",
"oxc_ast/serialize",
"oxc_data_structures",
"oxc_span/serialize",
"oxc_syntax/serialize",
]
Expand Down
5 changes: 2 additions & 3 deletions crates/oxc_ast_visit/src/utf8_to_utf16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
use std::{cmp::min, slice};

use oxc_ast::ast::{Comment, Program};
use oxc_data_structures::pointer_ext::PointerExt;
use oxc_span::Span;
use oxc_syntax::module_record::{ModuleRecord, VisitMutModuleRecord};

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

Expand All @@ -573,7 +572,7 @@ fn build_translations(source_text: &str, translations: &mut Vec<Translation>) {
let last_chunk = unsafe { slice::from_raw_parts(ptr, remaining_len) };
// SAFETY: `ptr` is after `start_ptr`. Both are within bounds of `bytes`.
// `ptr` is derived from `start_ptr`.
let offset = unsafe { ptr.offset_from_usize(start_ptr) };
let offset = unsafe { ptr.offset_from_unsigned(start_ptr) };
process_slice(last_chunk, offset);
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ doctest = true
[dependencies]
oxc_allocator = { workspace = true }
oxc_ast = { workspace = true }
oxc_data_structures = { workspace = true, features = ["code_buffer", "pointer_ext", "slice_iter_ext", "stack"] }
oxc_data_structures = { workspace = true, features = ["code_buffer", "slice_iter_ext", "stack"] }
oxc_index = { workspace = true }
oxc_semantic = { workspace = true }
oxc_sourcemap = { workspace = true }
Expand Down
3 changes: 1 addition & 2 deletions crates/oxc_codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use std::{borrow::Cow, cmp, slice};

use cow_utils::CowUtils;
use oxc_data_structures::pointer_ext::PointerExt;

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

Expand Down
6 changes: 2 additions & 4 deletions crates/oxc_codegen/src/str.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use std::slice;

use oxc_ast::ast::StringLiteral;
use oxc_data_structures::{
assert_unchecked, pointer_ext::PointerExt, slice_iter_ext::SliceIterExt,
};
use oxc_data_structures::{assert_unchecked, slice_iter_ext::SliceIterExt};
use oxc_syntax::identifier::{LS, NBSP, PS};

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

// SAFETY: `chunk_start` is within bounds of original `&str`.
Expand Down
6 changes: 2 additions & 4 deletions crates/oxc_data_structures/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,13 @@ doctest = true

[dependencies]
ropey = { workspace = true, optional = true }
rustversion = { workspace = true, optional = true }

[features]
default = []
all = ["assert_unchecked", "code_buffer", "inline_string", "pointer_ext", "rope", "slice_iter_ext", "stack"]
all = ["assert_unchecked", "code_buffer", "inline_string", "rope", "slice_iter_ext", "stack"]
assert_unchecked = []
code_buffer = ["assert_unchecked"]
inline_string = ["assert_unchecked"]
pointer_ext = ["dep:rustversion"]
rope = ["dep:ropey"]
slice_iter_ext = ["assert_unchecked"]
stack = ["pointer_ext"]
stack = []
1 change: 0 additions & 1 deletion crates/oxc_data_structures/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ This crate provides specialized data structures and utilities that are used thro
- **Stacks**: Efficient stack types, optimized for fast `push`, `pop`, and `last`
- **Code buffer**: Efficient string building with segment tracking
- **Inline strings**: Memory-efficient string storage for short strings
- **Pointer extensions**: Utilities for safe pointer manipulation
- **Slice iterators**: Enhanced iteration capabilities for slices
- **Rope data structure**: Efficient text manipulation for large documents

Expand Down
3 changes: 0 additions & 3 deletions crates/oxc_data_structures/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ pub mod code_buffer;
#[cfg(feature = "inline_string")]
pub mod inline_string;

#[cfg(feature = "pointer_ext")]
pub mod pointer_ext;

#[cfg(feature = "slice_iter_ext")]
pub mod slice_iter_ext;

Expand Down
171 changes: 0 additions & 171 deletions crates/oxc_data_structures/src/pointer_ext.rs

This file was deleted.

Loading
Loading