aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Compilation.zig12
-rw-r--r--src/DepTokenizer.zig6
-rw-r--r--src/Module.zig22
-rw-r--r--src/astgen.zig6
-rw-r--r--src/codegen/c.zig6
-rw-r--r--src/glibc.zig28
-rw-r--r--src/link.zig2
-rw-r--r--src/link/Elf.zig6
-rw-r--r--src/liveness.zig3
-rw-r--r--src/main.zig14
-rw-r--r--src/translate_c.zig18
-rw-r--r--src/type.zig8
-rw-r--r--src/zir.zig19
-rw-r--r--src/zir_sema.zig14
14 files changed, 82 insertions, 82 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig
index c688cf7980..de115b9b40 100644
--- a/src/Compilation.zig
+++ b/src/Compilation.zig
@@ -1512,7 +1512,7 @@ pub fn performAllTheWork(self: *Compilation) error{ TimerUnsupported, OutOfMemor
module.failed_decls.putAssumeCapacityNoClobber(decl, try ErrorMsg.create(
module.gpa,
decl.src(),
- "unable to generate C header: {}",
+ "unable to generate C header: {s}",
.{@errorName(err)},
));
decl.analysis = .codegen_failure_retryable;
@@ -1593,7 +1593,7 @@ pub fn performAllTheWork(self: *Compilation) error{ TimerUnsupported, OutOfMemor
.libtsan => {
libtsan.buildTsan(self) catch |err| {
// TODO Expose this as a normal compile error rather than crashing here.
- fatal("unable to build TSAN library: {}", .{@errorName(err)});
+ fatal("unable to build TSAN library: {s}", .{@errorName(err)});
};
},
.compiler_rt_lib => {
@@ -1983,7 +1983,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_comp_progress_node: *
// TODO parse clang stderr and turn it into an error message
// and then call failCObjWithOwnedErrorMsg
log.err("clang failed with stderr: {s}", .{stderr});
- return comp.failCObj(c_object, "clang exited with code {}", .{code});
+ return comp.failCObj(c_object, "clang exited with code {d}", .{code});
}
},
else => {
@@ -3013,7 +3013,7 @@ fn updateStage1Module(comp: *Compilation, main_progress_node: *std.Progress.Node
id_symlink_basename,
&prev_digest_buf,
) catch |err| blk: {
- log.debug("stage1 {} new_digest={} error: {s}", .{ mod.root_pkg.root_src_path, digest, @errorName(err) });
+ log.debug("stage1 {s} new_digest={} error: {s}", .{ mod.root_pkg.root_src_path, digest, @errorName(err) });
// Handle this as a cache miss.
break :blk prev_digest_buf[0..0];
};
@@ -3021,7 +3021,7 @@ fn updateStage1Module(comp: *Compilation, main_progress_node: *std.Progress.Node
if (!mem.eql(u8, prev_digest[0..digest.len], &digest))
break :hit;
- log.debug("stage1 {} digest={} match - skipping invocation", .{ mod.root_pkg.root_src_path, digest });
+ log.debug("stage1 {s} digest={} match - skipping invocation", .{ mod.root_pkg.root_src_path, digest });
var flags_bytes: [1]u8 = undefined;
_ = std.fmt.hexToBytes(&flags_bytes, prev_digest[digest.len..]) catch {
log.warn("bad cache stage1 digest: '{s}'", .{prev_digest});
@@ -3044,7 +3044,7 @@ fn updateStage1Module(comp: *Compilation, main_progress_node: *std.Progress.Node
mod.stage1_flags = @bitCast(@TypeOf(mod.stage1_flags), flags_bytes[0]);
return;
}
- log.debug("stage1 {} prev_digest={} new_digest={}", .{ mod.root_pkg.root_src_path, prev_digest, digest });
+ log.debug("stage1 {s} prev_digest={} new_digest={}", .{ mod.root_pkg.root_src_path, prev_digest, digest });
man.unhit(prev_hash_state, input_file_count);
}
diff --git a/src/DepTokenizer.zig b/src/DepTokenizer.zig
index c42583a786..0872513b51 100644
--- a/src/DepTokenizer.zig
+++ b/src/DepTokenizer.zig
@@ -373,7 +373,7 @@ pub const Token = union(enum) {
} else {
try printCharValues(writer, index_and_bytes.bytes);
}
- try writer.print("' at position {}", .{index_and_bytes.index});
+ try writer.print("' at position {d}", .{index_and_bytes.index});
},
.invalid_target,
.bad_target_escape,
@@ -383,7 +383,7 @@ pub const Token = union(enum) {
=> |index_and_char| {
try writer.writeAll("illegal char ");
try printUnderstandableChar(writer, index_and_char.char);
- try writer.print(" at position {}: {s}", .{ index_and_char.index, self.errStr() });
+ try writer.print(" at position {d}: {s}", .{ index_and_char.index, self.errStr() });
},
}
}
@@ -943,7 +943,7 @@ fn printSection(out: anytype, label: []const u8, bytes: []const u8) !void {
fn printLabel(out: anytype, label: []const u8, bytes: []const u8) !void {
var buf: [80]u8 = undefined;
- var text = try std.fmt.bufPrint(buf[0..], "{s} {} bytes ", .{ label, bytes.len });
+ var text = try std.fmt.bufPrint(buf[0..], "{s} {d} bytes ", .{ label, bytes.len });
try out.writeAll(text);
var i: usize = text.len;
const end = 79;
diff --git a/src/Module.zig b/src/Module.zig
index 0d03703dcb..d1719059c4 100644
--- a/src/Module.zig
+++ b/src/Module.zig
@@ -248,7 +248,7 @@ pub const Decl = struct {
pub fn dump(self: *Decl) void {
const loc = std.zig.findLineColumn(self.scope.source.bytes, self.src);
- std.debug.print("{}:{}:{} name={} status={}", .{
+ std.debug.print("{s}:{d}:{d} name={s} status={s}", .{
self.scope.sub_file_path,
loc.line + 1,
loc.column + 1,
@@ -308,7 +308,7 @@ pub const Fn = struct {
/// For debugging purposes.
pub fn dump(self: *Fn, mod: Module) void {
- std.debug.print("Module.Function(name={}) ", .{self.owner_decl.name});
+ std.debug.print("Module.Function(name={s}) ", .{self.owner_decl.name});
switch (self.analysis) {
.queued => {
std.debug.print("queued\n", .{});
@@ -632,7 +632,7 @@ pub const Scope = struct {
pub fn dumpSrc(self: *File, src: usize) void {
const loc = std.zig.findLineColumn(self.source.bytes, src);
- std.debug.print("{}:{}:{}\n", .{ self.sub_file_path, loc.line + 1, loc.column + 1 });
+ std.debug.print("{s}:{d}:{d}\n", .{ self.sub_file_path, loc.line + 1, loc.column + 1 });
}
pub fn getSource(self: *File, module: *Module) ![:0]const u8 {
@@ -730,7 +730,7 @@ pub const Scope = struct {
pub fn dumpSrc(self: *ZIRModule, src: usize) void {
const loc = std.zig.findLineColumn(self.source.bytes, src);
- std.debug.print("{}:{}:{}\n", .{ self.sub_file_path, loc.line + 1, loc.column + 1 });
+ std.debug.print("{s}:{d}:{d}\n", .{ self.sub_file_path, loc.line + 1, loc.column + 1 });
}
pub fn getSource(self: *ZIRModule, module: *Module) ![:0]const u8 {
@@ -1641,7 +1641,7 @@ pub fn analyzeContainer(self: *Module, container_scope: *Scope.Container) !void
}
} else if (src_decl.castTag(.Comptime)) |comptime_node| {
const name_index = self.getNextAnonNameIndex();
- const name = try std.fmt.allocPrint(self.gpa, "__comptime_{}", .{name_index});
+ const name = try std.fmt.allocPrint(self.gpa, "__comptime_{d}", .{name_index});
defer self.gpa.free(name);
const name_hash = container_scope.fullyQualifiedNameHash(name);
@@ -2277,7 +2277,7 @@ pub fn createAnonymousDecl(
) !*Decl {
const name_index = self.getNextAnonNameIndex();
const scope_decl = scope.decl().?;
- const name = try std.fmt.allocPrint(self.gpa, "{s}__anon_{}", .{ scope_decl.name, name_index });
+ const name = try std.fmt.allocPrint(self.gpa, "{s}__anon_{d}", .{ scope_decl.name, name_index });
defer self.gpa.free(name);
const name_hash = scope.namespace().fullyQualifiedNameHash(name);
const src_hash: std.zig.SrcHash = undefined;
@@ -2555,7 +2555,7 @@ pub fn cmpNumeric(
if (lhs_ty_tag == .Vector and rhs_ty_tag == .Vector) {
if (lhs.ty.arrayLen() != rhs.ty.arrayLen()) {
- return self.fail(scope, src, "vector length mismatch: {} and {}", .{
+ return self.fail(scope, src, "vector length mismatch: {d} and {d}", .{
lhs.ty.arrayLen(),
rhs.ty.arrayLen(),
});
@@ -2700,7 +2700,7 @@ pub fn cmpNumeric(
const dest_type = if (dest_float_type) |ft| ft else blk: {
const max_bits = std.math.max(lhs_bits, rhs_bits);
const casted_bits = std.math.cast(u16, max_bits) catch |err| switch (err) {
- error.Overflow => return self.fail(scope, src, "{} exceeds maximum integer bit count", .{max_bits}),
+ error.Overflow => return self.fail(scope, src, "{d} exceeds maximum integer bit count", .{max_bits}),
};
break :blk try self.makeIntType(scope, dest_int_is_signed, casted_bits);
};
@@ -3319,7 +3319,7 @@ pub fn dumpInst(self: *Module, scope: *Scope, inst: *Inst) void {
const source = zir_module.getSource(self) catch @panic("dumpInst failed to get source");
const loc = std.zig.findLineColumn(source, inst.src);
if (inst.tag == .constant) {
- std.debug.print("constant ty={} val={} src={}:{}:{}\n", .{
+ std.debug.print("constant ty={} val={} src={s}:{d}:{d}\n", .{
inst.ty,
inst.castTag(.constant).?.val,
zir_module.subFilePath(),
@@ -3327,7 +3327,7 @@ pub fn dumpInst(self: *Module, scope: *Scope, inst: *Inst) void {
loc.column + 1,
});
} else if (inst.deaths == 0) {
- std.debug.print("{} ty={} src={}:{}:{}\n", .{
+ std.debug.print("{s} ty={} src={s}:{d}:{d}\n", .{
@tagName(inst.tag),
inst.ty,
zir_module.subFilePath(),
@@ -3335,7 +3335,7 @@ pub fn dumpInst(self: *Module, scope: *Scope, inst: *Inst) void {
loc.column + 1,
});
} else {
- std.debug.print("{} ty={} deaths={b} src={}:{}:{}\n", .{
+ std.debug.print("{s} ty={} deaths={b} src={s}:{d}:{d}\n", .{
@tagName(inst.tag),
inst.ty,
inst.deaths,
diff --git a/src/astgen.zig b/src/astgen.zig
index b3cb648dcb..a50fa026ca 100644
--- a/src/astgen.zig
+++ b/src/astgen.zig
@@ -385,7 +385,7 @@ fn breakExpr(mod: *Module, parent_scope: *Scope, node: *ast.Node.ControlFlowExpr
.local_ptr => scope = scope.cast(Scope.LocalPtr).?.parent,
else => if (node.getLabel()) |break_label| {
const label_name = try identifierTokenString(mod, parent_scope, break_label);
- return mod.failTok(parent_scope, break_label, "label not found: '{}'", .{label_name});
+ return mod.failTok(parent_scope, break_label, "label not found: '{s}'", .{label_name});
} else {
return mod.failTok(parent_scope, src, "break expression outside loop", .{});
},
@@ -427,7 +427,7 @@ fn continueExpr(mod: *Module, parent_scope: *Scope, node: *ast.Node.ControlFlowE
.local_ptr => scope = scope.cast(Scope.LocalPtr).?.parent,
else => if (node.getLabel()) |break_label| {
const label_name = try identifierTokenString(mod, parent_scope, break_label);
- return mod.failTok(parent_scope, break_label, "label not found: '{}'", .{label_name});
+ return mod.failTok(parent_scope, break_label, "label not found: '{s}'", .{label_name});
} else {
return mod.failTok(parent_scope, src, "continue expression outside loop", .{});
},
@@ -2204,7 +2204,7 @@ fn ensureBuiltinParamCount(mod: *Module, scope: *Scope, call: *ast.Node.BuiltinC
return;
const s = if (count == 1) "" else "s";
- return mod.failTok(scope, call.builtin_token, "expected {} parameter{s}, found {}", .{ count, s, call.params_len });
+ return mod.failTok(scope, call.builtin_token, "expected {d} parameter{s}, found {d}", .{ count, s, call.params_len });
}
fn simpleCast(
diff --git a/src/codegen/c.zig b/src/codegen/c.zig
index 37654b8ce0..684a03eb79 100644
--- a/src/codegen/c.zig
+++ b/src/codegen/c.zig
@@ -383,7 +383,7 @@ const Context = struct {
}
fn name(self: *Context) ![]u8 {
- const val = try std.fmt.allocPrint(&self.arena.allocator, "__temp_{}", .{self.unnamed_index});
+ const val = try std.fmt.allocPrint(&self.arena.allocator, "__temp_{d}", .{self.unnamed_index});
self.unnamed_index += 1;
return val;
}
@@ -420,7 +420,7 @@ fn genAlloc(ctx: *Context, file: *C, alloc: *Inst.NoOp) !?[]u8 {
}
fn genArg(ctx: *Context) !?[]u8 {
- const name = try std.fmt.allocPrint(&ctx.arena.allocator, "arg{}", .{ctx.argdex});
+ const name = try std.fmt.allocPrint(&ctx.arena.allocator, "arg{d}", .{ctx.argdex});
ctx.argdex += 1;
return name;
}
@@ -528,7 +528,7 @@ fn genCall(ctx: *Context, file: *C, inst: *Inst.Call) !?[]u8 {
try renderValue(ctx, writer, arg.ty, val);
} else {
const val = try ctx.resolveInst(arg);
- try writer.print("{}", .{val});
+ try writer.print("{s}", .{val});
}
}
}
diff --git a/src/glibc.zig b/src/glibc.zig
index f69dd11ada..e7b7b1b1cf 100644
--- a/src/glibc.zig
+++ b/src/glibc.zig
@@ -111,12 +111,12 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError!
while (it.next()) |line| : (line_i += 1) {
const prefix = "GLIBC_";
if (!mem.startsWith(u8, line, prefix)) {
- std.log.err("vers.txt:{}: expected 'GLIBC_' prefix", .{line_i});
+ std.log.err("vers.txt:{d}: expected 'GLIBC_' prefix", .{line_i});
return error.ZigInstallationCorrupt;
}
const adjusted_line = line[prefix.len..];
const ver = std.builtin.Version.parse(adjusted_line) catch |err| {
- std.log.err("vers.txt:{}: unable to parse glibc version '{s}': {s}", .{ line_i, line, @errorName(err) });
+ std.log.err("vers.txt:{d}: unable to parse glibc version '{s}': {s}", .{ line_i, line, @errorName(err) });
return error.ZigInstallationCorrupt;
};
try all_versions.append(arena, ver);
@@ -128,15 +128,15 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError!
while (file_it.next()) |line| : (line_i += 1) {
var line_it = mem.tokenize(line, " ");
const fn_name = line_it.next() orelse {
- std.log.err("fns.txt:{}: expected function name", .{line_i});
+ std.log.err("fns.txt:{d}: expected function name", .{line_i});
return error.ZigInstallationCorrupt;
};
const lib_name = line_it.next() orelse {
- std.log.err("fns.txt:{}: expected library name", .{line_i});
+ std.log.err("fns.txt:{d}: expected library name", .{line_i});
return error.ZigInstallationCorrupt;
};
const lib = findLib(lib_name) orelse {
- std.log.err("fns.txt:{}: unknown library name: {s}", .{ line_i, lib_name });
+ std.log.err("fns.txt:{d}: unknown library name: {s}", .{ line_i, lib_name });
return error.ZigInstallationCorrupt;
};
try all_functions.append(arena, .{
@@ -158,27 +158,27 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError!
while (line_it.next()) |target_string| {
var component_it = mem.tokenize(target_string, "-");
const arch_name = component_it.next() orelse {
- std.log.err("abi.txt:{}: expected arch name", .{line_i});
+ std.log.err("abi.txt:{d}: expected arch name", .{line_i});
return error.ZigInstallationCorrupt;
};
const os_name = component_it.next() orelse {
- std.log.err("abi.txt:{}: expected OS name", .{line_i});
+ std.log.err("abi.txt:{d}: expected OS name", .{line_i});
return error.ZigInstallationCorrupt;
};
const abi_name = component_it.next() orelse {
- std.log.err("abi.txt:{}: expected ABI name", .{line_i});
+ std.log.err("abi.txt:{d}: expected ABI name", .{line_i});
return error.ZigInstallationCorrupt;
};
const arch_tag = std.meta.stringToEnum(std.Target.Cpu.Arch, arch_name) orelse {
- std.log.err("abi.txt:{}: unrecognized arch: '{s}'", .{ line_i, arch_name });
+ std.log.err("abi.txt:{d}: unrecognized arch: '{s}'", .{ line_i, arch_name });
return error.ZigInstallationCorrupt;
};
if (!mem.eql(u8, os_name, "linux")) {
- std.log.err("abi.txt:{}: expected OS 'linux', found '{s}'", .{ line_i, os_name });
+ std.log.err("abi.txt:{d}: expected OS 'linux', found '{s}'", .{ line_i, os_name });
return error.ZigInstallationCorrupt;
}
const abi_tag = std.meta.stringToEnum(std.Target.Abi, abi_name) orelse {
- std.log.err("abi.txt:{}: unrecognized ABI: '{s}'", .{ line_i, abi_name });
+ std.log.err("abi.txt:{d}: unrecognized ABI: '{s}'", .{ line_i, abi_name });
return error.ZigInstallationCorrupt;
};
@@ -193,7 +193,7 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError!
};
for (ver_list_base) |*ver_list| {
const line = file_it.next() orelse {
- std.log.err("abi.txt:{}: missing version number line", .{line_i});
+ std.log.err("abi.txt:{d}: missing version number line", .{line_i});
return error.ZigInstallationCorrupt;
};
line_i += 1;
@@ -206,12 +206,12 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError!
while (line_it.next()) |version_index_string| {
if (ver_list.len >= ver_list.versions.len) {
// If this happens with legit data, increase the array len in the type.
- std.log.err("abi.txt:{}: too many versions", .{line_i});
+ std.log.err("abi.txt:{d}: too many versions", .{line_i});
return error.ZigInstallationCorrupt;
}
const version_index = std.fmt.parseInt(u8, version_index_string, 10) catch |err| {
// If this happens with legit data, increase the size of the integer type in the struct.
- std.log.err("abi.txt:{}: unable to parse version: {s}", .{ line_i, @errorName(err) });
+ std.log.err("abi.txt:{d}: unable to parse version: {s}", .{ line_i, @errorName(err) });
return error.ZigInstallationCorrupt;
};
diff --git a/src/link.zig b/src/link.zig
index 92702c7973..3dbfb3b922 100644
--- a/src/link.zig
+++ b/src/link.zig
@@ -523,7 +523,7 @@ pub const File = struct {
id_symlink_basename,
&prev_digest_buf,
) catch |err| b: {
- log.debug("archive new_digest={} readFile error: {}", .{ digest, @errorName(err) });
+ log.debug("archive new_digest={} readFile error: {s}", .{ digest, @errorName(err) });
break :b prev_digest_buf[0..0];
};
if (mem.eql(u8, prev_digest, &digest)) {
diff --git a/src/link/Elf.zig b/src/link/Elf.zig
index 5d0e897008..116d7c9859 100644
--- a/src/link/Elf.zig
+++ b/src/link/Elf.zig
@@ -2082,10 +2082,10 @@ pub fn allocateDeclIndexes(self: *Elf, decl: *Module.Decl) !void {
try self.offset_table.ensureCapacity(self.base.allocator, self.offset_table.items.len + 1);
if (self.local_symbol_free_list.popOrNull()) |i| {
- log.debug("reusing symbol index {} for {s}\n", .{ i, decl.name });
+ log.debug("reusing symbol index {d} for {s}\n", .{ i, decl.name });
decl.link.elf.local_sym_index = i;
} else {
- log.debug("allocating symbol index {} for {s}\n", .{ self.local_symbols.items.len, decl.name });
+ log.debug("allocating symbol index {d} for {s}\n", .{ self.local_symbols.items.len, decl.name });
decl.link.elf.local_sym_index = @intCast(u32, self.local_symbols.items.len);
_ = self.local_symbols.addOneAssumeCapacity();
}
@@ -2432,7 +2432,7 @@ pub fn updateDecl(self: *Elf, module: *Module, decl: *Module.Decl) !void {
if (needed_size > self.allocatedSize(debug_line_sect.sh_offset)) {
const new_offset = self.findFreeSpace(needed_size, 1);
const existing_size = last_src_fn.off;
- log.debug("moving .debug_line section: {} bytes from 0x{x} to 0x{x}\n", .{
+ log.debug("moving .debug_line section: {d} bytes from 0x{x} to 0x{x}\n", .{
existing_size,
debug_line_sect.sh_offset,
new_offset,
diff --git a/src/liveness.zig b/src/liveness.zig
index 0d759f8312..b0aafa28f1 100644
--- a/src/liveness.zig
+++ b/src/liveness.zig
@@ -1,6 +1,7 @@
const std = @import("std");
const ir = @import("ir.zig");
const trace = @import("tracy.zig").trace;
+const log = std.log.scoped(.liveness);
/// Perform Liveness Analysis over the `Body`. Each `Inst` will have its `deaths` field populated.
pub fn analyze(
@@ -248,5 +249,5 @@ fn analyzeInst(
@panic("Handle liveness analysis for instructions with many parameters");
}
- std.log.scoped(.liveness).debug("analyze {}: 0b{b}\n", .{ base.tag, base.deaths });
+ log.debug("analyze {}: 0b{b}\n", .{ base.tag, base.deaths });
}
diff --git a/src/main.zig b/src/main.zig
index 7d03ea956f..b1243badff 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -626,7 +626,7 @@ fn buildOutputType(
fs.path.dirname(pkg_path),
fs.path.basename(pkg_path),
) catch |err| {
- fatal("Failed to add package at path {}: {}", .{ pkg_path, @errorName(err) });
+ fatal("Failed to add package at path {s}: {s}", .{ pkg_path, @errorName(err) });
};
new_cur_pkg.parent = cur_pkg;
try cur_pkg.add(gpa, pkg_name, new_cur_pkg);
@@ -696,13 +696,13 @@ fn buildOutputType(
if (i + 1 >= args.len) fatal("expected parameter after {s}", .{arg});
i += 1;
stack_size_override = std.fmt.parseUnsigned(u64, args[i], 0) catch |err| {
- fatal("unable to parse '{}': {}", .{ arg, @errorName(err) });
+ fatal("unable to parse '{s}': {s}", .{ arg, @errorName(err) });
};
} else if (mem.eql(u8, arg, "--image-base")) {
if (i + 1 >= args.len) fatal("expected parameter after {s}", .{arg});
i += 1;
image_base_override = std.fmt.parseUnsigned(u64, args[i], 0) catch |err| {
- fatal("unable to parse '{}': {}", .{ arg, @errorName(err) });
+ fatal("unable to parse '{s}': {s}", .{ arg, @errorName(err) });
};
} else if (mem.eql(u8, arg, "--name")) {
if (i + 1 >= args.len) fatal("expected parameter after {s}", .{arg});
@@ -1914,7 +1914,7 @@ fn buildOutputType(
if (!watch) return cleanExit();
} else {
const cmd = try argvCmd(arena, argv.items);
- fatal("the following test command failed with exit code {}:\n{s}", .{ code, cmd });
+ fatal("the following test command failed with exit code {d}:\n{s}", .{ code, cmd });
}
},
else => {
@@ -2069,7 +2069,7 @@ fn cmdTranslateC(comp: *Compilation, arena: *Allocator, enable_cache: bool) !voi
error.ASTUnitFailure => fatal("clang API returned errors but due to a clang bug, it is not exposing the errors for zig to see. For more details: https://github.com/ziglang/zig/issues/4455", .{}),
error.SemanticAnalyzeFail => {
for (clang_errors) |clang_err| {
- std.debug.print("{s}:{}:{}: {s}\n", .{
+ std.debug.print("{s}:{d}:{d}: {s}\n", .{
if (clang_err.filename_ptr) |p| p[0..clang_err.filename_len] else "(no file)",
clang_err.line + 1,
clang_err.column + 1,
@@ -2493,7 +2493,7 @@ pub fn cmdBuild(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !v
.Exited => |code| {
if (code == 0) return cleanExit();
const cmd = try argvCmd(arena, child_argv);
- fatal("the following build command failed with exit code {}:\n{s}", .{ code, cmd });
+ fatal("the following build command failed with exit code {d}:\n{s}", .{ code, cmd });
},
else => {
const cmd = try argvCmd(arena, child_argv);
@@ -2812,7 +2812,7 @@ fn printErrMsgToFile(
const text = text_buf.items;
const stream = file.outStream();
- try stream.print("{s}:{}:{}: error: {s}\n", .{ path, start_loc.line + 1, start_loc.column + 1, text });
+ try stream.print("{s}:{d}:{d}: error: {s}\n", .{ path, start_loc.line + 1, start_loc.column + 1, text });
if (!color_on) return;
diff --git a/src/translate_c.zig b/src/translate_c.zig
index c609597770..1b6455fd4d 100644
--- a/src/translate_c.zig
+++ b/src/translate_c.zig
@@ -136,7 +136,7 @@ const Scope = struct {
var proposed_name = name_copy;
while (scope.contains(proposed_name)) {
scope.mangle_count += 1;
- proposed_name = try std.fmt.allocPrint(c.arena, "{s}_{}", .{ name, scope.mangle_count });
+ proposed_name = try std.fmt.allocPrint(c.arena, "{s}_{d}", .{ name, scope.mangle_count });
}
try scope.variables.append(.{ .name = name_copy, .alias = proposed_name });
return proposed_name;
@@ -440,7 +440,7 @@ pub fn translate(
mem.copy(*ast.Node, root_node.decls(), context.root_decls.items);
if (false) {
- std.debug.warn("debug source:\n{}\n==EOF==\ntokens:\n", .{source_buffer.items});
+ std.debug.warn("debug source:\n{s}\n==EOF==\ntokens:\n", .{source_buffer.items});
for (context.token_ids.items) |token| {
std.debug.warn("{}\n", .{token});
}
@@ -945,7 +945,7 @@ fn transRecordDecl(c: *Context, record_decl: *const clang.RecordDecl) Error!?*as
// Record declarations such as `struct {...} x` have no name but they're not
// anonymous hence here isAnonymousStructOrUnion is not needed
if (bare_name.len == 0) {
- bare_name = try std.fmt.allocPrint(c.arena, "unnamed_{}", .{c.getMangle()});
+ bare_name = try std.fmt.allocPrint(c.arena, "unnamed_{d}", .{c.getMangle()});
is_unnamed = true;
}
@@ -1019,7 +1019,7 @@ fn transRecordDecl(c: *Context, record_decl: *const clang.RecordDecl) Error!?*as
var raw_name = try c.str(@ptrCast(*const clang.NamedDecl, field_decl).getName_bytes_begin());
if (field_decl.isAnonymousStructOrUnion() or raw_name.len == 0) {
// Context.getMangle() is not used here because doing so causes unpredictable field names for anonymous fields.
- raw_name = try std.fmt.allocPrint(c.arena, "unnamed_{}", .{unnamed_field_count});
+ raw_name = try std.fmt.allocPrint(c.arena, "unnamed_{d}", .{unnamed_field_count});
unnamed_field_count += 1;
is_anon = true;
}
@@ -1110,7 +1110,7 @@ fn transEnumDecl(c: *Context, enum_decl: *const clang.EnumDecl) Error!?*ast.Node
var bare_name = try c.str(@ptrCast(*const clang.NamedDecl, enum_decl).getName_bytes_begin());
var is_unnamed = false;
if (bare_name.len == 0) {
- bare_name = try std.fmt.allocPrint(c.arena, "unnamed_{}", .{c.getMangle()});
+ bare_name = try std.fmt.allocPrint(c.arena, "unnamed_{d}", .{c.getMangle()});
is_unnamed = true;
}
@@ -3956,7 +3956,7 @@ fn qualTypeToLog2IntRef(rp: RestorePoint, qt: clang.QualType, source_loc: clang.
const node = try rp.c.arena.create(ast.Node.OneToken);
node.* = .{
.base = .{ .tag = .IntegerLiteral },
- .token = try appendTokenFmt(rp.c, .Identifier, "u{}", .{cast_bit_width}),
+ .token = try appendTokenFmt(rp.c, .Identifier, "u{d}", .{cast_bit_width}),
};
return &node.base;
}
@@ -4484,7 +4484,7 @@ fn transCreateNodeMacroFn(c: *Context, name: []const u8, ref: *ast.Node, proto_a
_ = try appendToken(c, .Comma, ",");
}
const param_name_tok = param.name_token orelse
- try appendTokenFmt(c, .Identifier, "arg_{}", .{c.getMangle()});
+ try appendTokenFmt(c, .Identifier, "arg_{d}", .{c.getMangle()});
_ = try appendToken(c, .Colon, ":");
@@ -5916,11 +5916,11 @@ fn parseCPrimaryExprInner(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!*
// struct Foo will be declared as struct_Foo by transRecordDecl
const next_id = m.next().?;
if (next_id != .Identifier) {
- try m.fail(c, "unable to translate C expr: expected Identifier instead got: {}", .{@tagName(next_id)});
+ try m.fail(c, "unable to translate C expr: expected Identifier instead got: {s}", .{@tagName(next_id)});
return error.ParseError;
}
- const ident_token = try appendTokenFmt(c, .Identifier, "{}_{}", .{ slice, m.slice() });
+ const ident_token = try appendTokenFmt(c, .Identifier, "{s}_{s}", .{ slice, m.slice() });
const identifier = try c.arena.create(ast.Node.OneToken);
identifier.* = .{
.base = .{ .tag = .Identifier },
diff --git a/src/type.zig b/src/type.zig
index bb2e3b3bc2..9e2cd321f0 100644
--- a/src/type.zig
+++ b/src/type.zig
@@ -558,21 +558,21 @@ pub const Type = extern union {
},
.array_u8 => {
const len = ty.castTag(.array_u8).?.data;
- return out_stream.print("[{}]u8", .{len});
+ return out_stream.print("[{d}]u8", .{len});
},
.array_u8_sentinel_0 => {
const len = ty.castTag(.array_u8_sentinel_0).?.data;
- return out_stream.print("[{}:0]u8", .{len});
+ return out_stream.print("[{d}:0]u8", .{len});
},
.array => {
const payload = ty.castTag(.array).?.data;
- try out_stream.print("[{}]", .{payload.len});
+ try out_stream.print("[{d}]", .{payload.len});
ty = payload.elem_type;
continue;
},
.array_sentinel => {
const payload = ty.castTag(.array_sentinel).?.data;
- try out_stream.print("[{}:{}]", .{ payload.len, payload.sentinel });
+ try out_stream.print("[{d}:{}]", .{ payload.len, payload.sentinel });
ty = payload.elem_type;
continue;
},
diff --git a/src/zir.zig b/src/zir.zig
index 94e2b24b0c..0593cbd8fd 100644
--- a/src/zir.zig
+++ b/src/zir.zig
@@ -1257,12 +1257,12 @@ const Writer = struct {
self.next_instr_index += 1;
try self.inst_table.putNoClobber(inst, .{ .inst = inst, .index = my_i, .name = undefined });
try stream.writeByteNTimes(' ', self.indent);
- try stream.print("%{} ", .{my_i});
+ try stream.print("%{d} ", .{my_i});
if (inst.cast(Inst.Block)) |block| {
- const name = try std.fmt.allocPrint(&self.arena.allocator, "label_{}", .{my_i});
+ const name = try std.fmt.allocPrint(&self.arena.allocator, "label_{d}", .{my_i});
try self.block_table.put(block, name);
} else if (inst.cast(Inst.Loop)) |loop| {
- const name = try std.fmt.allocPrint(&self.arena.allocator, "loop_{}", .{my_i});
+ const name = try std.fmt.allocPrint(&self.arena.allocator, "loop_{d}", .{my_i});
try self.loop_table.put(loop, name);
}
self.indent += 2;
@@ -1332,7 +1332,7 @@ const Writer = struct {
fn writeInstParamToStream(self: *Writer, stream: anytype, inst: *Inst) !void {
if (self.inst_table.get(inst)) |info| {
if (info.index) |i| {
- try stream.print("%{}", .{info.index});
+ try stream.print("%{d}", .{info.index});
} else {
try stream.print("@{s}", .{info.name});
}
@@ -1660,7 +1660,6 @@ const Parser = struct {
.contents_hash = std.zig.hashSrc(self.source[contents_start..self.i]),
.inst = &inst_specific.base,
};
- //std.debug.warn("parsed {} = '{}'\n", .{ inst_specific.base.name, inst_specific.base.contents });
return decl;
}
@@ -1805,7 +1804,7 @@ const Parser = struct {
}
fn generateName(self: *Parser) ![]u8 {
- const result = try std.fmt.allocPrint(&self.arena.allocator, "unnamed${}", .{self.unnamed_index});
+ const result = try std.fmt.allocPrint(&self.arena.allocator, "unnamed${d}", .{self.unnamed_index});
self.unnamed_index += 1;
return result;
}
@@ -2865,7 +2864,7 @@ const EmitZIR = struct {
fn autoName(self: *EmitZIR) ![]u8 {
while (true) {
- const proposed_name = try std.fmt.allocPrint(&self.arena.allocator, "unnamed${}", .{self.next_auto_name});
+ const proposed_name = try std.fmt.allocPrint(&self.arena.allocator, "unnamed${d}", .{self.next_auto_name});
self.next_auto_name += 1;
const gop = try self.names.getOrPut(proposed_name);
if (!gop.found_existing) {
@@ -2954,15 +2953,15 @@ pub fn dumpZir(allocator: *Allocator, kind: []const u8, decl_name: [*:0]const u8
write.next_instr_index += 1;
if (inst.cast(Inst.Block)) |block| {
- const name = try std.fmt.allocPrint(&write.arena.allocator, "label_{}", .{my_i});
+ const name = try std.fmt.allocPrint(&write.arena.allocator, "label_{d}", .{my_i});
try write.block_table.put(block, name);
} else if (inst.cast(Inst.Loop)) |loop| {
- const name = try std.fmt.allocPrint(&write.arena.allocator, "loop_{}", .{my_i});
+ const name = try std.fmt.allocPrint(&write.arena.allocator, "loop_{d}", .{my_i});
try write.loop_table.put(loop, name);
}
try write.inst_table.putNoClobber(inst, .{ .inst = inst, .index = my_i, .name = "inst" });
- try stderr.print(" %{} ", .{my_i});
+ try stderr.print(" %{d} ", .{my_i});
try write.writeInstToStream(stderr, inst);
try stderr.writeByte('\n');
}
diff --git a/src/zir_sema.zig b/src/zir_sema.zig
index 72a1b04238..f9cd0e1a3d 100644
--- a/src/zir_sema.zig
+++ b/src/zir_sema.zig
@@ -535,7 +535,7 @@ fn analyzeInstParamType(mod: *Module, scope: *Scope, inst: *zir.Inst.ParamType)
// TODO support C-style var args
const param_count = fn_ty.fnParamLen();
if (arg_index >= param_count) {
- return mod.fail(scope, inst.base.src, "arg index {} out of bounds; '{}' has {} argument(s)", .{
+ return mod.fail(scope, inst.base.src, "arg index {d} out of bounds; '{}' has {d} argument(s)", .{
arg_index,
fn_ty,
param_count,
@@ -580,7 +580,7 @@ fn analyzeInstArg(mod: *Module, scope: *Scope, inst: *zir.Inst.Arg) InnerError!*
const param_index = b.instructions.items.len;
const param_count = fn_ty.fnParamLen();
if (param_index >= param_count) {
- return mod.fail(scope, inst.base.src, "parameter index {} outside list of length {}", .{
+ return mod.fail(scope, inst.base.src, "parameter index {d} outside list of length {d}", .{
param_index,
param_count,
});
@@ -790,7 +790,7 @@ fn analyzeInstCall(mod: *Module, scope: *Scope, inst: *zir.Inst.Call) InnerError
return mod.fail(
scope,
inst.positionals.func.src,
- "expected at least {} argument(s), found {}",
+ "expected at least {d} argument(s), found {d}",
.{ fn_params_len, call_params_len },
);
}
@@ -800,7 +800,7 @@ fn analyzeInstCall(mod: *Module, scope: *Scope, inst: *zir.Inst.Call) InnerError
return mod.fail(
scope,
inst.positionals.func.src,
- "expected {} argument(s), found {}",
+ "expected {d} argument(s), found {d}",
.{ fn_params_len, call_params_len },
);
}
@@ -1545,7 +1545,7 @@ fn analyzeInstBitwise(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerE
if (lhs.ty.zigTypeTag() == .Vector and rhs.ty.zigTypeTag() == .Vector) {
if (lhs.ty.arrayLen() != rhs.ty.arrayLen()) {
- return mod.fail(scope, inst.base.src, "vector length mismatch: {} and {}", .{
+ return mod.fail(scope, inst.base.src, "vector length mismatch: {d} and {d}", .{
lhs.ty.arrayLen(),
rhs.ty.arrayLen(),
});
@@ -1620,7 +1620,7 @@ fn analyzeInstArithmetic(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) Inn
if (lhs.ty.zigTypeTag() == .Vector and rhs.ty.zigTypeTag() == .Vector) {
if (lhs.ty.arrayLen() != rhs.ty.arrayLen()) {
- return mod.fail(scope, inst.base.src, "vector length mismatch: {} and {}", .{
+ return mod.fail(scope, inst.base.src, "vector length mismatch: {d} and {d}", .{
lhs.ty.arrayLen(),
rhs.ty.arrayLen(),
});
@@ -1791,7 +1791,7 @@ fn analyzeInstCmp(
return mod.cmpNumeric(scope, inst.base.src, lhs, rhs, op);
} else if (lhs_ty_tag == .Type and rhs_ty_tag == .Type) {
if (!is_equality_cmp) {
- return mod.fail(scope, inst.base.src, "{} operator not allowed for types", .{@tagName(op)});
+ return mod.fail(scope, inst.base.src, "{s} operator not allowed for types", .{@tagName(op)});
}
return mod.constBool(scope, inst.base.src, lhs.value().?.eql(rhs.value().?) == (op == .eq));
}