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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
14 changes: 0 additions & 14 deletions src/ast/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,6 @@ impl Expr {
}
}

// TODO(port): gated on `EString::string_z` (E.rs:1666 block) which
// needs `bun_core::ZStr` bump-arena constructors. Only caller
// (`get_string_cloned_z`) is likewise gated.

#[inline]
pub fn as_string_z<'b>(&self, bump: &'b Bump) -> Result<Option<&'b ZStr>, AllocError> {
match &self.data {
Expand All @@ -283,10 +279,6 @@ impl Expr {
}

// Expr — property/object/string accessor methods.
// TODO(port): these call into `E::Object::as_property` / `EString`
// methods that need `bun_core::utf16_eql_string`/`to_utf8_alloc` (track-A
// blocked_on) and `Vec::deep_clone`. Types are real; bodies un-gate with
// the parser round once those land.

impl Expr {
pub fn has_any_property_named(&self, names: &'static [&'static [u8]]) -> bool {
Expand Down Expand Up @@ -314,7 +306,6 @@ impl Expr {
}

// toJS alias deleted — `to_js` lives in `bun_js_parser_jsc::expr_jsc` extension trait.
// TODO(port): move to *_jsc

/// Only use this for pretty-printing JSON. Do not use in transpiler.
///
Expand Down Expand Up @@ -2306,10 +2297,6 @@ impl Data {

// ───────────────────────────────────────────────────────────────────────────
// Data — heavy transform/analysis methods (clone/deep_clone/fold/etc).
// TODO(port): these reference `Vec::deep_clone`/`E::*::Clone`
// surfaces, `bun_core::write_any_to_hasher`, and parser-state types that land
// with `P.rs`/`Parser.rs`. The *types* (`Data`/`Expr`/`Tag`/`Store`) are real;
// only these method bodies wait.

impl Data {
/// Shallow clone: re-allocate the boxed payload (so the caller owns a fresh
Expand Down Expand Up @@ -3101,7 +3088,6 @@ impl Data {
}

// toJS alias deleted — see `bun_js_parser_jsc::expr_jsc::DataJsc` extension trait.
// TODO(port): move to *_jsc

#[inline]
pub fn is_string_value(&self) -> bool {
Expand Down
3 changes: 0 additions & 3 deletions src/ast/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2090,9 +2090,6 @@ impl Log {
let Some((tag_name, sys_errno)) = e.get_error_code_tag_name() else {
return self.add_error_fmt(None, Loc::EMPTY, args);
};
// TODO(port): Zig does comptime fmt-string concat `"{s}: " ++ fmt` and
// tuple concat `.{x} ++ args`. With `fmt::Arguments` we compose at the
// value level instead.
let prefix = bun_sys::coreutils_error_map::get(sys_errno).unwrap_or(tag_name);
self.add_error_fmt(None, Loc::EMPTY, format_args!("{}: {}", prefix, args))
}
Expand Down
2 changes: 0 additions & 2 deletions src/ast/nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,6 @@ pub struct SlotCounts {

impl SlotCounts {
pub fn union_max(&mut self, other: SlotCounts) {
// TODO(port): `enum_map::EnumMap` exposes `.values()`; the Zig iterates raw arrays.
for (a, b) in self.slots.values_mut().zip(other.slots.values()) {
if *a < *b {
*a = *b;
Expand Down Expand Up @@ -1244,7 +1243,6 @@ pub fn printmem(args: fmt::Arguments<'_>) {
Output::flush();
}

// TODO(port): `thiserror` not in this crate's deps; hand-roll Display/Error.
#[derive(Debug, Copy, Clone, PartialEq, Eq, strum::IntoStaticStr)]
pub enum ToJSError {
#[strum(serialize = "Cannot convert argument type to JS")]
Expand Down
1 change: 0 additions & 1 deletion src/ast/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@ impl Op {
// Zig: `pub const TableType: std.EnumArray(Op.Code, Op) = undefined;`
// This declared an `undefined` value (vestigial / used only for @TypeOf at callsites).
// Ported as a type alias since Rust statics cannot be uninitialized.
// TODO(port): verify no callsite reads TableType as a value.
pub type TableType = Table;

/// `.rodata` `[Op; Code::COUNT]` indexed by [`Code`] discriminant. Exposes the
Expand Down
1 change: 0 additions & 1 deletion src/ast/stmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ impl Stmt {
// Zig `comptime_init` — `@unionInit(Data, tag_name, origData)`. In Rust the
// variant constructor IS the union-init; this helper collapses to identity
// and is absorbed by `StatementData::wrap_ref`.
// TODO(port): no direct equivalent; callers use the trait.

#[inline]
pub fn alloc<T: StatementData>(orig_data: T, loc: crate::Loc) -> Stmt {
Expand Down
2 changes: 0 additions & 2 deletions src/base64/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ pub enum DecodeAllocError {
bun_core::named_error_set!(DecodeAllocError);

pub fn decode_alloc(input: &[u8]) -> Result<Vec<u8>, DecodeAllocError> {
// TODO(port): narrow error set
let mut dest = vec![0u8; decode_len(input)];
let result = decode(&mut dest, input);
if !result.is_successful() {
Expand All @@ -122,7 +121,6 @@ pub fn decode_alloc(input: &[u8]) -> Result<Vec<u8>, DecodeAllocError> {
pub use bun_core::base64::encode;

pub fn encode_alloc(source: &[u8]) -> Vec<u8> {
// TODO(port): narrow error set (Zig was `!bun.Vec<u8>`; OOM now aborts)
let len = encode_len(source);
let mut destination = vec![0u8; len];
let encoded_len = encode(&mut destination, source);
Expand Down
1 change: 0 additions & 1 deletion src/boringssl/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,6 @@ pub fn check_x509_server_identity(x509: &mut boring::X509, hostname: &[u8]) -> b
for i in 0..boring::sk_GENERAL_NAME_num(names) {
let r#gen = boring::sk_GENERAL_NAME_value(names, i);
if let Some(name) = r#gen.as_ref() {
// TODO(port): name_type discriminants — verify GEN_* are c_int consts in bun_boringssl_sys
match name.name_type {
boring::GEN_URI => {
has_identifier_san = true;
Expand Down
2 changes: 0 additions & 2 deletions src/bun_alloc/basic.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use core::ffi::c_void;

use crate::{default_alloc, mimalloc};
// TODO(port): `Allocator`/`AllocatorVTable`/`Alignment` are the bun_alloc crate's
// equivalents of `std.mem.Allocator`, its `VTable`, and `std.mem.Alignment`.
// TODO(refactor): consider reshaping the vtable struct into `trait Allocator` impls.
use crate::{Alignment, AllocatorVTable, StdAllocator};

Expand Down
5 changes: 2 additions & 3 deletions src/bun_alloc/heap_breakdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ use core::ffi::{c_char, c_void};
#[cfg(target_os = "macos")]
use core::ffi::{c_int, c_uint};

// Only referenced from the Darwin `extern "C"` block below; rustc's
// reachability analysis doesn't see uses inside dead `extern fn` signatures.
#[allow(non_camel_case_types, dead_code)]
#[cfg(target_os = "macos")]
#[allow(non_camel_case_types)]
type vm_size_t = usize;

// Environment.allow_assert and Environment.isMac and !Environment.enable_asan
Expand Down
5 changes: 0 additions & 5 deletions src/bun_alloc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2187,8 +2187,6 @@ impl Result {
}

pub fn is_overflowing<const COUNT: usize>(&self) -> bool {
// TODO(port): Zig compares the whole packed struct against a usize here
// (`r.index >= count`); reproduce by comparing the raw u32.
self.index.raw() as usize >= COUNT
}
}
Expand All @@ -2198,7 +2196,6 @@ impl Result {
// ──────────────────────────────────────────────────────────────────────────

/// Required interface for the `Block` parameter of `OverflowGroup`/`OverflowList`.
/// TODO(port): Zig used structural duck-typing; this trait names the methods the body calls.
pub trait OverflowBlock {
/// In-place initialize the `used` counter on possibly-uninitialized storage.
/// SAFETY: `this` must point to writable, properly-aligned storage of `Self`.
Expand Down Expand Up @@ -2759,7 +2756,6 @@ struct EmptyType {
}

/// Trait modeling Zig's `comptime AppendType` switch in `doAppend`.
/// TODO(port): Zig dispatches on the *type* (EmptyType / single slice / iterable-of-slices).
pub trait BSSAppendable {
/// Total byte length (excluding sentinel).
fn total_len(&self) -> usize;
Expand Down Expand Up @@ -3204,7 +3200,6 @@ impl<ValueType, const COUNT: usize, const REMOVE_TRAILING_SLASHES: bool>
let _key = Self::key_hash(denormalized_key);

let _guard = self.mutex.lock();
// TODO(port): narrow error set — IndexMap::get_or_put can only OOM.
match self.index.entry(_key) {
std::collections::hash_map::Entry::Occupied(e) => {
let v = *e.get();
Expand Down
5 changes: 0 additions & 5 deletions src/bun_core/Global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -660,8 +660,6 @@ pub fn exit(code: u32) -> ! {

#[cfg(debug_assertions)]
{
// TODO(port): Zig asserts the debug allocator deinit() == .ok and nulls
// the backing. Map to `bun_alloc::debug_allocator_data` once ported.
debug_assert!(debug_allocator_data::deinit_ok());
}

Expand Down Expand Up @@ -789,9 +787,6 @@ pub fn crash() -> ! {

pub const user_agent: &str = concatcp!("Bun/", package_json_version);

// TODO(port): `*const c_char` is `!Sync`; wrap this in a `#[repr(transparent)]`
// Sync newtype or export via a `#[used]` static byte array. Kept as-is to
// mirror the Zig `export const`.
#[repr(transparent)]
pub struct SyncCStr(pub *const c_char);
// SAFETY: points into a `'static` string literal; the pointer is never mutated.
Expand Down
1 change: 0 additions & 1 deletion src/bun_core/env_var.rs
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,6 @@ macro_rules! __key_opt {
None
};
($lit:literal) => {
// TODO(port): need a `zstr!` const constructor for &'static ZStr from a string literal.
Some($crate::zstr!($lit))
};
}
Expand Down
3 changes: 0 additions & 3 deletions src/bun_core/external_shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ impl<T: ExternalSharedDescriptor> ExternalShared<T> {
ptr: Some(this.ptr),
}
}

// TODO(port): Zig's `ExternalShared(T).Optional` was an inherent associated type.
// Stable Rust callers spell `ExternalSharedOptional<T>` directly.
}

impl<T: ExternalSharedDescriptor> core::ops::Deref for ExternalShared<T> {
Expand Down
13 changes: 0 additions & 13 deletions src/bun_core/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,6 @@ impl TableSymbols {
// Table
// ───────────────────────────────────────────────────────────────────────────

// TODO(port): Zig `column_color` was a comptime `[]const u8` param spliced into the
// format string at compile time. Rust const generics don't accept `&'static str`, so
// it is stored as a runtime field and the format string is built at print time.
pub struct Table<
'a,
const COLUMN_LEFT_PAD: usize,
Expand Down Expand Up @@ -211,9 +208,6 @@ impl<'a, const L: usize, const R: usize, const C: bool> Table<'a, L, R, C> {
for _ in 0..L {
crate::pretty!(" ");
}
// TODO(port): Zig spliced `column_color` into the comptime format string
// ("<b><" ++ column_color ++ ">{s}<r>"). Replicate via Output::pretty's
// runtime tag handling.
Output::pretty(format_args!(
"<b><{}>{}<r>",
self.column_color,
Expand Down Expand Up @@ -703,9 +697,6 @@ pub fn fmt_os_path(buf: crate::OSPathSlice<'_>, options: PathFormatOptions) -> F
}
}

// TODO(port): Zig `fmtPath` dispatches on `comptime T: type` returning either FormatUTF8
// or FormatUTF16. In Rust, callers should call `fmt_path_u8` / `fmt_path_u16` directly,
// or use a small trait. Providing both monomorphizations here.
pub fn fmt_path_u8(path: &[u8], options: PathFormatOptions) -> FormatUTF8<'_> {
FormatUTF8 {
buf: path,
Expand Down Expand Up @@ -3556,10 +3547,6 @@ fn escape_powershell_impl(str: &[u8], writer: &mut impl fmt::Write) -> fmt::Resu
// OutOfRangeFormatter — Equivalent to ERR_OUT_OF_RANGE
// ───────────────────────────────────────────────────────────────────────────

// TODO(port): Zig `NewOutOfRangeFormatter(comptime T: type)` branches on `@typeName(T)`
// and `std.meta.hasFn(T, "format")` for the "Received" tail. The `@typeName(T)` fallback
// path is debug-only (Zig panics if field_name unset in debug). Represent as a trait so
// each `T` controls how it prints "Received <value>".
pub trait OutOfRangeValue {
fn write_received(&self, f: &mut Formatter<'_>) -> fmt::Result;
fn type_name() -> &'static str;
Expand Down
18 changes: 2 additions & 16 deletions src/bun_core/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ unsafe impl<T: Sync> Sync for RawSlice<T> {}

/// Port of Zig's `std.os.environ` global (`[][*:0]u8`). On Windows the
/// startup path `bun_sys::windows::env::convert_env_to_wtf8` overwrites this
/// with a WTF-8-encoded envp slice; `getenvZ` and `bun_main` then read it via
/// `os_environ_ptr()`. POSIX builds leave it empty and use libc's `environ`.
/// with a WTF-8-encoded envp slice; `getenvZ` then reads it via
/// `os::environ()`. POSIX builds leave it empty and use libc's `environ`.
#[cfg(windows)]
pub mod os {
use core::ffi::c_char;
Expand Down Expand Up @@ -259,20 +259,6 @@ pub mod os {
}
}

/// `bun.os_environ_ptr()` — pointer to the first element of `std.os.environ`
/// (or null if empty). Windows-only; POSIX uses libc's `environ` symbol.
#[cfg(windows)]
#[inline]
#[allow(dead_code)]
pub(crate) fn os_environ_ptr() -> *const *mut core::ffi::c_char {
// SAFETY: read of a process-global written once at startup.
let e = unsafe { os::environ() };
if e.is_empty() {
core::ptr::null()
} else {
e.as_ptr()
}
}
pub mod deprecated;
pub mod env_var;
pub mod feature_flags;
Expand Down
3 changes: 1 addition & 2 deletions src/bun_core/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
//! * thin `macro_rules!` wrappers (`pretty!`, `pretty_errorln!`, `note!`, …) that perform
//! the compile-time format-string rewrite via `pretty_fmt!`.
//!
//! `pretty_fmt!` itself (the `<red>…<r>` → ANSI substitution) is necessarily a proc-macro;
//! a stub is declared here and flagged `TODO(port): proc-macro`.
//! `pretty_fmt!` itself (the `<red>…<r>` → ANSI substitution) is necessarily a proc-macro.

use core::cell::{Cell, RefCell};
use core::ffi::c_int;
Expand Down
4 changes: 0 additions & 4 deletions src/bun_core/string/HashedString.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ impl HashedString {
}
}

// TODO(port): Zig `eql` took `other: anytype` and switched on `@TypeOf(other)`:
// - HashedString / *HashedString / *const HashedString → compare hash/ptr/len
// - else (slice-like with .len and indexing) → rehash bytes and compare
// Rust has no type-switch; split into `eql` (HashedString) and `eql_bytes` (&[u8]).
pub fn eql(&self, other: &HashedString) -> bool {
((self.hash.max(other.hash) > 0 && self.hash == other.hash) || (self.ptr == other.ptr))
&& self.len == other.len
Expand Down
8 changes: 0 additions & 8 deletions src/bundler/Chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ pub struct Chunk {
pub files_with_parts_in_chunk: ArrayHashMap<IndexInt, core::sync::atomic::AtomicUsize>,

/// We must not keep pointers to this type until all chunks have been allocated.
// TODO(port): was `= undefined` in Zig (set before use)
pub entry_bits: AutoBitSet,

/// PORT NOTE: Zig stored this as an arena-owned `[]const u8` (linker arena);
Expand Down Expand Up @@ -652,7 +651,6 @@ impl IntermediateOutput {
// `LinkerGraph.files` SoA (`items_entry_point_chunk_index`) lands with
// the LinkerGraph work. `bun_paths` / `bun_core::fmt::count` /
// `bun_alloc::alloc_slice` surfaces are tracked upstream.
// TODO(port): MultiArrayList SoA accessors — assuming `.items(.field)` → method returning slice
let additional_files = graph.input_files.items_additional_files();
let unique_key_for_additional_files =
graph.input_files.items_unique_key_for_additional_file();
Expand Down Expand Up @@ -750,7 +748,6 @@ impl IntermediateOutput {
}

QueryKind::HtmlImport => {
// TODO(port): std.fmt.count → counting writer; assuming bun_core::fmt::count
count += bun_core::fmt::count(format_args!(
"{}",
HTMLImportManifest::format_escaped_json(
Expand Down Expand Up @@ -790,7 +787,6 @@ impl IntermediateOutput {

let debug_id_len = if ENABLE_SOURCE_MAP_SHIFTS && FeatureFlags::SOURCE_MAP_DEBUG_ID
{
// TODO(port): std.fmt.count → counting writer
bun_core::fmt::count(format_args!(
"\n//# debugId={}\n",
source_map::DebugIDFormatter {
Expand Down Expand Up @@ -914,7 +910,6 @@ impl IntermediateOutput {
}

QueryKind::HtmlImport => {
// TODO(port): std.io.fixedBufferStream → write into &mut [u8]
let mut cursor: &mut [u8] = remain;
let before_len = cursor.len();
HTMLImportManifest::write_escaped_json(
Expand Down Expand Up @@ -1214,7 +1209,6 @@ impl fmt::Display for UniqueKey {
pub struct EntryPoint(u64);

/// so `EntryPoint` can be a u64
// TODO(port): Rust has no native u30 — using u32 with mask. Zig: `pub const ID = u30;`
pub(crate) type EntryPointId = u32;

impl EntryPoint {
Expand Down Expand Up @@ -1425,13 +1419,11 @@ impl Layers {
}

impl CssImportOrder {
// TODO(port): hasher: anytype — Zig hasher protocol has .update([]const u8)
pub(crate) fn hash<H: bun_core::Hasher + ?Sized>(&self, hasher: &mut H) {
// TODO: conditions, condition_import_records

// Zig: bun.writeAnyToHasher(hasher, std.meta.activeTag(this.kind)) — feeds the small-int
// tag bytes. core::mem::Discriminant is opaque/pointer-sized; hash an explicit u8 instead.
// TODO(port): activeTag byte width — Zig's Tag(union) here is u2; u8 keeps hash stable.
let tag: u8 = match &self.kind {
CssImportOrderKind::Layers(_) => 0,
CssImportOrderKind::ExternalPath(_) => 1,
Expand Down
4 changes: 1 addition & 3 deletions src/bundler/Graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ use bun_ast::Index;
pub(crate) use crate::IndexInt;

pub struct Graph<'a> {
// TODO(port): lifetime — no direct LIFETIMES.tsv row for Graph.pool, but row 170
// (ThreadPool.v2, BACKREF) evidence states "BundleV2.graph.pool owns ThreadPool".
// bundle_v2.zig:992 allocates it from `this.arena()` (the `self.heap` arena) and
// bundle_v2.zig:992 allocates this from `this.arena()` (the `self.heap` arena) and
// bundle_v2.zig:2248 calls `pool.deinit()`, so this is arena-owned but self-referential
// (sibling field). `BackRef` (not raw `NonNull`) so the read accessor `pool()` is
// safe — the BACKREF invariant (pointee outlives holder) holds for the entire
Expand Down
2 changes: 0 additions & 2 deletions src/bundler/HTMLImportManifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ use crate::options::{Loader, OutputKind};
use crate::options_impl::LoaderExt as _;
use crate::{BundleV2, Chunk, LinkerGraph};

// TODO(port): lifetime — LIFETIMES.tsv has no rows for this file; classified as
// BORROW_PARAM (transient formatter struct passed by value).
#[derive(Clone, Copy)]
pub struct HTMLImportManifest<'a> {
pub index: u32,
Expand Down
2 changes: 0 additions & 2 deletions src/bundler/HTMLScanner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ use bun_sys as sys;

bun_core::declare_scope!(HTMLScanner, hidden);

// TODO(port): lifetime — `log`/`source` are borrowed for the scanner's lifetime
// (LIFETIMES.tsv had no row for this file; classified locally as BORROW_PARAM).
pub(crate) struct HTMLScanner<'a> {
// arena field dropped — global mimalloc (see PORTING.md §Allocators).
pub import_records: Vec<ImportRecord>, // Zig: ImportRecord.List
Expand Down
Loading
Loading