mirror of
https://github.com/ziglang/zig.git
synced 2026-02-12 20:37:54 +00:00
fix casts
This commit is contained in:
parent
03cc81665b
commit
133579d7c0
@ -548,10 +548,11 @@ pub const Compilation = struct {
|
||||
|
||||
comp.deinit_group.wait();
|
||||
|
||||
if (comp.tmp_dir.getOrNull()) |tmp_dir_result| if (tmp_dir_result.*) |tmp_dir| {
|
||||
// TODO evented I/O?
|
||||
std.fs.deleteTree(tmp_dir) catch {};
|
||||
} else |_| {};
|
||||
if (comp.tmp_dir.getOrNull()) |tmp_dir_result|
|
||||
if (tmp_dir_result.*) |tmp_dir| {
|
||||
// TODO evented I/O?
|
||||
std.fs.deleteTree(tmp_dir) catch {};
|
||||
} else |_| {};
|
||||
}
|
||||
|
||||
/// it does ref the result because it could be an arbitrary integer size
|
||||
|
||||
@ -138,7 +138,7 @@ pub const LibCInstallation = struct {
|
||||
self.static_lib_dir orelse "",
|
||||
self.msvc_lib_dir orelse "",
|
||||
self.kernel32_lib_dir orelse "",
|
||||
self.dynamic_linker_path orelse util.getDynamicLinkerPath(Target(Target.Native)),
|
||||
self.dynamic_linker_path orelse util.getDynamicLinkerPath(Target{ .Native = {} }),
|
||||
);
|
||||
}
|
||||
|
||||
@ -382,7 +382,7 @@ pub const LibCInstallation = struct {
|
||||
|
||||
fn initEmpty(self: *LibCInstallation) void {
|
||||
self.* = LibCInstallation{
|
||||
.include_dir = ([*]const u8)(undefined)[0..0],
|
||||
.include_dir = @as([*]const u8, undefined)[0..0],
|
||||
.lib_dir = null,
|
||||
.static_lib_dir = null,
|
||||
.msvc_lib_dir = null,
|
||||
|
||||
@ -631,7 +631,7 @@ fn cmdFmt(allocator: *Allocator, args: []const []const u8) !void {
|
||||
}
|
||||
if (flags.present("check")) {
|
||||
const anything_changed = try std.zig.render(allocator, io.null_out_stream, tree);
|
||||
const code = if (anything_changed) u8(1) else u8(0);
|
||||
const code: u8 = if (anything_changed) 1 else 0;
|
||||
process.exit(code);
|
||||
}
|
||||
|
||||
|
||||
@ -294,7 +294,7 @@ pub const Type = struct {
|
||||
if (self.alignment) |self_align| {
|
||||
if (self_align != other.alignment.?) return false;
|
||||
}
|
||||
if (@TagType(Data)(self.data) != @TagType(Data)(other.data)) return false;
|
||||
if (@as(@TagType(Data), self.data) != @as(@TagType(Data), other.data)) return false;
|
||||
switch (self.data) {
|
||||
.Generic => |*self_generic| {
|
||||
const other_generic = &other.data.Generic;
|
||||
@ -665,7 +665,7 @@ pub const Type = struct {
|
||||
self.mut != other.mut or
|
||||
self.vol != other.vol or
|
||||
self.size != other.size or
|
||||
@TagType(Align)(self.alignment) != @TagType(Align)(other.alignment))
|
||||
@as(@TagType(Align), self.alignment) != @as(@TagType(Align), other.alignment))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -1058,7 +1058,7 @@ fn hashAny(x: var, comptime seed: u64) u32 {
|
||||
comptime var rng = comptime std.rand.DefaultPrng.init(seed);
|
||||
const unsigned_x = @bitCast(@IntType(false, info.bits), x);
|
||||
if (info.bits <= 32) {
|
||||
return u32(unsigned_x) *% comptime rng.random.scalar(u32);
|
||||
return @as(u32, unsigned_x) *% comptime rng.random.scalar(u32);
|
||||
} else {
|
||||
return @truncate(u32, unsigned_x *% comptime rng.random.scalar(@typeOf(unsigned_x)));
|
||||
}
|
||||
@ -1081,7 +1081,7 @@ fn hashAny(x: var, comptime seed: u64) u32 {
|
||||
if (x) |non_opt| {
|
||||
return hashAny(non_opt, seed);
|
||||
} else {
|
||||
return hashAny(u32(1), seed);
|
||||
return hashAny(@as(u32, 1), seed);
|
||||
}
|
||||
},
|
||||
else => @compileError("implement hash function for " ++ @typeName(@typeOf(x))),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user