diff --git a/scripts/build/config.ts b/scripts/build/config.ts index a2d5cb4c7528..c21d03f7ed3b 100644 --- a/scripts/build/config.ts +++ b/scripts/build/config.ts @@ -84,8 +84,6 @@ export interface Config { freebsd: boolean; /** linux || darwin || freebsd */ unix: boolean; - /** darwin || freebsd — kqueue-based event loop */ - kqueue: boolean; x64: boolean; arm64: boolean; @@ -740,7 +738,6 @@ export function resolveConfig(partial: PartialConfig, toolchain: Toolchain): Con const windows = os === "windows"; const freebsd = os === "freebsd"; const unix = linux || darwin || freebsd; - const kqueue = darwin || freebsd; const x64 = arch === "x64"; const arm64 = arch === "aarch64"; // Darwin target on a non-darwin host (Linux CI box building macOS @@ -1183,7 +1180,6 @@ export function resolveConfig(partial: PartialConfig, toolchain: Toolchain): Con windows, freebsd, unix, - kqueue, x64, arm64, host, diff --git a/scripts/build/depVersionsHeader.ts b/scripts/build/depVersionsHeader.ts index bbeed206b600..fbf24f63fd6c 100644 --- a/scripts/build/depVersionsHeader.ts +++ b/scripts/build/depVersionsHeader.ts @@ -101,9 +101,6 @@ export function generateDepVersionsHeader(cfg: Config): string { 'extern "C" {', "#endif", "", - "// Dependency versions", - ...versions.map(([name, val]) => `#define BUN_DEP_${name} "${val}"`), - "", "// C string constants for easy access", ...versions.map(([name, val]) => `static const char* const BUN_VERSION_${name} = "${val}";`), "", diff --git a/scripts/build/source.ts b/scripts/build/source.ts index a46b034d4805..6593e7257b51 100644 --- a/scripts/build/source.ts +++ b/scripts/build/source.ts @@ -452,7 +452,7 @@ export interface Dependency { /** * Macro name suffix for `bun_dependency_versions.h` — becomes - * `BUN_DEP_` / `BUN_VERSION_`. The value is derived from + * `BUN_VERSION_`. The value is derived from * `source(cfg)`: `github-archive.commit`, `prebuilt.identity`, etc. * * Omit for deps that shouldn't appear in `process.versions` (e.g. diff --git a/scripts/glob-sources.ts b/scripts/glob-sources.ts index 804d38c72f51..c9ba7599100c 100644 --- a/scripts/glob-sources.ts +++ b/scripts/glob-sources.ts @@ -123,7 +123,6 @@ const patterns = { "packages/bun-usockets/src/crypto/*.c", "src/jsc/bindings/uv-posix-polyfills.c", "src/jsc/bindings/uv-posix-stubs.c", - "src/*.c", "src/jsc/bindings/node/http/llhttp/*.c", ], }, diff --git a/src/ast/symbol.rs b/src/ast/symbol.rs index 7bc5ac875ee8..1b76b3abee95 100644 --- a/src/ast/symbol.rs +++ b/src/ast/symbol.rs @@ -545,14 +545,6 @@ impl Map { }) } - pub fn init(source_count: usize) -> Map { - let mut v: NestedList = Vec::with_capacity(source_count); - v.resize_with(source_count, Vec::new); - Map { - symbols_for_source: v, - } - } - // Takes ownership of `list` and boxes it into a one-element NestedList. // PERF: one extra allocation — profile if needed (single caller is the // printer one-shot, cold). diff --git a/src/boringssl_sys/boringssl.rs b/src/boringssl_sys/boringssl.rs index ed3994d474b1..b4467c77ceeb 100644 --- a/src/boringssl_sys/boringssl.rs +++ b/src/boringssl_sys/boringssl.rs @@ -331,10 +331,6 @@ impl GeneralNames { unsafe { sk_num(self.0.as_ptr().cast::()) } } - pub fn is_empty(&self) -> bool { - self.len() == 0 - } - /// Borrows the `i`th entry; `None` past the end. pub(crate) fn get(&self, i: usize) -> Option<&GENERAL_NAME> { if i >= self.len() { @@ -1098,10 +1094,6 @@ opaque!( /// `TLS1_3_VERSION` (`openssl/tls1.h`). pub const TLS1_3_VERSION: u16 = 0x0304; -/// `X509_V_OK` (`openssl/x509.h`). -pub const X509_V_OK: c_long = 0; -/// `SSL_SESS_CACHE_CLIENT` (`openssl/ssl.h`). -pub const SSL_SESS_CACHE_CLIENT: c_int = 1; unsafe extern "C" { pub safe fn TLS_method() -> *const SSL_METHOD; diff --git a/src/bun_alloc/lib.rs b/src/bun_alloc/lib.rs index d99683419c75..b8b43c687345 100644 --- a/src/bun_alloc/lib.rs +++ b/src/bun_alloc/lib.rs @@ -592,13 +592,6 @@ impl Default for Mutex { #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct AllocError; -impl AllocError { - #[inline] - pub const fn name(self) -> &'static str { - "OutOfMemory" - } -} - impl core::fmt::Display for AllocError { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { f.write_str("OutOfMemory") @@ -698,13 +691,6 @@ pub unsafe fn realloc_raw( Ok(new_ptr.cast::()) } -/// `mi_usable_size` — actual allocated size for a mimalloc-owned ptr. -#[inline] -pub fn usable_size(ptr: *const u8) -> usize { - // SAFETY: `mi_usable_size` is null-safe (returns 0). - unsafe { mimalloc::mi_usable_size(ptr.cast()) } -} - // ────────────────────────────────────────────────────────────────────────── // Symbols hoisted DOWN into T0 so higher tiers can re-import without cycles. // ────────────────────────────────────────────────────────────────────────── @@ -1453,7 +1439,7 @@ macro_rules! bss_singleton { /// Heap-allocate a fresh `T` via mimalloc and run its in-place `init_at` initializer. /// -/// Shared body of the `BSSList`/`BSSStringList`/`BSSMapInner` `init()` shims. +/// Shared body of the `BSSStringList`/`BSSMapInner` `init()` shims. /// The once-guard is the *caller's* responsibility; use the `bss_*!` macros /// for the canonical per-monomorphization singleton. #[doc(hidden)] // Public only for the `bss_singleton!` macro expansion in dependent crates. @@ -2020,9 +2006,7 @@ impl BSSList { // Rust cannot define generic statics, so the per-monomorphization storage is // emitted at the *declare site* via `bss_list! { name: T, N }` (see macro // below), which owns a `SyncUnsafeCell>` + `Once` and - // calls `init_at` on first access. `init()` is kept for callers that manage - // their own once-guard (e.g. `dir_info::hash_map_instance`); it heap-allocs - // a fresh instance each call. + // calls `init_at` on first access. /// In-place field initialization into demand-zero storage. /// @@ -2048,13 +2032,6 @@ impl BSSList { } } - /// Heap-allocate and initialize a fresh instance. The once-guard is the - /// *caller's* responsibility — use `bss_list!` for - /// the canonical per-monomorphization singleton. - pub fn init() -> NonNull { - bss_heap_init(Self::init_at) - } - // Singleton teardown belongs to the `bss_list!` singleton wrapper; // Drop only frees the heap-allocated head chain. @@ -2066,7 +2043,7 @@ impl BSSList { &mut self, ) -> core::result::Result<*mut MaybeUninit, AllocError> { self.used += 1; - // SAFETY: head is always non-null after init() (points at self.tail or heap block). + // SAFETY: head is always non-null after init_at() (points at self.tail or heap block). let mut head_ptr = self.head.unwrap(); // Check capacity first, allocate the new block if // needed, then reserve exactly one slot. Safe under `self.mutex`. diff --git a/src/bun_core/bounded_array.rs b/src/bun_core/bounded_array.rs index d05eb3d47774..446625e26586 100644 --- a/src/bun_core/bounded_array.rs +++ b/src/bun_core/bounded_array.rs @@ -125,14 +125,6 @@ impl BoundedArrayAligned { // If a non-`Copy` caller // appears, add a `from_slice_clone` or use `ptr::copy_nonoverlapping`. - /// Return the element at index `i` of the slice. - pub fn get(&self, i: usize) -> T - where - T: Copy, - { - self.const_slice()[i] - } - /// Check that the slice can hold at least `additional_count` items. pub(crate) fn ensure_unused_capacity( &self, diff --git a/src/bun_core/fmt.rs b/src/bun_core/fmt.rs index 381ba04fa6c8..93c646200ed4 100644 --- a/src/bun_core/fmt.rs +++ b/src/bun_core/fmt.rs @@ -3354,14 +3354,6 @@ impl OutOfRangeValue for i64 { "i64" } } -impl OutOfRangeValue for i32 { - fn write_received(&self, f: &mut Formatter<'_>) -> fmt::Result { - write!(f, " Received {}", self) - } - fn type_name() -> &'static str { - "i32" - } -} impl<'a> OutOfRangeValue for &'a [u8] { fn write_received(&self, f: &mut Formatter<'_>) -> fmt::Result { write!(f, " Received {}", bstr::BStr::new(self)) @@ -3370,15 +3362,6 @@ impl<'a> OutOfRangeValue for &'a [u8] { "[]const u8" } } -// MOVE_DOWN: bun_core::String → bun_alloc (T0). Re-import from there. -impl OutOfRangeValue for bun_alloc::String { - fn write_received(&self, f: &mut Formatter<'_>) -> fmt::Result { - write!(f, " Received {}", self) - } - fn type_name() -> &'static str { - "bun.String" - } -} pub struct NewOutOfRangeFormatter<'a, T: OutOfRangeValue> { pub value: T, diff --git a/src/bun_core/string/immutable.rs b/src/bun_core/string/immutable.rs index c3df7ef4c337..eaf71d156687 100644 --- a/src/bun_core/string/immutable.rs +++ b/src/bun_core/string/immutable.rs @@ -639,13 +639,6 @@ impl<'a> SplitIterator<'a> { Some(&self.buffer[start..end]) } - - /// Returns a slice of the remaining bytes. Does not affect iterator state. - pub fn rest(&self) -> &'a [u8] { - let end = self.buffer.len(); - let start = self.index.unwrap_or(end); - &self.buffer[start..end] - } } impl<'a> Iterator for SplitIterator<'a> { diff --git a/src/bun_core/string/mod.rs b/src/bun_core/string/mod.rs index 2e7a65b21b08..2eae4e7d1ea8 100644 --- a/src/bun_core/string/mod.rs +++ b/src/bun_core/string/mod.rs @@ -1835,17 +1835,6 @@ impl SliceWithUnderlyingString { } } - /// `fromUTF8` — wrap a borrowed UTF-8 slice (caller keeps it alive). - #[inline] - pub fn from_utf8(utf8: &[u8]) -> SliceWithUnderlyingString { - SliceWithUnderlyingString { - utf8: ZigStringSlice::from_utf8_never_free(utf8), - underlying: String::DEAD, - #[cfg(debug_assertions)] - did_report_extra_memory_debug: false, - } - } - /// `slice` — the UTF-8 byte view. #[inline] pub fn slice(&self) -> &[u8] { diff --git a/src/bun_core/string/write.rs b/src/bun_core/string/write.rs index df8d80418c42..5126b1694bff 100644 --- a/src/bun_core/string/write.rs +++ b/src/bun_core/string/write.rs @@ -11,7 +11,4 @@ //! (`FixedBufferStream`, `BufWriter`, `FmtAdapter`, `DiscardingWriter`) on top, //! so the existing `bun_io::Write` importers are unaffected. -/// `Result` over `core::fmt::Error` so `?` composes everywhere. -pub type Result = core::result::Result; - pub use crate::io::{IntLe, Write}; diff --git a/src/bun_core/windows_sys.rs b/src/bun_core/windows_sys.rs index cac8de64e056..cfca2cae090b 100644 --- a/src/bun_core/windows_sys.rs +++ b/src/bun_core/windows_sys.rs @@ -42,7 +42,7 @@ pub fn GetStdHandle(std_handle: DWORD) -> Option { // `crate::windows_sys::*` path used by callers. // ────────────────────────────────────────────────────────────────────────── pub use bun_windows_sys::{ - CURDIR, Curdir, PEB, PebView, ProcessParameters, RTL_USER_PROCESS_PARAMETERS, TEB, peb, teb, + CURDIR, PEB, ProcessParameters, RTL_USER_PROCESS_PARAMETERS, TEB, peb, teb, }; // SAFETY: nested `i16`/`u16` POD; all-zero is the documented pre-call state diff --git a/src/cares_sys/c_ares.rs b/src/cares_sys/c_ares.rs index 58390891bd72..09e53da5fee0 100644 --- a/src/cares_sys/c_ares.rs +++ b/src/cares_sys/c_ares.rs @@ -659,12 +659,6 @@ pub struct AddrInfo_hints { // SAFETY: four `c_int` fields; all-zero is a valid hints value (S021). unsafe impl bun_core::ffi::Zeroable for AddrInfo_hints {} -impl AddrInfo_hints { - pub fn is_empty(&self) -> bool { - self.ai_flags == 0 && self.ai_family == 0 && self.ai_socktype == 0 && self.ai_protocol == 0 - } -} - #[derive(Copy, Clone, Default)] pub struct ChannelOptions { pub timeout: Option, diff --git a/src/clap/error.rs b/src/clap/error.rs index 42569187ccae..3bab9a99ffad 100644 --- a/src/clap/error.rs +++ b/src/clap/error.rs @@ -6,8 +6,6 @@ pub enum Error { MissingValue, #[error("InvalidArgument")] InvalidArgument, - #[error("WriteFailed")] - WriteFailed, } impl Error { @@ -17,7 +15,6 @@ impl Error { Self::DoesntTakeValue => "DoesntTakeValue", Self::MissingValue => "MissingValue", Self::InvalidArgument => "InvalidArgument", - Self::WriteFailed => "WriteFailed", } } } @@ -28,12 +25,6 @@ impl bun_core::output::ErrName for Error { } } -impl From for Error { - fn from(_: core::fmt::Error) -> Self { - Self::WriteFailed - } -} - impl From for Error { fn from(e: crate::streaming::ArgError) -> Self { match e { diff --git a/src/clap/lib.rs b/src/clap/lib.rs index 9e1f9bc8d545..87559b1817f7 100644 --- a/src/clap/lib.rs +++ b/src/clap/lib.rs @@ -334,11 +334,6 @@ impl Diagnostic { crate::Error::InvalidArgument => { bun_core::pretty_errorln!("error: Invalid Argument '{}'", name) } - _ => bun_core::pretty_errorln!( - "error: {} while parsing argument '{}'", - err, - name - ), } bun_core::Output::flush(); Ok(()) diff --git a/src/codegen/generate-js2native.ts b/src/codegen/generate-js2native.ts index ccc9ce85d83d..abbcd8243d79 100644 --- a/src/codegen/generate-js2native.ts +++ b/src/codegen/generate-js2native.ts @@ -56,7 +56,6 @@ const rustIdentifierPaths: Record = { "collections/linear_fifo.rs": "collections/linear_fifo.rs", "crash_handler.rs": "crash_handler/crash_handler.rs", "css_internals.rs": "css_jsc/css_internals.rs", - "dependency.rs": "install/dependency.rs", "escapeRegExp.rs": "string/escapeRegExp.rs", "event_loop.rs": "jsc/event_loop.rs", "ffi.rs": "runtime/ffi/ffi.rs", diff --git a/src/codegen/generate-unified-source-bundles.rb b/src/codegen/generate-unified-source-bundles.rb deleted file mode 100644 index 505654acef84..000000000000 --- a/src/codegen/generate-unified-source-bundles.rb +++ /dev/null @@ -1,392 +0,0 @@ -# Copyright (C) 2017 Apple Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS -# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -# THE POSSIBILITY OF SUCH DAMAGE. - -require 'digest' -require 'fileutils' -require 'pathname' -require 'getoptlong' - -SCRIPT_NAME = File.basename($0) -COMMENT_REGEXP = /\/\// - -def usage(message) - if message - puts "Error: #{message}" - puts - end - - puts "usage: #{SCRIPT_NAME} [options] ..." - puts " may be separate arguments or one semicolon separated string" - puts "--help (-h) Print this message" - puts "--verbose (-v) Adds extra logging to stderr." - puts - puts "Required arguments:" - puts "--source-tree-path (-s) Path to the root of the source directory." - puts "--derived-sources-path (-d) Path to the directory where the unified source files should be placed." - puts - puts "Optional arguments:" - puts "--print-bundled-sources Print bundled sources rather than generating sources" - puts "--print-all-sources Print all sources rather than generating sources" - puts "--generate-xcfilelists Generate .xcfilelist files" - puts "--input-xcfilelist-path Path of the generated input .xcfilelist file" - puts "--output-xcfilelist-path Path of the generated output .xcfilelist file" - puts - puts "Generation options:" - puts "--max-cpp-bundle-count Use global sequential numbers for cpp bundle filenames and set the limit on the number" - puts "--max-c-bundle-count Use global sequential numbers for c bundle filenames and set the limit on the number" - puts "--max-obj-c-bundle-count Use global sequential numbers for Obj-C bundle filenames and set the limit on the number" - puts "--max-bundle-size The number of files to merge into a single bundle" - puts "--dense-bundle-filter Densely bundle files matching the given path glob" - exit 1 -end - -MAX_DENSE_BUNDLE_SIZE = 64 -$derivedSourcesPath = nil -$unifiedSourceOutputPath = nil -$sourceTreePath = nil -$verbose = false -$mode = :GenerateBundles -$inputXCFilelistPath = nil -$outputXCFilelistPath = nil -$maxCppBundleCount = nil -$maxCBundleCount = nil -$maxObjCBundleCount = nil -$maxBundleSize = 8 -$denseBundleFilters = [] -$bundleFilenamePrefix = '' - -def log(text) - $stderr.puts text if $verbose -end - -GetoptLong.new(['--help', '-h', GetoptLong::NO_ARGUMENT], - ['--verbose', '-v', GetoptLong::NO_ARGUMENT], - ['--derived-sources-path', '-d', GetoptLong::REQUIRED_ARGUMENT], - ['--source-tree-path', '-s', GetoptLong::REQUIRED_ARGUMENT], - ['--print-bundled-sources', GetoptLong::NO_ARGUMENT], - ['--print-all-sources', GetoptLong::NO_ARGUMENT], - ['--generate-xcfilelists', GetoptLong::NO_ARGUMENT], - ['--input-xcfilelist-path', GetoptLong::REQUIRED_ARGUMENT], - ['--output-xcfilelist-path', GetoptLong::REQUIRED_ARGUMENT], - ['--max-cpp-bundle-count', GetoptLong::REQUIRED_ARGUMENT], - ['--max-c-bundle-count', GetoptLong::REQUIRED_ARGUMENT], - ['--max-obj-c-bundle-count', GetoptLong::REQUIRED_ARGUMENT], - ['--max-bundle-size', GetoptLong::REQUIRED_ARGUMENT], - ['--dense-bundle-filter', GetoptLong::REQUIRED_ARGUMENT], - ['--bundle-filename-prefix', GetoptLong::REQUIRED_ARGUMENT]).each { - | opt, arg | - case opt - when '--help' - usage(nil) - when '--verbose' - $verbose = true - when '--derived-sources-path' - $derivedSourcesPath = Pathname.new(arg) - when '--source-tree-path' - $sourceTreePath = Pathname.new(arg) - usage("Source tree #{arg} does not exist.") if !$sourceTreePath.exist? - when '--print-bundled-sources' - $mode = :PrintBundledSources - when '--print-all-sources' - $mode = :PrintAllSources - when '--generate-xcfilelists' - $mode = :GenerateXCFilelists - when '--input-xcfilelist-path' - $inputXCFilelistPath = arg - when '--output-xcfilelist-path' - $outputXCFilelistPath = arg - when '--max-cpp-bundle-count' - $maxCppBundleCount = arg.to_i - when '--max-c-bundle-count' - $maxCBundleCount = arg.to_i - when '--max-obj-c-bundle-count' - $maxObjCBundleCount = arg.to_i - when '--max-bundle-size' - $maxBundleSize = arg.to_i - when '--dense-bundle-filter' - $denseBundleFilters.push(arg) - when '--bundle-filename-prefix' - $bundleFilenamePrefix = arg - end -} - -$unifiedSourceOutputPath = $derivedSourcesPath + Pathname.new("unified-sources") -FileUtils.mkpath($unifiedSourceOutputPath) if !$unifiedSourceOutputPath.exist? && $mode != :GenerateXCFilelists - -usage("--derived-sources-path must be specified.") if !$unifiedSourceOutputPath -usage("--source-tree-path must be specified.") if !$sourceTreePath -log("Putting unified sources in #{$unifiedSourceOutputPath}") - -usage("At least one source list file must be specified.") if ARGV.length == 0 -# Even though CMake will only pass us a single semicolon separated arguemnts, we separate all the arguments for simplicity. -sourceListFiles = ARGV.to_a.map { | sourceFileList | sourceFileList.split(";") }.flatten -log("Source files: #{sourceListFiles}") -$generatedSources = [] -$inputSources = [] -$outputSources = [] - -class SourceFile - attr_reader :unifiable, :fileIndex, :path - def initialize(file, fileIndex) - @unifiable = true - @fileIndex = fileIndex - - attributeStart = file =~ /@/ - if attributeStart - # We want to make sure we skip the first @ so split works correctly - attributesText = file[(attributeStart + 1)..file.length] - attributesText.split(/\s*@/).each { - | attribute | - case attribute.strip - when "no-unify" - @unifiable = false - else - raise "unknown attribute: #{attribute}" - end - } - file = file[0..(attributeStart-1)] - end - - @path = Pathname.new(file.strip) - end - - def <=>(other) - return @path.dirname <=> other.path.dirname if @path.dirname != other.path.dirname - return @path.basename <=> other.path.basename if @fileIndex == other.fileIndex - @fileIndex <=> other.fileIndex - end - - def derived? - return @derived if @derived != nil - @derived = !($sourceTreePath + self.path).exist? - end - - def to_s - if $mode == :GenerateXCFilelists - if derived? - ($derivedSourcesPath + @path).to_s - else - '$(SRCROOT)/' + @path.to_s - end - elsif $mode == :GenerateBundles || !derived? - @path.to_s - else - ($derivedSourcesPath + @path).to_s - end - end -end - -class BundleManager - attr_reader :bundleCount, :extension, :fileCount, :currentBundleText, :maxCount, :extraFiles - - def initialize(extension, max) - @extension = extension - @fileCount = 0 - @bundleCount = 0 - @currentBundleText = "" - @maxCount = max - @extraFiles = [] - @currentDirectory = nil - @lastBundlingPrefix = nil - end - - def writeFile(file, text) - bundleFile = $unifiedSourceOutputPath + file - if $mode == :GenerateXCFilelists - $outputSources << bundleFile - return - end - if (!bundleFile.exist? || IO::read(bundleFile) != @currentBundleText) - log("Writing bundle #{bundleFile} with: \n#{@currentBundleText}") - IO::write(bundleFile, @currentBundleText) - end - end - - def bundleFileName() - id = - if @maxCount - @bundleCount.to_s - else - # The dash makes the filenames more clear when using a hash. - hash = Digest::SHA1.hexdigest(@currentDirectory.to_s)[0..7] - "-#{hash}-#{@bundleCount}" - end - @extension == "cpp" ? "#{$bundleFilenamePrefix}UnifiedSource#{id}.#{extension}" : "#{$bundleFilenamePrefix}UnifiedSource#{id}-#{extension}.#{extension}" - end - - def flush - @bundleCount += 1 - bundleFile = bundleFileName - $generatedSources << $unifiedSourceOutputPath + bundleFile - @extraFiles << bundleFile if @maxCount and @bundleCount > @maxCount - - writeFile(bundleFile, @currentBundleText) - @currentBundleText = "" - @fileCount = 0 - end - - def flushToMax - raise if !@maxCount - while @bundleCount < @maxCount - flush - end - end - - def addFile(sourceFile) - path = sourceFile.path - raise "wrong extension: #{path.extname} expected #{@extension}" unless path.extname == ".#{@extension}" - bundlePrefix, bundleSize = BundlePrefixAndSizeForPath(path) - if (@lastBundlingPrefix != bundlePrefix) - unless @fileCount.zero? - log("Flushing because new top level directory; old: #{@currentDirectory}, new: #{path.dirname}") - flush - end - @lastBundlingPrefix = bundlePrefix - @currentDirectory = path.dirname - @bundleCount = 0 unless @maxCount - end - if @fileCount >= bundleSize - log("Flushing because new bundle is full (#{@fileCount} sources)") - flush - end - @currentBundleText += "#include \"#{sourceFile}\"\n" - @fileCount += 1 - end -end - -def BundlePrefixAndSizeForPath(path) - topLevelDirectory = TopLevelDirectoryForPath(path.dirname) - $denseBundleFilters.each { |filter| - if path.fnmatch(filter) - return filter, MAX_DENSE_BUNDLE_SIZE - end - } - return topLevelDirectory, $maxBundleSize -end - -def TopLevelDirectoryForPath(path) - if !path - return nil - end - while path.dirname != path.dirname.dirname - path = path.dirname - end - return path -end - -def ProcessFileForUnifiedSourceGeneration(sourceFile) - path = sourceFile.path - $inputSources << sourceFile.to_s - - bundle = $bundleManagers[path.extname] - if !bundle - log("No bundle for #{path.extname} files, building #{path} standalone") - $generatedSources << sourceFile - elsif !sourceFile.unifiable - log("Not allowed to unify #{path}, building standalone") - $generatedSources << sourceFile - else - bundle.addFile(sourceFile) - end -end - -$bundleManagers = { - ".cpp" => BundleManager.new("cpp", $maxCppBundleCount), - ".c" => BundleManager.new("c", $maxCBundleCount), - ".mm" => BundleManager.new("mm", $maxObjCBundleCount) -} - -seen = {} -sourceFiles = [] - -sourceListFiles.each_with_index { - | path, sourceFileIndex | - log("Reading #{path}") - result = [] - File.read(path).lines.each { - | line | - commentStart = line =~ COMMENT_REGEXP - log("Before: #{line}") - if commentStart != nil - line = line.slice(0, commentStart) - log("After: #{line}") - end - line.strip! - - next if line.empty? - - if seen[line] - next if $mode == :GenerateXCFilelists - raise "duplicate line: #{line} in #{path}" - end - seen[line] = true - result << SourceFile.new(line, sourceFileIndex) - } - - log("Found #{result.length} source files in #{path}") - sourceFiles += result -} - -log("Found sources: #{sourceFiles.sort}") - -sourceFiles.sort.each { - | sourceFile | - case $mode - when :GenerateBundles, :GenerateXCFilelists - ProcessFileForUnifiedSourceGeneration(sourceFile) - when :PrintAllSources - $generatedSources << sourceFile - when :PrintBundledSources - $generatedSources << sourceFile if $bundleManagers[sourceFile.path.extname] && sourceFile.unifiable - end -} - -if $mode != :PrintAllSources - $bundleManagers.each_value { - | manager | - manager.flush unless manager.fileCount.zero? - - maxCount = manager.maxCount - next if !maxCount # It is nil in CMake since maxCount limitation does not exist. - - manager.flushToMax - - unless manager.extraFiles.empty? - extension = manager.extension - bundleCount = manager.bundleCount - filesToAdd = manager.extraFiles.join(", ") - raise "number of bundles for #{extension} sources, #{bundleCount}, exceeded limit, #{maxCount}. Please add #{filesToAdd} to Xcode then update UnifiedSource#{extension.capitalize}FileCount" - end - } -end - -if $mode == :GenerateXCFilelists - IO::write($inputXCFilelistPath, $inputSources.sort.join("\n") + "\n") if $inputXCFilelistPath - IO::write($outputXCFilelistPath, $outputSources.sort.join("\n") + "\n") if $outputXCFilelistPath -end - -# We use stdout to report our unified source list to CMake. -# Add trailing semicolon and avoid a trailing newline for CMake's sake. - -log($generatedSources.join(";") + ";") -print($generatedSources.join(";") + ";") diff --git a/src/csrf/lib.rs b/src/csrf/lib.rs index 40aa39a392ec..0ce67a069179 100644 --- a/src/csrf/lib.rs +++ b/src/csrf/lib.rs @@ -18,10 +18,7 @@ pub const DEFAULT_ALGORITHM: Algorithm = Algorithm::Sha256; /// Error types for CSRF operations #[derive(strum::IntoStaticStr, Debug, Clone, Copy, PartialEq, Eq)] pub enum Error { - InvalidToken, - ExpiredToken, TokenCreationFailed, - DecodingFailed, } bun_core::impl_tag_error!(Error); diff --git a/src/css/css_parser.rs b/src/css/css_parser.rs index b2cfade3f66e..dca631f6fa00 100644 --- a/src/css/css_parser.rs +++ b/src/css/css_parser.rs @@ -625,12 +625,6 @@ pub trait QualifiedRuleParser { #[derive(Default, Clone, Copy, crate::DeepClone)] pub struct DefaultAtRule; -impl DefaultAtRule { - pub fn to_css(self, dest: &mut Printer) -> Result<(), PrintErr> { - dest.new_error(PrinterErrorKind::fmt_error, None) - } -} - /// Same as `AtRuleParser` but modified to provide parser options. /// Also added: `on_import_rule` to handle `@import` rules. pub trait CustomAtRuleParser { @@ -5232,11 +5226,6 @@ pub enum TokenKind { pub use crate::Token; impl Token { - pub fn eql(lhs: &Token, rhs: &Token) -> bool { - // TODO: derive PartialEq once payload lifetimes settle. - generic::implement_eql(lhs, rhs) - } - /// Return whether this token represents a parse error. pub(crate) fn is_parse_error(&self) -> bool { matches!( @@ -5481,22 +5470,16 @@ pub use bun_io::Write as WriteAll; // Num/Dimension data layouts hoisted at crate root (lib.rs). pub use crate::{Dimension, Num}; -// Num/Dimension eql/hash gated until generics::CssEql/CssHash blanket impls +// Num/Dimension hash gated until generics::CssHash blanket impls // cover the float/slice payloads. impl Num { - pub fn eql(lhs: &Num, rhs: &Num) -> bool { - generic::implement_eql(lhs, rhs) - } pub(crate) fn hash(&self, hasher: &mut bun_wyhash::Wyhash) { generic::implement_hash(self, hasher) } } impl Dimension { - pub fn eql(lhs: &Self, rhs: &Self) -> bool { - generic::implement_eql(lhs, rhs) - } pub(crate) fn hash(&self, hasher: &mut bun_wyhash::Wyhash) { generic::implement_hash(self, hasher) } diff --git a/src/css/generics.rs b/src/css/generics.rs index 956273c7312d..a4a0e08f618b 100644 --- a/src/css/generics.rs +++ b/src/css/generics.rs @@ -190,11 +190,6 @@ pub trait CssEql { /// derive into scope (same-name idiom, cf. `Clone`). pub use bun_css_derive::CssEql; -#[inline] -pub fn implement_eql(this: &T, other: &T) -> bool { - this.eql(other) -} - #[inline] pub(crate) fn eql(lhs: &T, rhs: &T) -> bool { lhs.eql(rhs) @@ -1205,11 +1200,6 @@ pub fn parse_with_options( T::parse_with_options(input, options) } -#[inline] -pub fn parse(input: &mut Parser) -> CssResult { - T::parse(input) -} - // ── container / primitive Parse impls ──────────────────────────────────────── impl Parse for Option { diff --git a/src/css/lib.rs b/src/css/lib.rs index 771ffc9a3999..2f7baff7302b 100644 --- a/src/css/lib.rs +++ b/src/css/lib.rs @@ -340,7 +340,7 @@ pub struct Dimension { } /// CSS lexer token. Data-only definition hoisted out of `css_parser.rs`; the -/// `to_css*`/`eql`/`hash` impls stay in `css_parser.rs` since they depend on +/// `to_css*`/`hash` impls stay in `css_parser.rs` since they depend on /// `serializer::*` and `generics`. // Every `&'static [u8]` payload actually borrows the parser arena/source text and // must not outlive the arena; `&'static` is the crate-wide placeholder until the diff --git a/src/css/properties/custom.rs b/src/css/properties/custom.rs index 61aeedf3497a..3f7165b959f4 100644 --- a/src/css/properties/custom.rs +++ b/src/css/properties/custom.rs @@ -1,6 +1,6 @@ //! CSS custom properties / `var()` / `env()` / unparsed token lists. // -// `TokenList::{parse, parse_into, parse_with_options, to_css, to_css_raw}`, +// `TokenList::{parse, parse_into, to_css, to_css_raw}`, // `UnresolvedColor::{parse, to_css}`, `Variable::{parse, to_css}`, // `EnvironmentVariable::{parse, parse_nested, to_css}`, // `EnvironmentVariableName::{parse, to_css}`, `Function::to_css`, @@ -162,7 +162,7 @@ mod ext { // ─── Token protocol impls ────────────────────────────────────────────────── // `Token` / `Num` / `Dimension` are defined data-only at crate root (lib.rs); -// their `eql`/`hash` bodies in css_parser.rs forward to `generic::implement_*` +// their `hash` bodies in css_parser.rs forward to `generic::implement_*` // which bound on these traits — provide them here so the cycle closes and // `#[derive(CssEql/CssHash/DeepClone)]` on `TokenOrValue` resolves the // `Token(Token)` arm. Hand-written (not derived) because `Token` carries @@ -480,10 +480,6 @@ impl TokenList { Ok(TokenList { v: tokens }) } - pub fn parse_with_options(input: &mut Parser, options: &ParserOptions) -> Result { - Self::parse(input, options, 0) - } - pub(crate) fn parse_raw( input: &mut Parser, tokens: &mut Vec, diff --git a/src/css/rules/mod.rs b/src/css/rules/mod.rs index 6cd0b547bad4..d3bacb092d95 100644 --- a/src/css/rules/mod.rs +++ b/src/css/rules/mod.rs @@ -58,10 +58,9 @@ macro_rules! css_rule_variants { match self { $( CssRule::$Variant(x) => x.to_css(dest), )+ CssRule::Unknown(x) => x.to_css(dest), - // The only concrete `R` is `DefaultAtRule` (whose `to_css` - // errors unconditionally), so erroring here is correct for - // every `R` that is actually instantiated. If another `R` - // is ever added, thread a `ToCss`-style bound + // The only concrete `R` is `DefaultAtRule`, so erroring here + // is correct for every `R` that is actually instantiated. If + // another `R` is ever added, thread a `ToCss`-style bound // (or per-`R` vtable) so `Custom(x)` dispatches to // `x.to_css(dest)` and only the error path maps through // `add_fmt_error()`; that bound cascades through every nested diff --git a/src/css/values/angle.rs b/src/css/values/angle.rs index 21f37e3fdaa8..935ead24135f 100644 --- a/src/css/values/angle.rs +++ b/src/css/values/angle.rs @@ -178,10 +178,6 @@ impl Angle { Some(Angle::Deg(self.to_degrees() + rhs.to_degrees())) } - pub(crate) fn eql(self, rhs: Angle) -> bool { - self.to_degrees() == rhs.to_degrees() - } - pub(crate) fn mul_f32(self, other: f32) -> Angle { // return Angle.op(&this, &other, Angle.mulF32); match self { diff --git a/src/css/values/calc.rs b/src/css/values/calc.rs index a429d0d7381e..9ad34f6ea4f0 100644 --- a/src/css/values/calc.rs +++ b/src/css/values/calc.rs @@ -141,7 +141,6 @@ pub trait CalcValue: fn into_calc(self) -> Calc; /// Convert a `Calc` into `Self` if representable. fn from_calc(c: Calc, input: &mut css::Parser) -> CssResult; - fn eql(&self, other: &Self) -> bool; } impl Clone for Calc { @@ -152,8 +151,7 @@ impl Clone for Calc { // Structural equality decoupled from `CalcValue` so `derive(PartialEq)` on // `Length` / `DimensionPercentage` consumers can compare through -// `Box>` without pulling in the full behavior bound. `Calc::eql` -// (below) keeps its `V: CalcValue` bound for callers that already have it. +// `Box>` without pulling in the full behavior bound. impl PartialEq for Calc { fn eq(&self, other: &Self) -> bool { match (self, other) { @@ -217,38 +215,6 @@ impl Calc { // Cleanup is handled by Drop on Box/Box>/ // Box>. No explicit Drop impl needed. - - pub fn eql(&self, other: &Self) -> bool - where - V: CalcValue, - { - match (self, other) { - (Calc::Value(a), Calc::Value(b)) => a.eql(b), - (Calc::Number(a), Calc::Number(b)) => *a == *b, - ( - Calc::Sum { - left: al, - right: ar, - }, - Calc::Sum { - left: bl, - right: br, - }, - ) => al.eql(bl) && ar.eql(br), - ( - Calc::Product { - number: an, - expression: ae, - }, - Calc::Product { - number: bn, - expression: be, - }, - ) => an == bn && ae.eql(be), - (Calc::Function(a), Calc::Function(b)) => a.eql(b), - _ => false, - } - } } // `PartialEq for Calc` is provided above with the looser `V: PartialEq + @@ -1204,8 +1170,8 @@ pub enum MathFunction { impl PartialEq for MathFunction { fn eq(&self, other: &Self) -> bool { - // Mirrors `MathFunction::eql` but bounds only on `V: PartialEq` so - // `Calc: PartialEq` (above) closes without `CalcValue`. + // Bounds only on `V: PartialEq` so `Calc: PartialEq` (above) + // closes without `CalcValue`. match (self, other) { (MathFunction::Calc(a), MathFunction::Calc(b)) => a == b, (MathFunction::Min(a), MathFunction::Min(b)) => a == b, @@ -1262,78 +1228,7 @@ impl PartialEq for MathFunction { } } -fn eql_calc_list(a: &[Calc], b: &[Calc]) -> bool { - if a.len() != b.len() { - return false; - } - for (l, r) in a.iter().zip(b.iter()) { - if !l.eql(r) { - return false; - } - } - true -} - impl MathFunction { - pub fn eql(&self, other: &Self) -> bool - where - V: CalcValue, - { - match (self, other) { - (MathFunction::Calc(a), MathFunction::Calc(b)) => a.eql(b), - (MathFunction::Min(a), MathFunction::Min(b)) => eql_calc_list(a, b), - (MathFunction::Max(a), MathFunction::Max(b)) => eql_calc_list(a, b), - ( - MathFunction::Clamp { - min: a0, - center: a1, - max: a2, - }, - MathFunction::Clamp { - min: b0, - center: b1, - max: b2, - }, - ) => a0.eql(b0) && a1.eql(b1) && a2.eql(b2), - ( - MathFunction::Round { - strategy: as_, - value: av, - interval: ai, - }, - MathFunction::Round { - strategy: bs, - value: bv, - interval: bi, - }, - ) => as_ == bs && av.eql(bv) && ai.eql(bi), - ( - MathFunction::Rem { - dividend: ad, - divisor: av, - }, - MathFunction::Rem { - dividend: bd, - divisor: bv, - }, - ) => ad.eql(bd) && av.eql(bv), - ( - MathFunction::Mod { - dividend: ad, - divisor: av, - }, - MathFunction::Mod { - dividend: bd, - divisor: bv, - }, - ) => ad.eql(bd) && av.eql(bv), - (MathFunction::Abs(a), MathFunction::Abs(b)) => a.eql(b), - (MathFunction::Sign(a), MathFunction::Sign(b)) => a.eql(b), - (MathFunction::Hypot(a), MathFunction::Hypot(b)) => eql_calc_list(a, b), - _ => false, - } - } - pub(crate) fn deep_clone(&self) -> Self where V: Clone, @@ -1615,10 +1510,6 @@ impl CalcValue for CSSNumber { _ => Err(input.new_custom_error(css::ParserError::invalid_value)), } } - #[inline] - fn eql(&self, other: &Self) -> bool { - *self == *other - } } impl CalcValue for Angle { @@ -1636,10 +1527,6 @@ impl CalcValue for Angle { _ => Err(input.new_custom_error(css::ParserError::invalid_value)), } } - #[inline] - fn eql(&self, other: &Self) -> bool { - Angle::eql(*self, *other) - } } // ───────────────────────────────────────────────────────────────────────────── @@ -1777,10 +1664,6 @@ impl CalcValue for Percentage { _ => Ok(Percentage { v: f32::NAN }), } } - #[inline] - fn eql(&self, other: &Self) -> bool { - Percentage::eql(*self, *other) - } } calc_protocol_forwarders!(Time { @@ -1823,10 +1706,6 @@ impl CalcValue for Time { _ => Err(input.new_custom_error(css::ParserError::invalid_value)), } } - #[inline] - fn eql(&self, other: &Self) -> bool { - Time::eql(*self, *other) - } } calc_protocol_forwarders!(Length { @@ -1864,10 +1743,6 @@ impl CalcValue for Length { fn from_calc(c: Calc, _input: &mut css::Parser) -> CssResult { Ok(Length::Calc(Box::new(c))) } - #[inline] - fn eql(&self, other: &Self) -> bool { - self == other - } } /// `protocol::*` + `CalcValue` impls for the two concrete `DimensionPercentage` @@ -1916,7 +1791,6 @@ macro_rules! dim_pct_protocol { fn from_calc(c: Calc, _input: &mut css::Parser) -> CssResult { Ok(DimensionPercentage::Calc(Box::new(c))) } - #[inline] fn eql(&self, other: &Self) -> bool { self == other } } }; } diff --git a/src/css/values/css_string.rs b/src/css/values/css_string.rs index 960cd50e69cb..4c85544d4bac 100644 --- a/src/css/values/css_string.rs +++ b/src/css/values/css_string.rs @@ -1,5 +1,4 @@ pub use crate::css_parser as css; -pub use css::CssResult as Result; pub use css::PrintErr; pub use css::Printer; @@ -15,11 +14,6 @@ pub type CssString = *const [u8]; pub struct CssStringFns; impl CssStringFns { - pub fn parse(input: &mut css::Parser) -> Result { - // No lifetime laundering: capture the arena slice as a raw pointer. - input.expect_string().map(std::ptr::from_ref::<[u8]>) - } - pub fn to_css(this: &CssString, dest: &mut Printer) -> core::result::Result<(), PrintErr> { // SAFETY: per the `CssString` invariant above, the pointee borrows the // parser arena which outlives the `Printer` it is being written to. diff --git a/src/css/values/time.rs b/src/css/values/time.rs index ce14b1f814f0..bba24ac98738 100644 --- a/src/css/values/time.rs +++ b/src/css/values/time.rs @@ -28,13 +28,6 @@ pub enum Time { impl Time { // css.implementDeepClone / css.implementEql / css.implementHash — provided // by `#[derive(DeepClone, CssEql, CssHash)]` above (POD f32 payload). - // Kept as an inherent assoc fn for `protocol::CalcValue` callers that - // forward via UFCS (`Time::eql(a, b)`) — does not conflict with the - // derived trait method (that one has a `&self` receiver). - #[inline] - pub fn eql(lhs: Self, rhs: Self) -> bool { - lhs == rhs - } pub fn parse(input: &mut css::Parser) -> Result