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 /tools | |
| 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 'tools')
| -rw-r--r-- | tools/extract-grammar.zig | 2 | ||||
| -rw-r--r-- | tools/gen_spirv_spec.zig | 2 | ||||
| -rw-r--r-- | tools/gen_stubs.zig | 10 | ||||
| -rw-r--r-- | tools/update-linux-headers.zig | 2 | ||||
| -rw-r--r-- | tools/update_clang_options.zig | 4 |
5 files changed, 10 insertions, 10 deletions
diff --git a/tools/extract-grammar.zig b/tools/extract-grammar.zig index 9a72bf46e4..b251f57741 100644 --- a/tools/extract-grammar.zig +++ b/tools/extract-grammar.zig @@ -90,7 +90,7 @@ fn read(path: []const u8, allocator: mem.Allocator) ![:0]const u8 { const st = try f.stat(); if (st.size > max_src_size) return error.FileTooBig; - const src = try allocator.allocSentinel(u8, @intCast(usize, st.size), 0); + const src = try allocator.allocSentinel(u8, @as(usize, @intCast(st.size)), 0); const n = try f.readAll(src); if (n != st.size) return error.UnexpectedEndOfFile; diff --git a/tools/gen_spirv_spec.zig b/tools/gen_spirv_spec.zig index 91d0ba80ac..9427451a28 100644 --- a/tools/gen_spirv_spec.zig +++ b/tools/gen_spirv_spec.zig @@ -40,7 +40,7 @@ fn extendedStructs( kinds: []const g.OperandKind, ) !ExtendedStructSet { var map = ExtendedStructSet.init(arena); - try map.ensureTotalCapacity(@intCast(u32, kinds.len)); + try map.ensureTotalCapacity(@as(u32, @intCast(kinds.len))); for (kinds) |kind| { const enumerants = kind.enumerants orelse continue; diff --git a/tools/gen_stubs.zig b/tools/gen_stubs.zig index dab45350f9..1b70023666 100644 --- a/tools/gen_stubs.zig +++ b/tools/gen_stubs.zig @@ -441,10 +441,10 @@ fn parseElf(parse: Parse, comptime is_64: bool, comptime endian: builtin.Endian) const sh_name = try arena.dupe(u8, mem.sliceTo(shstrtab[s(shdr.sh_name)..], 0)); log.debug("found section: {s}", .{sh_name}); if (mem.eql(u8, sh_name, ".dynsym")) { - dynsym_index = @intCast(u16, i); + dynsym_index = @as(u16, @intCast(i)); } const gop = try parse.sections.getOrPut(sh_name); - section_index_map[i] = @intCast(u16, gop.index); + section_index_map[i] = @as(u16, @intCast(gop.index)); } if (dynsym_index == 0) @panic("did not find the .dynsym section"); @@ -470,9 +470,9 @@ fn parseElf(parse: Parse, comptime is_64: bool, comptime endian: builtin.Endian) for (copied_dyn_syms) |sym| { const this_section = s(sym.st_shndx); const name = try arena.dupe(u8, mem.sliceTo(dynstr[s(sym.st_name)..], 0)); - const ty = @truncate(u4, sym.st_info); - const binding = @truncate(u4, sym.st_info >> 4); - const visib = @enumFromInt(elf.STV, @truncate(u2, sym.st_other)); + const ty = @as(u4, @truncate(sym.st_info)); + const binding = @as(u4, @truncate(sym.st_info >> 4)); + const visib = @as(elf.STV, @enumFromInt(@as(u2, @truncate(sym.st_other)))); const size = s(sym.st_size); if (parse.blacklist.contains(name)) continue; diff --git a/tools/update-linux-headers.zig b/tools/update-linux-headers.zig index e3a3e9294d..ef701fc86d 100644 --- a/tools/update-linux-headers.zig +++ b/tools/update-linux-headers.zig @@ -112,7 +112,7 @@ const DestTarget = struct { _ = self; var hasher = std.hash.Wyhash.init(0); std.hash.autoHash(&hasher, a.arch); - return @truncate(u32, hasher.final()); + return @as(u32, @truncate(hasher.final())); } pub fn eql(self: @This(), a: DestTarget, b: DestTarget, b_index: usize) bool { diff --git a/tools/update_clang_options.zig b/tools/update_clang_options.zig index 4584a87ef7..6616d5f077 100644 --- a/tools/update_clang_options.zig +++ b/tools/update_clang_options.zig @@ -591,7 +591,7 @@ pub fn main() anyerror!void { for (all_features, 0..) |feat, i| { const llvm_name = feat.llvm_name orelse continue; - const zig_feat = @enumFromInt(Feature, i); + const zig_feat = @as(Feature, @enumFromInt(i)); const zig_name = @tagName(zig_feat); try llvm_to_zig_cpu_features.put(llvm_name, zig_name); } @@ -790,7 +790,7 @@ const Syntax = union(enum) { }; fn objSyntax(obj: *json.ObjectMap) ?Syntax { - const num_args = @intCast(u8, obj.get("NumArgs").?.integer); + const num_args = @as(u8, @intCast(obj.get("NumArgs").?.integer)); for (obj.get("!superclasses").?.array.items) |superclass_json| { const superclass = superclass_json.string; if (std.mem.eql(u8, superclass, "Joined")) { |
