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: 2 additions & 0 deletions .github/workflows/source-lints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ on:
- "src/**/*.rs"
- "src/**/*.classes.ts"
- "src/codegen/class-definitions.ts"
- "src/js/builtins.d.ts"
- "src/jsc/bindings/**"
- "packages/bun-types/redis.d.ts"
- "scripts/build/**"
Expand All @@ -33,6 +34,7 @@ on:
- "src/**/*.rs"
- "src/**/*.classes.ts"
- "src/codegen/class-definitions.ts"
- "src/js/builtins.d.ts"
- "src/jsc/bindings/**"
- "packages/bun-types/redis.d.ts"
- "scripts/build/**"
Expand Down
10 changes: 0 additions & 10 deletions src/bun_core/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,6 @@ impl<T> RawSlice<T> {
pub const fn new(s: &[T]) -> Self {
RawSlice(core::ptr::from_ref(s))
}
/// Wrap a raw slice pointer.
///
/// # Safety
/// `p` must either be a (dangling, len 0) empty slice or point to `len`
/// initialized `T` that remain live and stable for the lifetime of every
/// `RawSlice` copied from the result.
#[inline]
pub const unsafe fn from_raw(p: *const [T]) -> Self {
RawSlice(p)
}
#[inline]
pub const fn as_ptr(self) -> *const [T] {
self.0
Expand Down
27 changes: 1 addition & 26 deletions src/bun_core/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ pub unsafe fn bytes_as_slice_mut<T>(bytes: &mut [u8]) -> &mut [T] {
pub struct Unaligned<T: Copy>(T);

impl<T: Copy> Unaligned<T> {
#[inline(always)]
pub const fn new(value: T) -> Self {
Self(value)
}

#[inline(always)]
pub fn get(self) -> T {
// `self` is by-value (already moved into an aligned local), so a plain
Expand Down Expand Up @@ -601,8 +596,7 @@ macro_rules! opaque_extern {
// `bun_threading::Guarded` / `bun_threading::RwLock` directly.
//
// API parity with the previous `parking_lot` aliases: `const fn new(T)`,
// `.lock()` → guard (no `Result`), `.try_lock()` → `Option`, `.get_mut()`,
// `Default`.
// `.lock()` → guard (no `Result`), `.try_lock()` → `Option`, `Default`.

/// Poison-free `std::sync::Mutex<T>` wrapper. See module note above for why
/// this is not `bun_threading::Guarded<T>`.
Expand Down Expand Up @@ -635,13 +629,6 @@ impl<T> Mutex<T> {
Err(std::sync::TryLockError::WouldBlock) => None,
}
}

#[inline]
pub fn get_mut(&mut self) -> &mut T {
self.0
.get_mut()
.unwrap_or_else(std::sync::PoisonError::into_inner)
}
}

impl<T: Default> Default for Mutex<T> {
Expand Down Expand Up @@ -675,13 +662,6 @@ impl<T> RwLock<T> {
.write()
.unwrap_or_else(std::sync::PoisonError::into_inner)
}

#[inline]
pub fn get_mut(&mut self) -> &mut T {
self.0
.get_mut()
.unwrap_or_else(std::sync::PoisonError::into_inner)
}
}

impl<T: Default> Default for RwLock<T> {
Expand Down Expand Up @@ -4922,11 +4902,6 @@ impl Timespec {
const NS_PER_S: i64 = crate::time::NS_PER_S as i64;
const NS_PER_MS: i64 = crate::time::NS_PER_MS as i64;

#[inline]
pub const fn new(sec: i64, nsec: i64) -> Self {
Self { sec, nsec }
}

#[inline]
pub fn eql(&self, other: &Timespec) -> bool {
self == other
Expand Down
5 changes: 1 addition & 4 deletions src/bundler/bundle_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4541,7 +4541,6 @@ pub mod bv2_impl {
fd,
&load.path,
bun_wyhash::hash(load.path.as_ref()) as u32,
bun_watcher::Loader(code.loader as u8),
bun_sys::Fd::INVALID,
None,
),
Expand Down Expand Up @@ -6967,12 +6966,11 @@ pub mod bv2_impl {
if this.bun_watcher.is_some() {
if parse_result.watcher_data.fd != bun_sys::Fd::INVALID {
let source_index = parse_result.value.source_index();
// borrowck — read source path/loader before
// borrowck — read the source path before
// `should_add_watcher(&self)` so the column borrow is released.
let source_path = this.graph.input_files.items_source()[source_index as usize]
.path
.text;
let loader = this.graph.input_files.items_loader()[source_index as usize];
if this.should_add_watcher(source_path) {
// const generic `CLONE_FILE_PATH = isWindows`
// matches `cfg!(windows)` at compile time.
Expand All @@ -6983,7 +6981,6 @@ pub mod bv2_impl {
parse_result.watcher_data.fd,
source_path,
bun_wyhash::hash(source_path) as u32,
bun_watcher::Loader(loader as u8),
parse_result.watcher_data.dir_fd,
None,
);
Expand Down
131 changes: 0 additions & 131 deletions src/js/builtins.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,6 @@ declare function $argumentCount(): number;
/** array.push(item) */
declare function $arrayPush(array: T[], item: T): void;

/**
* gets a property on an object
*/
declare function $getByValWithThis(target: any, receiver: any, propertyKey: string): void;
/** gets the prototype of an object */
declare function $getPrototypeOf(value: any): any;
/**
* Returns the internal Promise state as a small integer:
* `0` = pending, `1` = fulfilled, `2` = rejected.
Expand Down Expand Up @@ -119,23 +113,6 @@ declare function $getInternalField<Fields extends any[], N extends keyof Fields>
number: N,
): Fields[N];
/**
* Use {@link $fulfillPromise} when:
* - Fulfilling with primitive values (numbers, strings, booleans, null, undefined)
* - Fulfilling with plain objects that definitely don't have a then method
* - You're in internal code that has already done the thenable checking
*
* Use {@link $resolvePromise} when:
* - The value might be a promise or thenable
* - You need the full resolution algorithm (self-check, thenable unwrapping)
* - You're implementing user-facing APIs where the resolution value is unknown
*/
declare function $fulfillPromise<T>(promise: Promise<T>, value: NoInfer<T>): void;
/**
* Use {@link $fulfillPromise} when:
* - Fulfilling with primitive values (numbers, strings, booleans, null, undefined)
* - Fulfilling with plain objects that definitely don't have a then method
* - You're in internal code that has already done the thenable checking
*
* Use {@link $resolvePromise} when:
* - The value might be a promise or thenable
* - You need the full resolution algorithm (self-check, thenable unwrapping)
Expand All @@ -148,13 +125,7 @@ declare function $resolvePromise<T>(promise: Promise<T>, value: NoInfer<T>): voi
declare function $rejectPromise(promise: Promise<unknown>, value: unknown): void;

declare function $loadEsmIntoCjs(...args: any[]): TODO;
declare function $getGeneratorInternalField(): TODO;
declare function $getAsyncGeneratorInternalField(): TODO;
declare function $getAbstractModuleRecordInternalField(): TODO;
declare function $getArrayIteratorInternalField(): TODO;
declare function $getStringIteratorInternalField(): TODO;
declare function $getProxyInternalField(): TODO;
declare function $idWithProfile(): TODO;
/**
* True for object-like `JSCell`s. That is, this is roughly equivalent to this
* JS code:
Expand All @@ -172,18 +143,11 @@ declare function $isObject(obj: unknown): obj is object;
declare function $isArray<T>(obj: T): obj is Extract<T, any[]> | Extract<T, readonly any[]>;
declare function $isArray(obj: unknown): obj is any[];
declare function $isCallable(fn: unknown): fn is CallableFunction;
declare function $isConstructor(fn: unknown): fn is { new (...args: any[]): any };
declare function $isJSArray(obj: unknown): obj is any[];
declare function $isProxyObject(obj: unknown): obj is Proxy;
declare function $isDerivedArray(): TODO;
declare function $isGenerator(obj: unknown): obj is Generator<any, any, any>;
declare function $isAsyncGenerator(obj: unknown): obj is AsyncGenerator<any, any, any>;
declare function $isRegExpObject(obj: unknown): obj is RegExp;
declare function $isMap<K, V>(obj: unknown): obj is Map<K, V>;
declare function $isSet<V>(obj: unknown): obj is Set<V>;
declare function $isShadowRealm(obj: unknown): obj is ShadowRealm;
declare function $isStringIterator(obj: unknown): obj is Iterator<string>;
declare function $isArrayIterator(obj: unknown): obj is Iterator<any>;
declare function $isUndefinedOrNull(obj: unknown): obj is null | undefined;
declare function $tailCallForwardArguments(fn: CallableFunction, thisValue: ThisType): any;
/**
Expand Down Expand Up @@ -213,94 +177,20 @@ declare function $putByIdDirectPrivate<T extends Record<`$${K}`, unknown>, K ext
): void;

declare function $putByValDirect(obj: any, key: PropertyKey, value: any): void;
declare function $putByValWithThisSloppy(): TODO;
declare function $putByValWithThisStrict(): TODO;
declare function $putInternalField<Fields extends any[], N extends keyof Fields>(
base: InternalFieldObject<Fields>,
number: N,
value: Fields[N],
): void;
declare function $putGeneratorInternalField(): TODO;
declare function $putAsyncGeneratorInternalField(): TODO;
declare function $putArrayIteratorInternalField(): TODO;
declare function $putStringIteratorInternalField(): TODO;
declare function $superSamplerBegin(): TODO;
declare function $superSamplerEnd(): TODO;
declare function $toNumber(x: any): number;
declare function $toString(x: any): string;
declare function $toPropertyKey(x: any): PropertyKey;
/**
* Often used like
* `$toObject(this, "Class.prototype.method requires that |this| not be null or undefined");`
*/
declare function $toObject(object: any, errorMessage?: string): object;
/**
* ## References
* - [WebKit - `emit_intrinsic_newArrayWithSize`](https://github.com/oven-sh/WebKit/blob/e1a802a2287edfe7f4046a9dd8307c8b59f5d816/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp#L2317)
*/
declare function $newArrayWithSize<T>(size: number): T[];
/**
* Optimized path for creating a new array storing objects with the same homogenous Structure
* as {@link array}.
*
* @param size the initial size of the new array
* @param array the array whose shape we want to copy
*
* @returns a new array
*
* ## References
* - [WebKit - `emit_intrinsic_newArrayWithSpecies`](https://github.com/oven-sh/WebKit/blob/e1a802a2287edfe7f4046a9dd8307c8b59f5d816/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp#L2328)
* - [WebKit - #4909](https://github.com/WebKit/WebKit/pull/4909)
* - [WebKit Bugzilla - Related Issue/Ticket](https://bugs.webkit.org/show_bug.cgi?id=245797)
*/
declare function $newArrayWithSpecies<T>(size: number, array: T[]): T[];
declare function $newPromise(): TODO;
declare function $createPromise(): TODO;
declare const $iterationKindKey: TODO;
declare const $iterationKindValue: TODO;
declare const $iterationKindEntries: TODO;
declare const $MAX_ARRAY_INDEX: number;
declare const $MAX_STRING_LENGTH: number;
declare const $MAX_SAFE_INTEGER: number;
declare const $ModuleFetch: number;
declare const $ModuleTranslate: number;
declare const $ModuleInstantiate: number;
declare const $ModuleSatisfy: number;
declare const $ModuleLink: number;
declare const $ModuleReady: number;
declare const $promiseRejectionReject: TODO;
declare const $promiseRejectionHandle: TODO;
declare const $proxyFieldTarget: TODO;
declare const $proxyFieldHandler: TODO;
declare const $generatorFieldState: TODO;
declare const $generatorFieldNext: TODO;
declare const $generatorFieldThis: TODO;
declare const $generatorFieldFrame: TODO;
declare const $generatorFieldContext: TODO;
declare const $GeneratorResumeModeNormal: TODO;
declare const $GeneratorResumeModeThrow: TODO;
declare const $GeneratorResumeModeReturn: TODO;
declare const $GeneratorStateCompleted: TODO;
declare const $GeneratorStateExecuting: TODO;
declare const $arrayIteratorFieldIndex: TODO;
declare const $arrayIteratorFieldIteratedObject: TODO;
declare const $arrayIteratorFieldKind: TODO;
declare const $mapIteratorFieldMapBucket: TODO;
declare const $setIteratorFieldSetBucket: TODO;
declare const $stringIteratorFieldIndex: TODO;
declare const $stringIteratorFieldIteratedString: TODO;
declare const $asyncGeneratorFieldSuspendReason: TODO;
declare const $asyncGeneratorFieldQueueFirst: TODO;
declare const $asyncGeneratorFieldQueueLast: TODO;
declare const $AsyncGeneratorStateCompleted: TODO;
declare const $AsyncGeneratorStateExecuting: TODO;
declare const $AsyncGeneratorStateAwaitingReturn: TODO;
declare const $AsyncGeneratorStateSuspendedStart: TODO;
declare const $AsyncGeneratorStateSuspendedYield: TODO;
declare const $AsyncGeneratorSuspendReasonYield: TODO;
declare const $AsyncGeneratorSuspendReasonAwait: TODO;
declare const $AsyncGeneratorSuspendReasonNone: TODO;
declare const $abstractModuleRecordFieldState: TODO;
declare const $processBindingConstants: {
os: typeof import("os").constants;
fs: typeof import("fs").constants;
Expand Down Expand Up @@ -424,11 +314,9 @@ declare function $overridableRequire(this: JSCommonJSModule, id: string): any;
declare function $toLength(length: number): number;
declare function $isTypedArrayView(obj: unknown): obj is ArrayBufferView | DataView | Uint8Array;
declare function $setStateToMax(target: any, state: number): void;
declare function $trunc(target: number): number;
declare function $newPromiseCapability(C: PromiseConstructor): TODO;
/** @deprecated, use new TypeError instead */
declare function $makeTypeError(message: string): TypeError;
declare function $newHandledRejectedPromise(error: unknown): Promise<never>;

declare const __internal: unique symbol;
interface InternalFieldObject<T extends any[]> {
Expand Down Expand Up @@ -542,7 +430,6 @@ declare function $ERR_MISSING_ARGS(...args: [string, ...string[]]): TypeError;
declare function $ERR_MISSING_ARGS(oneOf: string[]): TypeError;
declare function $ERR_INVALID_RETURN_VALUE(expected_type: string, name: string, actual_value: any): TypeError;
declare function $ERR_TLS_INVALID_PROTOCOL_VERSION(a: string, b: string): TypeError;
declare function $ERR_TLS_PROTOCOL_VERSION_CONFLICT(a: string, b: string): TypeError;
declare function $ERR_INVALID_IP_ADDRESS(ip: any): TypeError;
declare function $ERR_INVALID_ADDRESS_FAMILY(addressType, host, port): RangeError;
declare function $ERR_OUT_OF_RANGE(name: string, reason: string, value): RangeError;
Expand Down Expand Up @@ -571,8 +458,6 @@ declare function $ERR_UNESCAPED_CHARACTERS(arg): TypeError;
declare function $ERR_HTTP_INVALID_STATUS_CODE(code): RangeError;
declare function $ERR_UNHANDLED_ERROR(err?): Error;
declare function $ERR_BUFFER_OUT_OF_BOUNDS(name?: string): RangeError;
declare function $ERR_CRYPTO_INVALID_KEY_OBJECT_TYPE(value, expected): TypeError;
declare function $ERR_CRYPTO_INCOMPATIBLE_KEY(name, value): Error;
declare function $ERR_CHILD_PROCESS_IPC_REQUIRED(where): Error;
declare function $ERR_CHILD_PROCESS_STDIO_MAXBUFFER(message): Error;
declare function $ERR_INVALID_ASYNC_ID(name, value): RangeError;
Expand All @@ -591,7 +476,6 @@ declare function $ERR_INSPECTOR_NOT_WORKER(): Error;
declare function $ERR_INSPECTOR_COMMAND(message: string): Error;
declare function $ERR_WORKER_UNSUPPORTED_OPERATION(message: string): TypeError;
declare function $ERR_SERVER_NOT_RUNNING(): Error;
declare function $ERR_IPC_CHANNEL_CLOSED(): Error;
declare function $ERR_SOCKET_BAD_TYPE(): Error;
declare function $ERR_ZLIB_INITIALIZATION_FAILED(): Error;
declare function $ERR_IPC_ONE_PIPE(): Error;
Expand Down Expand Up @@ -642,9 +526,7 @@ declare function $ERR_HTTP2_OUT_OF_STREAMS(): Error;
declare function $ERR_HTTP_BODY_NOT_ALLOWED(): Error;
declare function $ERR_HTTP_SOCKET_ASSIGNED(): Error;
declare function $ERR_DIR_CLOSED(): Error;
declare function $ERR_INVALID_MIME_SYNTAX(production: string, str: string, invalidIndex: number | -1): TypeError;
declare function $ERR_SOCKET_CONNECTION_TIMEOUT(): Error;
declare function $ERR_INVALID_HANDLE_TYPE(): TypeError;
declare function $ERR_TLS_HANDSHAKE_TIMEOUT(): Error;
declare function $ERR_VM_MODULE_STATUS(reason: string): Error;
declare function $ERR_VM_MODULE_ALREADY_LINKED(): Error;
Expand Down Expand Up @@ -679,11 +561,6 @@ declare function $min(a: number, b: number): number;

declare function $checkBufferRead(buf: Buffer, offset: number, byteLength: number): undefined;

/**
* Schedules a callback to be invoked as a microtask.
*/
declare function $enqueueJob<T extends (...args: any[]) => any>(callback: T, ...args: Parameters<T>): void;

interface Map<K, V> {
$get: typeof Map.prototype.get;
$set: typeof Map.prototype.set;
Expand All @@ -694,8 +571,6 @@ interface ObjectConstructor {
$defineProperties: typeof Object.defineProperties;
}

declare const $Object: ObjectConstructor;

/** gets a property on an object */
declare function $getByIdDirect<T, K extends keyof T>(obj: T, key: K): T[K];

Expand All @@ -715,9 +590,3 @@ declare function $getByIdDirectPrivate<T = any, K extends string = string>(
declare var $Promise: PromiseConstructor;

declare function $isPromise<T>(value: unknown): value is Promise<T>;

declare type $ReadableStream = ReadableStream;
declare type $ReadableStreamBYOBReader = ReadableStreamBYOBReader;
declare type $ReadableStreamDefaultReader = ReadableStreamDefaultReader;
declare type $ReadableStreamDefaultController = ReadableStreamDefaultController;
declare type $ReadableStreamDirectController = ReadableStreamDirectController;
6 changes: 0 additions & 6 deletions src/jsc/JSValue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,6 @@ impl JSValue {
) {
self.then2(global, ctx, resolve, reject)
}

/// Reinterpret a raw pointer's address as a JSValue bit-pattern.
#[inline]
pub fn cast<T>(ptr: *const T) -> JSValue {
JSValue(ptr as usize, PhantomData)
}
}

// `pub fn format(...) !void { @compileError(...) }` — intentionally NOT
Expand Down
2 changes: 0 additions & 2 deletions src/jsc/RuntimeTranspilerStore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,6 @@ impl TranspilerJob {
input_file_fd,
path.text,
hash,
loader,
Fd::INVALID,
package_json,
);
Expand Down Expand Up @@ -968,7 +967,6 @@ impl TranspilerJob {
input_file_fd,
path.text,
hash,
loader,
Fd::INVALID,
package_json,
);
Expand Down
Loading
Loading