aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorInKryption <inkryption07@gmail.com>2022-07-25 15:29:07 +0300
committerAndrew Kelley <andrew@ziglang.org>2022-07-26 11:25:49 -0700
commita0d3a87ce15a9f68047dc900109f5b76184d046f (patch)
tree5fb7b787347a7061bc072e76787983c82698b00d /src
parent1a16b7214d88261f0e38b7ca4d15bcd76caaec4c (diff)
downloadzig-a0d3a87ce15a9f68047dc900109f5b76184d046f.tar.gz
zig-a0d3a87ce15a9f68047dc900109f5b76184d046f.zip
std.fmt: require specifier for unwrapping ?T and E!T
Diffstat (limited to 'src')
-rw-r--r--src/Cache.zig2
-rw-r--r--src/Compilation.zig2
-rw-r--r--src/link/MachO.zig18
-rw-r--r--src/link/MachO/Atom.zig6
-rw-r--r--src/link/Wasm.zig2
-rw-r--r--src/link/Wasm/Object.zig2
-rw-r--r--src/main.zig8
-rw-r--r--src/register_manager.zig2
-rw-r--r--src/translate_c.zig13
9 files changed, 29 insertions, 26 deletions
diff --git a/src/Cache.zig b/src/Cache.zig
index 0d4b51492d..829d903e5a 100644
--- a/src/Cache.zig
+++ b/src/Cache.zig
@@ -747,7 +747,7 @@ pub const Manifest = struct {
file.stat.inode,
file.stat.mtime,
&encoded_digest,
- file.path,
+ file.path.?,
});
}
diff --git a/src/Compilation.zig b/src/Compilation.zig
index 347f1ea0f5..869cd43f0f 100644
--- a/src/Compilation.zig
+++ b/src/Compilation.zig
@@ -1465,7 +1465,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
.handle = artifact_dir,
.path = try options.local_cache_directory.join(arena, &[_][]const u8{artifact_sub_dir}),
};
- log.debug("zig_cache_artifact_directory='{s}' use_stage1={}", .{
+ log.debug("zig_cache_artifact_directory='{?s}' use_stage1={}", .{
zig_cache_artifact_directory.path, use_stage1,
});
diff --git a/src/link/MachO.zig b/src/link/MachO.zig
index 218a866c01..a247b3e6c5 100644
--- a/src/link/MachO.zig
+++ b/src/link/MachO.zig
@@ -363,7 +363,7 @@ pub fn openPath(allocator: Allocator, options: link.Options) !*MachO {
// Create dSYM bundle.
const dir = options.module.?.zig_cache_artifact_directory;
- log.debug("creating {s}.dSYM bundle in {s}", .{ emit.sub_path, dir.path });
+ log.debug("creating {s}.dSYM bundle in {?s}", .{ emit.sub_path, dir.path });
const d_sym_path = try fmt.allocPrint(
allocator,
@@ -2378,7 +2378,7 @@ fn writeAtomsOneShot(self: *MachO) !void {
break :blk math.cast(usize, size) orelse return error.Overflow;
} else 0;
- log.debug(" (adding ATOM(%{d}, '{s}') from object({d}) to buffer)", .{
+ log.debug(" (adding ATOM(%{d}, '{s}') from object({?d}) to buffer)", .{
atom.sym_index,
atom.getName(self),
atom.file,
@@ -2911,7 +2911,7 @@ fn createTentativeDefAtoms(self: *MachO) !void {
const sym = self.getSymbolPtr(global);
if (!sym.tentative()) continue;
- log.debug("creating tentative definition for ATOM(%{d}, '{s}') in object({d})", .{
+ log.debug("creating tentative definition for ATOM(%{d}, '{s}') in object({?d})", .{
global.sym_index, self.getSymbolName(global), global.file,
});
@@ -3694,7 +3694,7 @@ pub fn lowerUnnamedConst(self: *MachO, typed_value: TypedValue, decl_index: Modu
};
const name = self.strtab.get(name_str_index);
- log.debug("allocating symbol indexes for {s}", .{name});
+ log.debug("allocating symbol indexes for {?s}", .{name});
const required_alignment = typed_value.ty.abiAlignment(self.base.options.target);
const sym_index = try self.allocateSymbol();
@@ -3734,7 +3734,7 @@ pub fn lowerUnnamedConst(self: *MachO, typed_value: TypedValue, decl_index: Modu
);
const addr = try self.allocateAtom(atom, code.len, required_alignment, match);
- log.debug("allocated atom for {s} at 0x{x}", .{ name, addr });
+ log.debug("allocated atom for {?s} at 0x{x}", .{ name, addr });
log.debug(" (required alignment 0x{x})", .{required_alignment});
errdefer self.freeAtom(atom, match, true);
@@ -7040,7 +7040,7 @@ fn logSymtab(self: *MachO) void {
@divTrunc(sym.n_desc, macho.N_SYMBOL_RESOLVER)
else
sym.n_sect;
- log.debug(" %{d}: {s} @{x} in {s}({d}), {s}", .{
+ log.debug(" %{d}: {?s} @{x} in {s}({d}), {s}", .{
sym_id,
self.strtab.get(sym.n_strx),
sym.n_value,
@@ -7053,7 +7053,7 @@ fn logSymtab(self: *MachO) void {
log.debug("globals table:", .{});
for (self.globals.keys()) |name, id| {
const value = self.globals.values()[id];
- log.debug(" {s} => %{d} in object({d})", .{ name, value.sym_index, value.file });
+ log.debug(" {s} => %{d} in object({?d})", .{ name, value.sym_index, value.file });
}
log.debug("GOT entries:", .{});
@@ -7068,7 +7068,7 @@ fn logSymtab(self: *MachO) void {
self.getSymbolName(entry.target),
});
} else {
- log.debug(" {d}@{x} => local(%{d}) in object({d}) {s}", .{
+ log.debug(" {d}@{x} => local(%{d}) in object({?d}) {s}", .{
i,
atom_sym.n_value,
entry.target.sym_index,
@@ -7137,7 +7137,7 @@ fn logAtoms(self: *MachO) void {
pub fn logAtom(self: *MachO, atom: *const Atom) void {
const sym = atom.getSymbol(self);
const sym_name = atom.getName(self);
- log.debug(" ATOM(%{d}, '{s}') @ {x} (sizeof({x}), alignof({x})) in object({d}) in sect({d})", .{
+ log.debug(" ATOM(%{d}, '{s}') @ {x} (sizeof({x}), alignof({x})) in object({?d}) in sect({d})", .{
atom.sym_index,
sym_name,
sym.n_value,
diff --git a/src/link/MachO/Atom.zig b/src/link/MachO/Atom.zig
index 2f60702423..ca840e1a51 100644
--- a/src/link/MachO/Atom.zig
+++ b/src/link/MachO/Atom.zig
@@ -541,7 +541,7 @@ pub fn resolveRelocs(self: *Atom, macho_file: *MachO) !void {
const arch = macho_file.base.options.target.cpu.arch;
switch (arch) {
.aarch64 => {
- log.debug(" RELA({s}) @ {x} => %{d} in object({d})", .{
+ log.debug(" RELA({s}) @ {x} => %{d} in object({?d})", .{
@tagName(@intToEnum(macho.reloc_type_arm64, rel.@"type")),
rel.offset,
rel.target.sym_index,
@@ -549,7 +549,7 @@ pub fn resolveRelocs(self: *Atom, macho_file: *MachO) !void {
});
},
.x86_64 => {
- log.debug(" RELA({s}) @ {x} => %{d} in object({d})", .{
+ log.debug(" RELA({s}) @ {x} => %{d} in object({?d})", .{
@tagName(@intToEnum(macho.reloc_type_x86_64, rel.@"type")),
rel.offset,
rel.target.sym_index,
@@ -579,7 +579,7 @@ pub fn resolveRelocs(self: *Atom, macho_file: *MachO) !void {
log.debug(" | atomless target '{s}'", .{target_name});
break :blk atomless_sym.n_value;
};
- log.debug(" | target ATOM(%{d}, '{s}') in object({d})", .{
+ log.debug(" | target ATOM(%{d}, '{s}') in object({?d})", .{
target_atom.sym_index,
target_atom.getName(macho_file),
target_atom.file,
diff --git a/src/link/Wasm.zig b/src/link/Wasm.zig
index 41ee8392ec..30e2192268 100644
--- a/src/link/Wasm.zig
+++ b/src/link/Wasm.zig
@@ -1629,7 +1629,7 @@ fn setupMemory(self: *Wasm) !void {
return error.MemoryTooBig;
}
self.memories.limits.max = @intCast(u32, max_memory / page_size);
- log.debug("Maximum memory pages: {d}", .{self.memories.limits.max});
+ log.debug("Maximum memory pages: {?d}", .{self.memories.limits.max});
}
}
diff --git a/src/link/Wasm/Object.zig b/src/link/Wasm/Object.zig
index 9dba838d27..a1308ec045 100644
--- a/src/link/Wasm/Object.zig
+++ b/src/link/Wasm/Object.zig
@@ -548,7 +548,7 @@ fn Parser(comptime ReaderType: type) type {
.index = try leb.readULEB128(u32, reader),
.addend = if (rel_type_enum.addendIsPresent()) try leb.readULEB128(u32, reader) else null,
};
- log.debug("Found relocation: type({s}) offset({d}) index({d}) addend({d})", .{
+ log.debug("Found relocation: type({s}) offset({d}) index({d}) addend({?d})", .{
@tagName(relocation.relocation_type),
relocation.offset,
relocation.index,
diff --git a/src/main.zig b/src/main.zig
index 27682003f2..c9b9d1c0af 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -3168,7 +3168,7 @@ fn parseCrossTargetOrReportFatalError(
@tagName(diags.arch.?), help_text.items,
});
}
- fatal("Unknown CPU feature: '{s}'", .{diags.unknown_feature_name});
+ fatal("Unknown CPU feature: '{s}'", .{diags.unknown_feature_name.?});
},
else => |e| return e,
};
@@ -3496,7 +3496,8 @@ fn cmdTranslateC(comp: *Compilation, arena: Allocator, enable_cache: bool, stage
} else {
const out_zig_path = try fs.path.join(arena, &[_][]const u8{ "o", &digest, translated_zig_basename });
const zig_file = comp.local_cache_directory.handle.openFile(out_zig_path, .{}) catch |err| {
- fatal("unable to open cached translated zig file '{s}{s}{s}': {s}", .{ comp.local_cache_directory.path, fs.path.sep_str, out_zig_path, @errorName(err) });
+ const path = comp.local_cache_directory.path orelse ".";
+ fatal("unable to open cached translated zig file '{s}{s}{s}': {s}", .{ path, fs.path.sep_str, out_zig_path, @errorName(err) });
};
defer zig_file.close();
try io.getStdOut().writeFileAll(zig_file, .{});
@@ -3626,7 +3627,8 @@ pub fn cmdInit(
.Exe => "init-exe",
};
var template_dir = zig_lib_directory.handle.openDir(template_sub_path, .{}) catch |err| {
- fatal("unable to open zig project template directory '{s}{s}{s}': {s}", .{ zig_lib_directory.path, s, template_sub_path, @errorName(err) });
+ const path = zig_lib_directory.path orelse ".";
+ fatal("unable to open zig project template directory '{s}{s}{s}': {s}", .{ path, s, template_sub_path, @errorName(err) });
};
defer template_dir.close();
diff --git a/src/register_manager.zig b/src/register_manager.zig
index 0bd9ef62e9..0ab9d103b8 100644
--- a/src/register_manager.zig
+++ b/src/register_manager.zig
@@ -301,7 +301,7 @@ pub fn RegisterManager(
/// register.
pub fn getReg(self: *Self, reg: Register, inst: ?Air.Inst.Index) AllocateRegistersError!void {
const index = indexOfRegIntoTracked(reg) orelse return;
- log.debug("getReg {} for inst {}", .{ reg, inst });
+ log.debug("getReg {} for inst {?}", .{ reg, inst });
self.markRegAllocated(reg);
if (inst) |tracked_inst|
diff --git a/src/translate_c.zig b/src/translate_c.zig
index 53481c8f5d..a64d00829a 100644
--- a/src/translate_c.zig
+++ b/src/translate_c.zig
@@ -2765,7 +2765,7 @@ fn transInitListExpr(
qual_type,
));
} else {
- const type_name = c.str(qual_type.getTypeClassName());
+ const type_name = try c.str(qual_type.getTypeClassName());
return fail(c, error.UnsupportedType, source_loc, "unsupported initlist type: '{s}'", .{type_name});
}
}
@@ -4812,11 +4812,11 @@ fn transType(c: *Context, scope: *Scope, ty: *const clang.Type, source_loc: clan
});
},
.BitInt, .ExtVector => {
- const type_name = c.str(ty.getTypeClassName());
+ const type_name = try c.str(ty.getTypeClassName());
return fail(c, error.UnsupportedType, source_loc, "TODO implement translation of type: '{s}'", .{type_name});
},
else => {
- const type_name = c.str(ty.getTypeClassName());
+ const type_name = try c.str(ty.getTypeClassName());
return fail(c, error.UnsupportedType, source_loc, "unsupported type: '{s}'", .{type_name});
},
}
@@ -5052,8 +5052,8 @@ fn finishTransFnProto(
}
fn warn(c: *Context, scope: *Scope, loc: clang.SourceLocation, comptime format: []const u8, args: anytype) !void {
- const args_prefix = .{c.locStr(loc)};
- const value = try std.fmt.allocPrint(c.arena, "// {s}: warning: " ++ format, args_prefix ++ args);
+ const str = try c.locStr(loc);
+ const value = try std.fmt.allocPrint(c.arena, "// {s}: warning: " ++ format, .{str} ++ args);
try scope.appendNode(try Tag.warning.create(c.arena, value));
}
@@ -5073,7 +5073,8 @@ pub fn failDecl(c: *Context, loc: clang.SourceLocation, name: []const u8, compti
// pub const name = @compileError(msg);
const fail_msg = try std.fmt.allocPrint(c.arena, format, args);
try addTopLevelDecl(c, name, try Tag.fail_decl.create(c.arena, .{ .actual = name, .mangled = fail_msg }));
- const location_comment = try std.fmt.allocPrint(c.arena, "// {s}", .{c.locStr(loc)});
+ const str = try c.locStr(loc);
+ const location_comment = try std.fmt.allocPrint(c.arena, "// {s}", .{str});
try c.global_scope.nodes.append(try Tag.warning.create(c.arena, location_comment));
}