diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-06-24 16:58:19 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-24 16:58:19 -0700 |
| commit | 146b79af153bbd5dafda0ba12a040385c7fc58f8 (patch) | |
| tree | 67e3db8b444d65c667e314770fc983a7fc8ba293 /lib/std/macho.zig | |
| parent | 13853bef0df3c90633021850cc6d6abaeea03282 (diff) | |
| parent | 21ac0beb436f49fe49c6982a872f2dc48e4bea5e (diff) | |
| download | zig-146b79af153bbd5dafda0ba12a040385c7fc58f8.tar.gz zig-146b79af153bbd5dafda0ba12a040385c7fc58f8.zip | |
Merge pull request #16163 from mlugg/feat/builtins-infer-dest-ty
Infer destination type of cast builtins using result type
Diffstat (limited to 'lib/std/macho.zig')
| -rw-r--r-- | lib/std/macho.zig | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/std/macho.zig b/lib/std/macho.zig index 8bddd67023..1b886e2d90 100644 --- a/lib/std/macho.zig +++ b/lib/std/macho.zig @@ -787,7 +787,7 @@ pub const section_64 = extern struct { } pub fn @"type"(sect: section_64) u8 { - return @truncate(u8, sect.flags & 0xff); + return @as(u8, @truncate(sect.flags & 0xff)); } pub fn attrs(sect: section_64) u32 { @@ -1870,7 +1870,7 @@ pub const LoadCommandIterator = struct { pub fn cast(lc: LoadCommand, comptime Cmd: type) ?Cmd { if (lc.data.len < @sizeOf(Cmd)) return null; - return @ptrCast(*const Cmd, @alignCast(@alignOf(Cmd), &lc.data[0])).*; + return @as(*const Cmd, @ptrCast(@alignCast(&lc.data[0]))).*; } /// Asserts LoadCommand is of type segment_command_64. @@ -1878,9 +1878,9 @@ pub const LoadCommandIterator = struct { const segment_lc = lc.cast(segment_command_64).?; if (segment_lc.nsects == 0) return &[0]section_64{}; const data = lc.data[@sizeOf(segment_command_64)..]; - const sections = @ptrCast( + const sections = @as( [*]const section_64, - @alignCast(@alignOf(section_64), &data[0]), + @ptrCast(@alignCast(&data[0])), )[0..segment_lc.nsects]; return sections; } @@ -1903,16 +1903,16 @@ pub const LoadCommandIterator = struct { pub fn next(it: *LoadCommandIterator) ?LoadCommand { if (it.index >= it.ncmds) return null; - const hdr = @ptrCast( + const hdr = @as( *const load_command, - @alignCast(@alignOf(load_command), &it.buffer[0]), + @ptrCast(@alignCast(&it.buffer[0])), ).*; const cmd = LoadCommand{ .hdr = hdr, .data = it.buffer[0..hdr.cmdsize], }; - it.buffer = @alignCast(@alignOf(u64), it.buffer[hdr.cmdsize..]); + it.buffer = @alignCast(it.buffer[hdr.cmdsize..]); it.index += 1; return cmd; |
