Skip to content

Commit 0a86578

Browse files
committed
zig fmt: apply new cast builtin order
1 parent 63d9c5d commit 0a86578

25 files changed

+40
-40
lines changed

lib/compiler_rt/memcpy.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ inline fn copyForwards(
110110
const d = dest + alignment_offset;
111111
const s = src + alignment_offset;
112112

113-
copyBlocksAlignedSource(@ptrCast(d), @alignCast(@ptrCast(s)), n);
113+
copyBlocksAlignedSource(@ptrCast(d), @ptrCast(@alignCast(s)), n);
114114

115115
// copy last `@sizeOf(Element)` bytes unconditionally, since block copy
116116
// methods only copy a multiple of `@sizeOf(Element)` bytes.

lib/compiler_rt/memmove.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ inline fn copyForwards(
157157
const d = dest + alignment_offset;
158158
const s = src + alignment_offset;
159159

160-
copyBlocksAlignedSource(@ptrCast(d), @alignCast(@ptrCast(s)), n);
160+
copyBlocksAlignedSource(@ptrCast(d), @ptrCast(@alignCast(s)), n);
161161

162162
// copy last `copy_size` bytes unconditionally, since block copy
163163
// methods only copy a multiple of `copy_size` bytes.

lib/fuzzer/web/main.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export fn coveredSourceLocations() usize {
127127
}
128128

129129
fn getCoverageUpdateHeader() *abi.CoverageUpdateHeader {
130-
return @alignCast(@ptrCast(recent_coverage_update.items[0..@sizeOf(abi.CoverageUpdateHeader)]));
130+
return @ptrCast(@alignCast(recent_coverage_update.items[0..@sizeOf(abi.CoverageUpdateHeader)]));
131131
}
132132

133133
export fn totalRuns() u64 {

lib/std/array_hash_map.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2086,7 +2086,7 @@ const IndexHeader = struct {
20862086
/// Returns the attached array of indexes. I must match the type
20872087
/// returned by capacityIndexType.
20882088
fn indexes(header: *IndexHeader, comptime I: type) []Index(I) {
2089-
const start_ptr: [*]Index(I) = @alignCast(@ptrCast(@as([*]u8, @ptrCast(header)) + @sizeOf(IndexHeader)));
2089+
const start_ptr: [*]Index(I) = @ptrCast(@alignCast(@as([*]u8, @ptrCast(header)) + @sizeOf(IndexHeader)));
20902090
return start_ptr[0..header.length()];
20912091
}
20922092

@@ -2122,7 +2122,7 @@ const IndexHeader = struct {
21222122
const nbytes = @sizeOf(IndexHeader) + index_size * len;
21232123
const bytes = try gpa.alignedAlloc(u8, .of(IndexHeader), nbytes);
21242124
@memset(bytes[@sizeOf(IndexHeader)..], 0xff);
2125-
const result: *IndexHeader = @alignCast(@ptrCast(bytes.ptr));
2125+
const result: *IndexHeader = @ptrCast(@alignCast(bytes.ptr));
21262126
result.* = .{
21272127
.bit_index = new_bit_index,
21282128
};

lib/std/crypto/codecs/asn1/der/Encoder.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fn anyTag(self: *Encoder, tag_: Tag, val: anytype) !void {
3737
// > The encoding of a set value or sequence value shall not include an encoding for any
3838
// > component value which is equal to its default value.
3939
const is_default = if (f.is_comptime) false else if (f.default_value_ptr) |v| brk: {
40-
const default_val: *const f.type = @alignCast(@ptrCast(v));
40+
const default_val: *const f.type = @ptrCast(@alignCast(v));
4141
break :brk std.mem.eql(u8, std.mem.asBytes(default_val), std.mem.asBytes(&field_val));
4242
} else false;
4343

lib/std/crypto/timing_safe.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ fn markSecret(ptr: anytype, comptime action: enum { classify, declassify }) void
147147
@compileError("A pointer value is always assumed leak information via side channels");
148148
},
149149
else => {
150-
const mem8: *const [@sizeOf(@TypeOf(ptr.*))]u8 = @constCast(@ptrCast(ptr));
150+
const mem8: *const [@sizeOf(@TypeOf(ptr.*))]u8 = @ptrCast(@constCast(ptr));
151151
if (action == .classify) {
152152
std.valgrind.memcheck.makeMemUndefined(mem8);
153153
} else {

lib/std/debug/SelfInfo.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ pub const WindowsModule = struct {
836836

837837
pub fn deinit(self: @This()) void {
838838
const process_handle = windows.GetCurrentProcess();
839-
assert(windows.ntdll.NtUnmapViewOfSection(process_handle, @constCast(@ptrCast(self.section_view.ptr))) == .SUCCESS);
839+
assert(windows.ntdll.NtUnmapViewOfSection(process_handle, @ptrCast(@constCast(self.section_view.ptr))) == .SUCCESS);
840840
windows.CloseHandle(self.section_handle);
841841
self.file.close();
842842
}

lib/std/hash_map.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1511,7 +1511,7 @@ pub fn HashMapUnmanaged(
15111511

15121512
const total_size = std.mem.alignForward(usize, vals_end, max_align);
15131513

1514-
const slice = @as([*]align(max_align) u8, @alignCast(@ptrCast(self.header())))[0..total_size];
1514+
const slice = @as([*]align(max_align) u8, @ptrCast(@alignCast(self.header())))[0..total_size];
15151515
allocator.free(slice);
15161516

15171517
self.metadata = null;

lib/std/heap.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ const CAllocator = struct {
151151
};
152152

153153
fn getHeader(ptr: [*]u8) *[*]u8 {
154-
return @alignCast(@ptrCast(ptr - @sizeOf(usize)));
154+
return @ptrCast(@alignCast(ptr - @sizeOf(usize)));
155155
}
156156

157157
fn alignedAlloc(len: usize, alignment: Alignment) ?[*]u8 {

lib/std/heap/SmpAllocator.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ fn free(context: *anyopaque, memory: []u8, alignment: mem.Alignment, ra: usize)
205205
return PageAllocator.unmap(@alignCast(memory));
206206
}
207207

208-
const node: *usize = @alignCast(@ptrCast(memory.ptr));
208+
const node: *usize = @ptrCast(@alignCast(memory.ptr));
209209

210210
const t = Thread.lock();
211211
defer t.unlock();

lib/std/heap/debug_allocator.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ pub fn DebugAllocator(comptime config: Config) type {
291291

292292
fn usedBits(bucket: *BucketHeader, index: usize) *usize {
293293
const ptr: [*]u8 = @ptrCast(bucket);
294-
const bits: [*]usize = @alignCast(@ptrCast(ptr + @sizeOf(BucketHeader)));
294+
const bits: [*]usize = @ptrCast(@alignCast(ptr + @sizeOf(BucketHeader)));
295295
return &bits[index];
296296
}
297297

lib/std/http/Server.zig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ pub const Request = struct {
625625
};
626626

627627
fn read_cl(context: *const anyopaque, buffer: []u8) ReadError!usize {
628-
const request: *Request = @constCast(@alignCast(@ptrCast(context)));
628+
const request: *Request = @ptrCast(@alignCast(@constCast(context)));
629629
const s = request.server;
630630

631631
const remaining_content_length = &request.reader_state.remaining_content_length;
@@ -653,7 +653,7 @@ pub const Request = struct {
653653
}
654654

655655
fn read_chunked(context: *const anyopaque, buffer: []u8) ReadError!usize {
656-
const request: *Request = @constCast(@alignCast(@ptrCast(context)));
656+
const request: *Request = @ptrCast(@alignCast(@constCast(context)));
657657
const s = request.server;
658658

659659
const cp = &request.reader_state.chunk_parser;
@@ -895,7 +895,7 @@ pub const Response = struct {
895895
}
896896

897897
fn write_cl(context: *const anyopaque, bytes: []const u8) WriteError!usize {
898-
const r: *Response = @constCast(@alignCast(@ptrCast(context)));
898+
const r: *Response = @ptrCast(@alignCast(@constCast(context)));
899899

900900
var trash: u64 = std.math.maxInt(u64);
901901
const len = switch (r.transfer_encoding) {
@@ -945,7 +945,7 @@ pub const Response = struct {
945945
}
946946

947947
fn write_chunked(context: *const anyopaque, bytes: []const u8) WriteError!usize {
948-
const r: *Response = @constCast(@alignCast(@ptrCast(context)));
948+
const r: *Response = @ptrCast(@alignCast(@constCast(context)));
949949
assert(r.transfer_encoding == .chunked);
950950

951951
if (r.elide_body)

lib/std/io.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ pub fn GenericReader(
283283
const Self = @This();
284284

285285
fn typeErasedReadFn(context: *const anyopaque, buffer: []u8) anyerror!usize {
286-
const ptr: *const Context = @alignCast(@ptrCast(context));
286+
const ptr: *const Context = @ptrCast(@alignCast(context));
287287
return readFn(ptr.*, buffer);
288288
}
289289
};
@@ -344,7 +344,7 @@ pub fn GenericWriter(
344344
}
345345

346346
fn typeErasedWriteFn(context: *const anyopaque, bytes: []const u8) anyerror!usize {
347-
const ptr: *const Context = @alignCast(@ptrCast(context));
347+
const ptr: *const Context = @ptrCast(@alignCast(context));
348348
return writeFn(ptr.*, bytes);
349349
}
350350
};

lib/std/os/windows.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ pub fn CreatePipe(rd: *HANDLE, wr: *HANDLE, sattr: *const SECURITY_ATTRIBUTES) C
202202
const name = UNICODE_STRING{
203203
.Length = len,
204204
.MaximumLength = len,
205-
.Buffer = @constCast(@ptrCast(str)),
205+
.Buffer = @ptrCast(@constCast(str)),
206206
};
207207
const attrs = OBJECT_ATTRIBUTES{
208208
.ObjectName = @constCast(&name),

lib/std/pie.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ pub fn relocate(phdrs: []const elf.Phdr) void {
264264

265265
const rel = sorted_dynv[elf.DT_REL];
266266
if (rel != 0) {
267-
const rels: []const elf.Rel = @alignCast(@ptrCast(
267+
const rels: []const elf.Rel = @ptrCast(@alignCast(
268268
@as([*]align(@alignOf(elf.Rel)) const u8, @ptrFromInt(base_addr + rel))[0..sorted_dynv[elf.DT_RELSZ]],
269269
));
270270
for (rels) |r| {
@@ -275,7 +275,7 @@ pub fn relocate(phdrs: []const elf.Phdr) void {
275275

276276
const rela = sorted_dynv[elf.DT_RELA];
277277
if (rela != 0) {
278-
const relas: []const elf.Rela = @alignCast(@ptrCast(
278+
const relas: []const elf.Rela = @ptrCast(@alignCast(
279279
@as([*]align(@alignOf(elf.Rela)) const u8, @ptrFromInt(base_addr + rela))[0..sorted_dynv[elf.DT_RELASZ]],
280280
));
281281
for (relas) |r| {

lib/std/zig/c_translation.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ fn castInt(comptime DestType: type, target: anytype) DestType {
7171
}
7272

7373
fn castPtr(comptime DestType: type, target: anytype) DestType {
74-
return @constCast(@volatileCast(@alignCast(@ptrCast(target))));
74+
return @ptrCast(@alignCast(@constCast(@volatileCast(target))));
7575
}
7676

7777
fn castToPtr(comptime DestType: type, comptime SourceType: type, target: anytype) DestType {

lib/ubsan_rt.zig

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ const Value = extern struct {
5858
}
5959

6060
return switch (size) {
61-
64 => @as(*const u64, @alignCast(@ptrCast(value.handle))).*,
62-
128 => @as(*const u128, @alignCast(@ptrCast(value.handle))).*,
61+
64 => @as(*const u64, @ptrCast(@alignCast(value.handle))).*,
62+
128 => @as(*const u128, @ptrCast(@alignCast(value.handle))).*,
6363
else => @trap(),
6464
};
6565
}
@@ -74,8 +74,8 @@ const Value = extern struct {
7474
return (handle << extra_bits) >> extra_bits;
7575
}
7676
return switch (size) {
77-
64 => @as(*const i64, @alignCast(@ptrCast(value.handle))).*,
78-
128 => @as(*const i128, @alignCast(@ptrCast(value.handle))).*,
77+
64 => @as(*const i64, @ptrCast(@alignCast(value.handle))).*,
78+
128 => @as(*const i128, @ptrCast(@alignCast(value.handle))).*,
7979
else => @trap(),
8080
};
8181
}
@@ -92,9 +92,9 @@ const Value = extern struct {
9292
}, @bitCast(@intFromPtr(value.handle)));
9393
}
9494
return @floatCast(switch (size) {
95-
64 => @as(*const f64, @alignCast(@ptrCast(value.handle))).*,
96-
80 => @as(*const f80, @alignCast(@ptrCast(value.handle))).*,
97-
128 => @as(*const f128, @alignCast(@ptrCast(value.handle))).*,
95+
64 => @as(*const f64, @ptrCast(@alignCast(value.handle))).*,
96+
80 => @as(*const f80, @ptrCast(@alignCast(value.handle))).*,
97+
128 => @as(*const f128, @ptrCast(@alignCast(value.handle))).*,
9898
else => @trap(),
9999
});
100100
}

src/InternPool.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,7 +1359,7 @@ const Local = struct {
13591359
capacity: u32,
13601360
};
13611361
fn header(list: ListSelf) *Header {
1362-
return @alignCast(@ptrCast(list.bytes - bytes_offset));
1362+
return @ptrCast(@alignCast(list.bytes - bytes_offset));
13631363
}
13641364
pub fn view(list: ListSelf) View {
13651365
const capacity = list.header().capacity;
@@ -1568,7 +1568,7 @@ const Shard = struct {
15681568
}
15691569
};
15701570
fn header(map: @This()) *Header {
1571-
return @alignCast(@ptrCast(@as([*]u8, @ptrCast(map.entries)) - entries_offset));
1571+
return @ptrCast(@alignCast(@as([*]u8, @ptrCast(map.entries)) - entries_offset));
15721572
}
15731573

15741574
const Entry = extern struct {

src/Package/Fetch.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ const Resource = union(enum) {
882882
}
883883

884884
fn read(context: *const anyopaque, buffer: []u8) anyerror!usize {
885-
const resource: *Resource = @constCast(@ptrCast(@alignCast(context)));
885+
const resource: *Resource = @ptrCast(@alignCast(@constCast(context)));
886886
switch (resource.*) {
887887
.file => |*f| return f.read(buffer),
888888
.http_request => |*r| return r.read(buffer),

src/codegen/c.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7966,7 +7966,7 @@ fn arrayListWriter(list: *std.ArrayList(u8)) ArrayListWriter {
79667966
.context = list,
79677967
.writeFn = struct {
79687968
fn write(context: *const anyopaque, bytes: []const u8) anyerror!usize {
7969-
const l: *std.ArrayList(u8) = @alignCast(@constCast(@ptrCast(context)));
7969+
const l: *std.ArrayList(u8) = @ptrCast(@alignCast(@constCast(context)));
79707970
return l.writer().write(bytes);
79717971
}
79727972
}.write,
@@ -8005,7 +8005,7 @@ fn IndentWriter(comptime UnderlyingWriter: type) type {
80058005
}
80068006

80078007
fn writeAny(context: *const anyopaque, bytes: []const u8) anyerror!usize {
8008-
const self: *Self = @alignCast(@constCast(@ptrCast(context)));
8008+
const self: *Self = @ptrCast(@alignCast(@constCast(context)));
80098009
return self.write(bytes);
80108010
}
80118011

test/behavior/array.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,7 @@ test "initialize pointer to anyopaque with reference to empty array initializer"
11261126
const ptr: *const anyopaque = &.{};
11271127
// The above acts like an untyped initializer, since the `.{}` has no result type.
11281128
// So, `ptr` points in memory to an empty tuple (`@TypeOf(.{})`).
1129-
const casted: *const @TypeOf(.{}) = @alignCast(@ptrCast(ptr));
1129+
const casted: *const @TypeOf(.{}) = @ptrCast(@alignCast(ptr));
11301130
const loaded = casted.*;
11311131
// `val` should be a `@TypeOf(.{})`, as expected.
11321132
// We can't check the value, but it's zero-bit, so the type matching is good enough.

test/behavior/comptime_memory.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ fn GenericIntApplier(
479479
}
480480

481481
fn typeErasedApplyFn(context: *const anyopaque, arg: u32) void {
482-
const ptr: *const Context = @alignCast(@ptrCast(context));
482+
const ptr: *const Context = @ptrCast(@alignCast(context));
483483
applyFn(ptr.*, arg);
484484
}
485485
};

test/behavior/extern.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ test "anyopaque extern symbol" {
88
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
99

1010
const a = @extern(*anyopaque, .{ .name = "a_mystery_symbol" });
11-
const b: *i32 = @alignCast(@ptrCast(a));
11+
const b: *i32 = @ptrCast(@alignCast(a));
1212
try expect(b.* == 1234);
1313
}
1414

test/cases/compile_errors/nested_ptr_cast_bad_operand.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export fn b() void {
66
_ = @constCast(@volatileCast(123));
77
}
88
export fn c() void {
9-
const x: ?*f32 = @constCast(@ptrCast(@addrSpaceCast(@volatileCast(p))));
9+
const x: ?*f32 = @ptrCast(@addrSpaceCast(@constCast(@volatileCast(p))));
1010
_ = x;
1111
}
1212

test/translate_c.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3234,12 +3234,12 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
32343234
\\pub export fn bar(arg_a: [*c]const c_int) void {
32353235
\\ var a = arg_a;
32363236
\\ _ = &a;
3237-
\\ foo(@as([*c]c_int, @ptrCast(@volatileCast(@constCast(a)))));
3237+
\\ foo(@as([*c]c_int, @ptrCast(@constCast(@volatileCast(a)))));
32383238
\\}
32393239
\\pub export fn baz(arg_a: [*c]volatile c_int) void {
32403240
\\ var a = arg_a;
32413241
\\ _ = &a;
3242-
\\ foo(@as([*c]c_int, @ptrCast(@volatileCast(@constCast(a)))));
3242+
\\ foo(@as([*c]c_int, @ptrCast(@constCast(@volatileCast(a)))));
32433243
\\}
32443244
});
32453245

0 commit comments

Comments
 (0)