mirror of
https://github.com/oven-sh/bun
synced 2026-02-11 19:38:58 +00:00
refactor: ban std.debug.assert (#10168)
* Ban `std.debug.assert` * Create .clangd * Update lint.yml * Update linter.ts * update * lint * Update linter.ts * Update linter.ts * update * Update linter.ts * update * Update linter.ts * more * Update install.zig * words * Remove UB
This commit is contained in:
@@ -458,15 +458,15 @@ pub const RunCommand = struct {
|
||||
// a relative lookup, because in the case we do find it, we have to
|
||||
// generate this full path anyways.
|
||||
if (Environment.isWindows and bun.FeatureFlags.windows_bunx_fast_path and bun.strings.hasSuffixComptime(executable, ".exe")) {
|
||||
std.debug.assert(std.fs.path.isAbsolute(executable));
|
||||
bun.assert(std.fs.path.isAbsolute(executable));
|
||||
|
||||
// Using @constCast is safe because we know that
|
||||
// `direct_launch_buffer` is the data destination that assumption is
|
||||
// backed by the immediate assertion.
|
||||
var wpath = @constCast(bun.strings.toNTPath(&BunXFastPath.direct_launch_buffer, executable));
|
||||
std.debug.assert(bun.isSliceInBufferT(u16, wpath, &BunXFastPath.direct_launch_buffer));
|
||||
bun.assert(bun.isSliceInBufferT(u16, wpath, &BunXFastPath.direct_launch_buffer));
|
||||
|
||||
std.debug.assert(wpath.len > bun.windows.nt_object_prefix.len + ".exe".len);
|
||||
bun.assert(wpath.len > bun.windows.nt_object_prefix.len + ".exe".len);
|
||||
wpath.len += ".bunx".len - ".exe".len;
|
||||
@memcpy(wpath[wpath.len - "bunx".len ..], comptime bun.strings.w("bunx"));
|
||||
|
||||
@@ -806,7 +806,7 @@ pub const RunCommand = struct {
|
||||
.ALREADY_EXISTS => {},
|
||||
else => {
|
||||
{
|
||||
std.debug.assert(target_path_buffer[dir_slice.len] == '\\');
|
||||
bun.assert(target_path_buffer[dir_slice.len] == '\\');
|
||||
target_path_buffer[dir_slice.len] = 0;
|
||||
std.os.mkdirW(target_path_buffer[0..dir_slice.len :0], 0) catch {};
|
||||
target_path_buffer[dir_slice.len] = '\\';
|
||||
@@ -1615,7 +1615,7 @@ pub const RunCommand = struct {
|
||||
}
|
||||
|
||||
pub fn execAsIfNode(ctx: Command.Context) !void {
|
||||
std.debug.assert(CLI.pretend_to_be_node);
|
||||
bun.assert(CLI.pretend_to_be_node);
|
||||
|
||||
if (ctx.runtime_options.eval.script.len > 0) {
|
||||
const trigger = bun.pathLiteral("/[eval]");
|
||||
@@ -1673,12 +1673,12 @@ pub const BunXFastPath = struct {
|
||||
if (!bun.FeatureFlags.windows_bunx_fast_path) return;
|
||||
|
||||
var ctx = ctx_const;
|
||||
std.debug.assert(bun.isSliceInBufferT(u16, path_to_use, &BunXFastPath.direct_launch_buffer));
|
||||
bun.assert(bun.isSliceInBufferT(u16, path_to_use, &BunXFastPath.direct_launch_buffer));
|
||||
var command_line = BunXFastPath.direct_launch_buffer[path_to_use.len..];
|
||||
|
||||
debug("Attempting to find and load bunx file: '{}'", .{bun.fmt.utf16(path_to_use)});
|
||||
if (Environment.allow_assert) {
|
||||
std.debug.assert(std.fs.path.isAbsoluteWindowsWTF16(path_to_use));
|
||||
bun.assert(std.fs.path.isAbsoluteWindowsWTF16(path_to_use));
|
||||
}
|
||||
const handle = (bun.sys.openFileAtWindows(
|
||||
bun.invalid_fd, // absolute path is given
|
||||
|
||||
Reference in New Issue
Block a user