all: migrate code to new cast builtin syntax

Most of this migration was performed automatically with `zig fmt`. There
were a few exceptions which I had to manually fix:

* `@alignCast` and `@addrSpaceCast` cannot be automatically rewritten
* `@truncate`'s fixup is incorrect for vectors
* Test cases are not formatted, and their error locations change
This commit is contained in:
mlugg
2023-06-22 18:46:56 +01:00
committed by Andrew Kelley
parent 447ca4e3ff
commit f26dda2117
651 changed files with 8967 additions and 9039 deletions

View File

@@ -170,7 +170,7 @@ test "array with sentinels" {
{
var zero_sized: [0:0xde]u8 = [_:0xde]u8{};
try expect(zero_sized[0] == 0xde);
var reinterpreted = @ptrCast(*[1]u8, &zero_sized);
var reinterpreted = @as(*[1]u8, @ptrCast(&zero_sized));
try expect(reinterpreted[0] == 0xde);
}
var arr: [3:0x55]u8 = undefined;
@@ -694,7 +694,7 @@ test "array init of container level array variable" {
test "runtime initialized sentinel-terminated array literal" {
var c: u16 = 300;
const f = &[_:0x9999]u16{c};
const g = @ptrCast(*const [4]u8, f);
const g = @as(*const [4]u8, @ptrCast(f));
try std.testing.expect(g[2] == 0x99);
try std.testing.expect(g[3] == 0x99);
}