authorgravatar for justus@klausecker.deJustus Klausecker <justus@klausecker.de> 2025-08-03 14:53:52+02:00
committergravatar for justus@klausecker.deJustus Klausecker <justus@klausecker.de> 2025-08-03 14:59:56+02:00
log7c35070b901d9181ec3c666480a91eddf6c1abce
tree74f6eddb4386054ad74aa04b9a506d1ccfb717dc
parent81219493f87b8345446e387e71279d74f35b6824

zig fmt: apply new cast builtin order


29 files changed, 45 insertions(+), 45 deletions(-)

lib/build-web/fuzz.zig+1-1
...@@ -256,7 +256,7 @@ fn updateStats() error{OutOfMemory}!void {...@@ -256,7 +256,7 @@ fn updateStats() error{OutOfMemory}!void {
256256
257 if (recent_coverage_update.items.len == 0) return;257 if (recent_coverage_update.items.len == 0) return;
258258
259 const hdr: *abi.fuzz.CoverageUpdateHeader = @alignCast(@ptrCast(259 const hdr: *abi.fuzz.CoverageUpdateHeader = @ptrCast(@alignCast(
260 recent_coverage_update.items[0..@sizeOf(abi.fuzz.CoverageUpdateHeader)],260 recent_coverage_update.items[0..@sizeOf(abi.fuzz.CoverageUpdateHeader)],
261 ));261 ));
262262
lib/compiler_rt/memcpy.zig+1-1
...@@ -110,7 +110,7 @@ inline fn copyForwards(...@@ -110,7 +110,7 @@ inline fn copyForwards(
110 const d = dest + alignment_offset;110 const d = dest + alignment_offset;
111 const s = src + alignment_offset;111 const s = src + alignment_offset;
112112
113 copyBlocksAlignedSource(@ptrCast(d), @alignCast(@ptrCast(s)), n);113 copyBlocksAlignedSource(@ptrCast(d), @ptrCast(@alignCast(s)), n);
114114
115 // copy last `@sizeOf(Element)` bytes unconditionally, since block copy115 // copy last `@sizeOf(Element)` bytes unconditionally, since block copy
116 // methods only copy a multiple of `@sizeOf(Element)` bytes.116 // methods only copy a multiple of `@sizeOf(Element)` bytes.
lib/compiler_rt/memmove.zig+1-1
...@@ -157,7 +157,7 @@ inline fn copyForwards(...@@ -157,7 +157,7 @@ inline fn copyForwards(
157 const d = dest + alignment_offset;157 const d = dest + alignment_offset;
158 const s = src + alignment_offset;158 const s = src + alignment_offset;
159159
160 copyBlocksAlignedSource(@ptrCast(d), @alignCast(@ptrCast(s)), n);160 copyBlocksAlignedSource(@ptrCast(d), @ptrCast(@alignCast(s)), n);
161161
162 // copy last `copy_size` bytes unconditionally, since block copy162 // copy last `copy_size` bytes unconditionally, since block copy
163 // methods only copy a multiple of `copy_size` bytes.163 // methods only copy a multiple of `copy_size` bytes.
lib/std/Io.zig+2-2
...@@ -304,7 +304,7 @@ pub fn GenericReader(...@@ -304,7 +304,7 @@ pub fn GenericReader(
304 const Self = @This();304 const Self = @This();
305305
306 fn typeErasedReadFn(context: *const anyopaque, buffer: []u8) anyerror!usize {306 fn typeErasedReadFn(context: *const anyopaque, buffer: []u8) anyerror!usize {
307 const ptr: *const Context = @alignCast(@ptrCast(context));307 const ptr: *const Context = @ptrCast(@alignCast(context));
308 return readFn(ptr.*, buffer);308 return readFn(ptr.*, buffer);
309 }309 }
310310
...@@ -397,7 +397,7 @@ pub fn GenericWriter(...@@ -397,7 +397,7 @@ pub fn GenericWriter(
397 }397 }
398398
399 fn typeErasedWriteFn(context: *const anyopaque, bytes: []const u8) anyerror!usize {399 fn typeErasedWriteFn(context: *const anyopaque, bytes: []const u8) anyerror!usize {
400 const ptr: *const Context = @alignCast(@ptrCast(context));400 const ptr: *const Context = @ptrCast(@alignCast(context));
401 return writeFn(ptr.*, bytes);401 return writeFn(ptr.*, bytes);
402 }402 }
403403
lib/std/Io/Reader.zig+1-1
...@@ -1698,7 +1698,7 @@ pub fn adaptToOldInterface(r: *Reader) std.Io.AnyReader {...@@ -1698,7 +1698,7 @@ pub fn adaptToOldInterface(r: *Reader) std.Io.AnyReader {
1698}1698}
16991699
1700fn derpRead(context: *const anyopaque, buffer: []u8) anyerror!usize {1700fn derpRead(context: *const anyopaque, buffer: []u8) anyerror!usize {
1701 const r: *Reader = @constCast(@alignCast(@ptrCast(context)));1701 const r: *Reader = @ptrCast(@alignCast(@constCast(context)));
1702 return r.readSliceShort(buffer);1702 return r.readSliceShort(buffer);
1703}1703}
17041704
lib/std/array_hash_map.zig+2-2
...@@ -2086,7 +2086,7 @@ const IndexHeader = struct {...@@ -2086,7 +2086,7 @@ const IndexHeader = struct {
2086 /// Returns the attached array of indexes. I must match the type2086 /// Returns the attached array of indexes. I must match the type
2087 /// returned by capacityIndexType.2087 /// returned by capacityIndexType.
2088 fn indexes(header: *IndexHeader, comptime I: type) []Index(I) {2088 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)));
2090 return start_ptr[0..header.length()];2090 return start_ptr[0..header.length()];
2091 }2091 }
20922092
...@@ -2122,7 +2122,7 @@ const IndexHeader = struct {...@@ -2122,7 +2122,7 @@ const IndexHeader = struct {
2122 const nbytes = @sizeOf(IndexHeader) + index_size * len;2122 const nbytes = @sizeOf(IndexHeader) + index_size * len;
2123 const bytes = try gpa.alignedAlloc(u8, .of(IndexHeader), nbytes);2123 const bytes = try gpa.alignedAlloc(u8, .of(IndexHeader), nbytes);
2124 @memset(bytes[@sizeOf(IndexHeader)..], 0xff);2124 @memset(bytes[@sizeOf(IndexHeader)..], 0xff);
2125 const result: *IndexHeader = @alignCast(@ptrCast(bytes.ptr));2125 const result: *IndexHeader = @ptrCast(@alignCast(bytes.ptr));
2126 result.* = .{2126 result.* = .{
2127 .bit_index = new_bit_index,2127 .bit_index = new_bit_index,
2128 };2128 };
lib/std/crypto/codecs/asn1/der/Encoder.zig+1-1
...@@ -37,7 +37,7 @@ fn anyTag(self: *Encoder, tag_: Tag, val: anytype) !void {...@@ -37,7 +37,7 @@ fn anyTag(self: *Encoder, tag_: Tag, val: anytype) !void {
37 // > The encoding of a set value or sequence value shall not include an encoding for any37 // > The encoding of a set value or sequence value shall not include an encoding for any
38 // > component value which is equal to its default value.38 // > component value which is equal to its default value.
39 const is_default = if (f.is_comptime) false else if (f.default_value_ptr) |v| brk: {39 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));
41 break :brk std.mem.eql(u8, std.mem.asBytes(default_val), std.mem.asBytes(&field_val));41 break :brk std.mem.eql(u8, std.mem.asBytes(default_val), std.mem.asBytes(&field_val));
42 } else false;42 } else false;
4343
lib/std/crypto/timing_safe.zig+1-1
...@@ -147,7 +147,7 @@ fn markSecret(ptr: anytype, comptime action: enum { classify, declassify }) void...@@ -147,7 +147,7 @@ fn markSecret(ptr: anytype, comptime action: enum { classify, declassify }) void
147 @compileError("A pointer value is always assumed leak information via side channels");147 @compileError("A pointer value is always assumed leak information via side channels");
148 },148 },
149 else => {149 else => {
150 const mem8: *const [@sizeOf(@TypeOf(ptr.*))]u8 = @constCast(@ptrCast(ptr));150 const mem8: *const [@sizeOf(@TypeOf(ptr.*))]u8 = @ptrCast(@constCast(ptr));
151 if (action == .classify) {151 if (action == .classify) {
152 std.valgrind.memcheck.makeMemUndefined(mem8);152 std.valgrind.memcheck.makeMemUndefined(mem8);
153 } else {153 } else {
lib/std/debug.zig+1-1
...@@ -569,7 +569,7 @@ pub fn assertReadable(slice: []const volatile u8) void {...@@ -569,7 +569,7 @@ pub fn assertReadable(slice: []const volatile u8) void {
569/// Invokes detectable illegal behavior when the provided array is not aligned569/// Invokes detectable illegal behavior when the provided array is not aligned
570/// to the provided amount.570/// to the provided amount.
571pub fn assertAligned(ptr: anytype, comptime alignment: std.mem.Alignment) void {571pub fn assertAligned(ptr: anytype, comptime alignment: std.mem.Alignment) void {
572 const aligned_ptr: *align(alignment.toByteUnits()) anyopaque = @alignCast(@ptrCast(ptr));572 const aligned_ptr: *align(alignment.toByteUnits()) anyopaque = @ptrCast(@alignCast(ptr));
573 _ = aligned_ptr;573 _ = aligned_ptr;
574}574}
575575
lib/std/debug/SelfInfo.zig+1-1
...@@ -836,7 +836,7 @@ pub const WindowsModule = struct {...@@ -836,7 +836,7 @@ pub const WindowsModule = struct {
836836
837 pub fn deinit(self: @This()) void {837 pub fn deinit(self: @This()) void {
838 const process_handle = windows.GetCurrentProcess();838 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);
840 windows.CloseHandle(self.section_handle);840 windows.CloseHandle(self.section_handle);
841 self.file.close();841 self.file.close();
842 }842 }
lib/std/hash_map.zig+1-1
...@@ -1511,7 +1511,7 @@ pub fn HashMapUnmanaged(...@@ -1511,7 +1511,7 @@ pub fn HashMapUnmanaged(
15111511
1512 const total_size = std.mem.alignForward(usize, vals_end, max_align);1512 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];
1515 allocator.free(slice);1515 allocator.free(slice);
15161516
1517 self.metadata = null;1517 self.metadata = null;
lib/std/heap.zig+1-1
...@@ -151,7 +151,7 @@ const CAllocator = struct {...@@ -151,7 +151,7 @@ const CAllocator = struct {
151 };151 };
152152
153 fn getHeader(ptr: [*]u8) *[*]u8 {153 fn getHeader(ptr: [*]u8) *[*]u8 {
154 return @alignCast(@ptrCast(ptr - @sizeOf(usize)));154 return @ptrCast(@alignCast(ptr - @sizeOf(usize)));
155 }155 }
156156
157 fn alignedAlloc(len: usize, alignment: Alignment) ?[*]u8 {157 fn alignedAlloc(len: usize, alignment: Alignment) ?[*]u8 {
lib/std/heap/SmpAllocator.zig+1-1
...@@ -205,7 +205,7 @@ fn free(context: *anyopaque, memory: []u8, alignment: mem.Alignment, ra: usize)...@@ -205,7 +205,7 @@ fn free(context: *anyopaque, memory: []u8, alignment: mem.Alignment, ra: usize)
205 return PageAllocator.unmap(@alignCast(memory));205 return PageAllocator.unmap(@alignCast(memory));
206 }206 }
207207
208 const node: *usize = @alignCast(@ptrCast(memory.ptr));208 const node: *usize = @ptrCast(@alignCast(memory.ptr));
209209
210 const t = Thread.lock();210 const t = Thread.lock();
211 defer t.unlock();211 defer t.unlock();
lib/std/heap/debug_allocator.zig+1-1
...@@ -291,7 +291,7 @@ pub fn DebugAllocator(comptime config: Config) type {...@@ -291,7 +291,7 @@ pub fn DebugAllocator(comptime config: Config) type {
291291
292 fn usedBits(bucket: *BucketHeader, index: usize) *usize {292 fn usedBits(bucket: *BucketHeader, index: usize) *usize {
293 const ptr: [*]u8 = @ptrCast(bucket);293 const ptr: [*]u8 = @ptrCast(bucket);
294 const bits: [*]usize = @alignCast(@ptrCast(ptr + @sizeOf(BucketHeader)));294 const bits: [*]usize = @ptrCast(@alignCast(ptr + @sizeOf(BucketHeader)));
295 return &bits[index];295 return &bits[index];
296 }296 }
297297
lib/std/http/Server.zig+4-4
...@@ -624,7 +624,7 @@ pub const Request = struct {...@@ -624,7 +624,7 @@ pub const Request = struct {
624 };624 };
625625
626 fn read_cl(context: *const anyopaque, buffer: []u8) ReadError!usize {626 fn read_cl(context: *const anyopaque, buffer: []u8) ReadError!usize {
627 const request: *Request = @constCast(@alignCast(@ptrCast(context)));627 const request: *Request = @ptrCast(@alignCast(@constCast(context)));
628 const s = request.server;628 const s = request.server;
629629
630 const remaining_content_length = &request.reader_state.remaining_content_length;630 const remaining_content_length = &request.reader_state.remaining_content_length;
...@@ -652,7 +652,7 @@ pub const Request = struct {...@@ -652,7 +652,7 @@ pub const Request = struct {
652 }652 }
653653
654 fn read_chunked(context: *const anyopaque, buffer: []u8) ReadError!usize {654 fn read_chunked(context: *const anyopaque, buffer: []u8) ReadError!usize {
655 const request: *Request = @constCast(@alignCast(@ptrCast(context)));655 const request: *Request = @ptrCast(@alignCast(@constCast(context)));
656 const s = request.server;656 const s = request.server;
657657
658 const cp = &request.reader_state.chunk_parser;658 const cp = &request.reader_state.chunk_parser;
...@@ -894,7 +894,7 @@ pub const Response = struct {...@@ -894,7 +894,7 @@ pub const Response = struct {
894 }894 }
895895
896 fn write_cl(context: *const anyopaque, bytes: []const u8) WriteError!usize {896 fn write_cl(context: *const anyopaque, bytes: []const u8) WriteError!usize {
897 const r: *Response = @constCast(@alignCast(@ptrCast(context)));897 const r: *Response = @ptrCast(@alignCast(@constCast(context)));
898898
899 var trash: u64 = std.math.maxInt(u64);899 var trash: u64 = std.math.maxInt(u64);
900 const len = switch (r.transfer_encoding) {900 const len = switch (r.transfer_encoding) {
...@@ -944,7 +944,7 @@ pub const Response = struct {...@@ -944,7 +944,7 @@ pub const Response = struct {
944 }944 }
945945
946 fn write_chunked(context: *const anyopaque, bytes: []const u8) WriteError!usize {946 fn write_chunked(context: *const anyopaque, bytes: []const u8) WriteError!usize {
947 const r: *Response = @constCast(@alignCast(@ptrCast(context)));947 const r: *Response = @ptrCast(@alignCast(@constCast(context)));
948 assert(r.transfer_encoding == .chunked);948 assert(r.transfer_encoding == .chunked);
949949
950 if (r.elide_body)950 if (r.elide_body)
lib/std/os/uefi/tables.zig+1-1
...@@ -154,7 +154,7 @@ pub const MemoryMapSlice = struct {...@@ -154,7 +154,7 @@ pub const MemoryMapSlice = struct {
154154
155 pub fn getUnchecked(self: MemoryMapSlice, index: usize) *MemoryDescriptor {155 pub fn getUnchecked(self: MemoryMapSlice, index: usize) *MemoryDescriptor {
156 const offset: usize = index * self.info.descriptor_size;156 const offset: usize = index * self.info.descriptor_size;
157 return @alignCast(@ptrCast(self.ptr[offset..]));157 return @ptrCast(@alignCast(self.ptr[offset..]));
158 }158 }
159};159};
160160
lib/std/os/uefi/tables/runtime_services.zig+1-1
...@@ -353,7 +353,7 @@ pub const RuntimeServices = extern struct {...@@ -353,7 +353,7 @@ pub const RuntimeServices = extern struct {
353 reset_type,353 reset_type,
354 reset_status,354 reset_status,
355 if (data) |d| d.len else 0,355 if (data) |d| d.len else 0,
356 if (data) |d| @alignCast(@ptrCast(d.ptr)) else null,356 if (data) |d| @ptrCast(@alignCast(d.ptr)) else null,
357 );357 );
358 }358 }
359359
lib/std/os/windows.zig+1-1
...@@ -202,7 +202,7 @@ pub fn CreatePipe(rd: *HANDLE, wr: *HANDLE, sattr: *const SECURITY_ATTRIBUTES) C...@@ -202,7 +202,7 @@ pub fn CreatePipe(rd: *HANDLE, wr: *HANDLE, sattr: *const SECURITY_ATTRIBUTES) C
202 const name = UNICODE_STRING{202 const name = UNICODE_STRING{
203 .Length = len,203 .Length = len,
204 .MaximumLength = len,204 .MaximumLength = len,
205 .Buffer = @constCast(@ptrCast(str)),205 .Buffer = @ptrCast(@constCast(str)),
206 };206 };
207 const attrs = OBJECT_ATTRIBUTES{207 const attrs = OBJECT_ATTRIBUTES{
208 .ObjectName = @constCast(&name),208 .ObjectName = @constCast(&name),
lib/std/pie.zig+2-2
...@@ -259,7 +259,7 @@ pub fn relocate(phdrs: []const elf.Phdr) void {...@@ -259,7 +259,7 @@ pub fn relocate(phdrs: []const elf.Phdr) void {
259259
260 const rel = sorted_dynv[elf.DT_REL];260 const rel = sorted_dynv[elf.DT_REL];
261 if (rel != 0) {261 if (rel != 0) {
262 const rels: []const elf.Rel = @alignCast(@ptrCast(262 const rels: []const elf.Rel = @ptrCast(@alignCast(
263 @as([*]align(@alignOf(elf.Rel)) const u8, @ptrFromInt(base_addr + rel))[0..sorted_dynv[elf.DT_RELSZ]],263 @as([*]align(@alignOf(elf.Rel)) const u8, @ptrFromInt(base_addr + rel))[0..sorted_dynv[elf.DT_RELSZ]],
264 ));264 ));
265 for (rels) |r| {265 for (rels) |r| {
...@@ -270,7 +270,7 @@ pub fn relocate(phdrs: []const elf.Phdr) void {...@@ -270,7 +270,7 @@ pub fn relocate(phdrs: []const elf.Phdr) void {
270270
271 const rela = sorted_dynv[elf.DT_RELA];271 const rela = sorted_dynv[elf.DT_RELA];
272 if (rela != 0) {272 if (rela != 0) {
273 const relas: []const elf.Rela = @alignCast(@ptrCast(273 const relas: []const elf.Rela = @ptrCast(@alignCast(
274 @as([*]align(@alignOf(elf.Rela)) const u8, @ptrFromInt(base_addr + rela))[0..sorted_dynv[elf.DT_RELASZ]],274 @as([*]align(@alignOf(elf.Rela)) const u8, @ptrFromInt(base_addr + rela))[0..sorted_dynv[elf.DT_RELASZ]],
275 ));275 ));
276 for (relas) |r| {276 for (relas) |r| {
lib/std/zig/c_translation.zig+1-1
...@@ -71,7 +71,7 @@ fn castInt(comptime DestType: type, target: anytype) DestType {...@@ -71,7 +71,7 @@ fn castInt(comptime DestType: type, target: anytype) DestType {
71}71}
7272
73fn castPtr(comptime DestType: type, target: anytype) DestType {73fn castPtr(comptime DestType: type, target: anytype) DestType {
74 return @constCast(@volatileCast(@alignCast(@ptrCast(target))));74 return @ptrCast(@alignCast(@constCast(@volatileCast(target))));
75}75}
7676
77fn castToPtr(comptime DestType: type, comptime SourceType: type, target: anytype) DestType {77fn castToPtr(comptime DestType: type, comptime SourceType: type, target: anytype) DestType {
lib/ubsan_rt.zig+7-7
...@@ -58,8 +58,8 @@ const Value = extern struct {...@@ -58,8 +58,8 @@ const Value = extern struct {
58 }58 }
5959
60 return switch (size) {60 return switch (size) {
61 64 => @as(*const u64, @alignCast(@ptrCast(value.handle))).*,61 64 => @as(*const u64, @ptrCast(@alignCast(value.handle))).*,
62 128 => @as(*const u128, @alignCast(@ptrCast(value.handle))).*,62 128 => @as(*const u128, @ptrCast(@alignCast(value.handle))).*,
63 else => @trap(),63 else => @trap(),
64 };64 };
65 }65 }
...@@ -74,8 +74,8 @@ const Value = extern struct {...@@ -74,8 +74,8 @@ const Value = extern struct {
74 return (handle << extra_bits) >> extra_bits;74 return (handle << extra_bits) >> extra_bits;
75 }75 }
76 return switch (size) {76 return switch (size) {
77 64 => @as(*const i64, @alignCast(@ptrCast(value.handle))).*,77 64 => @as(*const i64, @ptrCast(@alignCast(value.handle))).*,
78 128 => @as(*const i128, @alignCast(@ptrCast(value.handle))).*,78 128 => @as(*const i128, @ptrCast(@alignCast(value.handle))).*,
79 else => @trap(),79 else => @trap(),
80 };80 };
81 }81 }
...@@ -92,9 +92,9 @@ const Value = extern struct {...@@ -92,9 +92,9 @@ const Value = extern struct {
92 }, @bitCast(@intFromPtr(value.handle)));92 }, @bitCast(@intFromPtr(value.handle)));
93 }93 }
94 return @floatCast(switch (size) {94 return @floatCast(switch (size) {
95 64 => @as(*const f64, @alignCast(@ptrCast(value.handle))).*,95 64 => @as(*const f64, @ptrCast(@alignCast(value.handle))).*,
96 80 => @as(*const f80, @alignCast(@ptrCast(value.handle))).*,96 80 => @as(*const f80, @ptrCast(@alignCast(value.handle))).*,
97 128 => @as(*const f128, @alignCast(@ptrCast(value.handle))).*,97 128 => @as(*const f128, @ptrCast(@alignCast(value.handle))).*,
98 else => @trap(),98 else => @trap(),
99 });99 });
100 }100 }
src/InternPool.zig+2-2
...@@ -1365,7 +1365,7 @@ const Local = struct {...@@ -1365,7 +1365,7 @@ const Local = struct {
1365 capacity: u32,1365 capacity: u32,
1366 };1366 };
1367 fn header(list: ListSelf) *Header {1367 fn header(list: ListSelf) *Header {
1368 return @alignCast(@ptrCast(list.bytes - bytes_offset));1368 return @ptrCast(@alignCast(list.bytes - bytes_offset));
1369 }1369 }
1370 pub fn view(list: ListSelf) View {1370 pub fn view(list: ListSelf) View {
1371 const capacity = list.header().capacity;1371 const capacity = list.header().capacity;
...@@ -1574,7 +1574,7 @@ const Shard = struct {...@@ -1574,7 +1574,7 @@ const Shard = struct {
1574 }1574 }
1575 };1575 };
1576 fn header(map: @This()) *Header {1576 fn header(map: @This()) *Header {
1577 return @alignCast(@ptrCast(@as([*]u8, @ptrCast(map.entries)) - entries_offset));1577 return @ptrCast(@alignCast(@as([*]u8, @ptrCast(map.entries)) - entries_offset));
1578 }1578 }
15791579
1580 const Entry = extern struct {1580 const Entry = extern struct {
src/Package/Fetch.zig+1-1
...@@ -898,7 +898,7 @@ const Resource = union(enum) {...@@ -898,7 +898,7 @@ const Resource = union(enum) {
898 }898 }
899899
900 fn read(context: *const anyopaque, buffer: []u8) anyerror!usize {900 fn read(context: *const anyopaque, buffer: []u8) anyerror!usize {
901 const resource: *Resource = @constCast(@ptrCast(@alignCast(context)));901 const resource: *Resource = @ptrCast(@alignCast(@constCast(context)));
902 switch (resource.*) {902 switch (resource.*) {
903 .file => |*f| return f.read(buffer),903 .file => |*f| return f.read(buffer),
904 .http_request => |*r| return r.read(buffer),904 .http_request => |*r| return r.read(buffer),
src/translate_c.zig+3-3
...@@ -4008,11 +4008,11 @@ fn transCreateCompoundAssign(...@@ -4008,11 +4008,11 @@ fn transCreateCompoundAssign(
4008}4008}
40094009
4010fn removeCVQualifiers(c: *Context, dst_type_node: Node, expr: Node) Error!Node {4010fn removeCVQualifiers(c: *Context, dst_type_node: Node, expr: Node) Error!Node {
4011 const const_casted = try Tag.const_cast.create(c.arena, expr);4011 const volatile_casted = try Tag.volatile_cast.create(c.arena, expr);
4012 const volatile_casted = try Tag.volatile_cast.create(c.arena, const_casted);4012 const const_casted = try Tag.const_cast.create(c.arena, volatile_casted);
4013 return Tag.as.create(c.arena, .{4013 return Tag.as.create(c.arena, .{
4014 .lhs = dst_type_node,4014 .lhs = dst_type_node,
4015 .rhs = try Tag.ptr_cast.create(c.arena, volatile_casted),4015 .rhs = try Tag.ptr_cast.create(c.arena, const_casted),
4016 });4016 });
4017}4017}
40184018
test/behavior/array.zig+1-1
...@@ -1091,7 +1091,7 @@ test "initialize pointer to anyopaque with reference to empty array initializer"...@@ -1091,7 +1091,7 @@ test "initialize pointer to anyopaque with reference to empty array initializer"
1091 const ptr: *const anyopaque = &.{};1091 const ptr: *const anyopaque = &.{};
1092 // The above acts like an untyped initializer, since the `.{}` has no result type.1092 // The above acts like an untyped initializer, since the `.{}` has no result type.
1093 // So, `ptr` points in memory to an empty tuple (`@TypeOf(.{})`).1093 // So, `ptr` points in memory to an empty tuple (`@TypeOf(.{})`).
1094 const casted: *const @TypeOf(.{}) = @alignCast(@ptrCast(ptr));1094 const casted: *const @TypeOf(.{}) = @ptrCast(@alignCast(ptr));
1095 const loaded = casted.*;1095 const loaded = casted.*;
1096 // `val` should be a `@TypeOf(.{})`, as expected.1096 // `val` should be a `@TypeOf(.{})`, as expected.
1097 // We can't check the value, but it's zero-bit, so the type matching is good enough.1097 // We can't check the value, but it's zero-bit, so the type matching is good enough.
test/behavior/comptime_memory.zig+1-1
...@@ -477,7 +477,7 @@ fn GenericIntApplier(...@@ -477,7 +477,7 @@ fn GenericIntApplier(
477 }477 }
478478
479 fn typeErasedApplyFn(context: *const anyopaque, arg: u32) void {479 fn typeErasedApplyFn(context: *const anyopaque, arg: u32) void {
480 const ptr: *const Context = @alignCast(@ptrCast(context));480 const ptr: *const Context = @ptrCast(@alignCast(context));
481 applyFn(ptr.*, arg);481 applyFn(ptr.*, arg);
482 }482 }
483 };483 };
test/behavior/extern.zig+1-1
...@@ -8,7 +8,7 @@ test "anyopaque extern symbol" {...@@ -8,7 +8,7 @@ test "anyopaque extern symbol" {
8 if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;8 if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
99
10 const a = @extern(*anyopaque, .{ .name = "a_mystery_symbol" });10 const a = @extern(*anyopaque, .{ .name = "a_mystery_symbol" });
11 const b: *i32 = @alignCast(@ptrCast(a));11 const b: *i32 = @ptrCast(@alignCast(a));
12 try expect(b.* == 1234);12 try expect(b.* == 1234);
13}13}
1414
test/cases/compile_errors/nested_ptr_cast_bad_operand.zig+1-1
...@@ -6,7 +6,7 @@ export fn b() void {...@@ -6,7 +6,7 @@ export fn b() void {
6 _ = @constCast(@volatileCast(123));6 _ = @constCast(@volatileCast(123));
7}7}
8export fn c() void {8export fn c() void {
9 const x: ?*f32 = @constCast(@ptrCast(@addrSpaceCast(@volatileCast(p))));9 const x: ?*f32 = @ptrCast(@addrSpaceCast(@constCast(@volatileCast(p))));
10 _ = x;10 _ = x;
11}11}
1212
test/translate_c.zig+2-2
...@@ -3234,12 +3234,12 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -3234,12 +3234,12 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
3234 \\pub export fn bar(arg_a: [*c]const c_int) void {3234 \\pub export fn bar(arg_a: [*c]const c_int) void {
3235 \\ var a = arg_a;3235 \\ var a = arg_a;
3236 \\ _ = &a;3236 \\ _ = &a;
3237 \\ foo(@as([*c]c_int, @ptrCast(@volatileCast(@constCast(a)))));3237 \\ foo(@as([*c]c_int, @ptrCast(@constCast(@volatileCast(a)))));
3238 \\}3238 \\}
3239 \\pub export fn baz(arg_a: [*c]volatile c_int) void {3239 \\pub export fn baz(arg_a: [*c]volatile c_int) void {
3240 \\ var a = arg_a;3240 \\ var a = arg_a;
3241 \\ _ = &a;3241 \\ _ = &a;
3242 \\ foo(@as([*c]c_int, @ptrCast(@volatileCast(@constCast(a)))));3242 \\ foo(@as([*c]c_int, @ptrCast(@constCast(@volatileCast(a)))));
3243 \\}3243 \\}
3244 });3244 });
32453245