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 /src/TypedValue.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 'src/TypedValue.zig')
| -rw-r--r-- | src/TypedValue.zig | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/src/TypedValue.zig b/src/TypedValue.zig index 159297a4e8..5abcd7b280 100644 --- a/src/TypedValue.zig +++ b/src/TypedValue.zig @@ -242,11 +242,6 @@ pub fn print( } try writer.writeAll("@enumFromInt("); try print(.{ - .ty = Type.type, - .val = enum_tag.ty.toValue(), - }, writer, level - 1, mod); - try writer.writeAll(", "); - try print(.{ .ty = ip.typeOf(enum_tag.int).toType(), .val = enum_tag.int.toValue(), }, writer, level - 1, mod); @@ -255,7 +250,7 @@ pub fn print( }, .empty_enum_value => return writer.writeAll("(empty enum value)"), .float => |float| switch (float.storage) { - inline else => |x| return writer.print("{d}", .{@floatCast(f64, x)}), + inline else => |x| return writer.print("{d}", .{@as(f64, @floatCast(x))}), }, .ptr => |ptr| { if (ptr.addr == .int) { @@ -278,7 +273,7 @@ pub fn print( for (buf[0..max_len], 0..) |*c, i| { const elem = try val.elemValue(mod, i); if (elem.isUndef(mod)) break :str; - c.* = @intCast(u8, elem.toUnsignedInt(mod)); + c.* = @as(u8, @intCast(elem.toUnsignedInt(mod))); } const truncated = if (len > max_string_len) " (truncated)" else ""; return writer.print("\"{}{s}\"", .{ std.zig.fmtEscapes(buf[0..max_len]), truncated }); @@ -357,11 +352,11 @@ pub fn print( if (container_ty.isTuple(mod)) { try writer.print("[{d}]", .{field.index}); } - const field_name = container_ty.structFieldName(@intCast(usize, field.index), mod); + const field_name = container_ty.structFieldName(@as(usize, @intCast(field.index)), mod); try writer.print(".{i}", .{field_name.fmt(ip)}); }, .Union => { - const field_name = container_ty.unionFields(mod).keys()[@intCast(usize, field.index)]; + const field_name = container_ty.unionFields(mod).keys()[@as(usize, @intCast(field.index))]; try writer.print(".{i}", .{field_name.fmt(ip)}); }, .Pointer => { |
