authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-06-26 20:03:36-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-06-29 23:50:20-07:00
log3b2af05df10a92a0ce6ec70e2f926dfddc2d4ba9
tree89e0bebc51f59ff7dfc4516a6cd5635a69e40a6f
parent2ef3f63e1ddc2c5c6b1e1881a54d4922770a2133

std.Build: prefer {q} over '{s}'


1 files changed, 18 insertions(+), 28 deletions(-)

lib/std/Build.zig+18-28
......@@ -852,10 +852,7 @@ pub fn addModule(b: *Build, name: []const u8, options: Module.CreateOptions) *Mo
852852 module,
853853 ) catch @panic("OOM");
854854 if (gop.found_existing) {
855 panic(
856 "A module with the name '{s}' has already been added to the package. Consider creating a private module with std.Build.createModule",
857 .{name},
858 );
855 panic("A module with the name {q} has already been added to the package. Consider creating a private module with std.Build.createModule", .{name});
859856 }
860857 return module;
861858}
......@@ -1016,7 +1013,7 @@ pub fn addNamedWriteFiles(b: *Build, name: []const u8) *Step.WriteFile {
10161013 ) catch @panic("OOM");
10171014 if (gop.found_existing) {
10181015 panic(
1019 "A WriteFile step with the name '{s}' has already been added to the package. Consider creating a private WriteFile step with std.Build.addWriteFiles",
1016 "A WriteFile step with the name {q} has already been added to the package. Consider creating a private WriteFile step with std.Build.addWriteFiles",
10201017 .{name},
10211018 );
10221019 }
......@@ -1031,10 +1028,7 @@ pub fn addNamedLazyPath(b: *Build, name: []const u8, lp: LazyPath) void {
10311028 lp.dupe(graph),
10321029 ) catch @panic("OOM");
10331030 if (gop.found_existing) {
1034 panic(
1035 "A LazyPath with the name '{s}' has already been added to the package.",
1036 .{name},
1037 );
1031 panic("A LazyPath with the name {q} has already been added to the package.", .{name});
10381032 }
10391033}
10401034
......@@ -1137,7 +1131,7 @@ pub fn option(b: *Build, comptime T: type, name_raw: []const u8, description_raw
11371131 .enum_options = enum_options,
11381132 };
11391133 if ((b.available_options_map.fetchPut(arena, name, available_option) catch @panic("OOM")) != null) {
1140 panic("option '{s}' declared twice", .{name});
1134 panic("option {q} declared twice", .{name});
11411135 }
11421136
11431137 const option_ptr = b.user_input_options.getPtr(name) orelse return null;
......@@ -1389,7 +1383,7 @@ pub fn parseTargetQuery(options: std.Target.Query.ParseOptions) error{ParseFaile
13891383 opts_copy.diagnostics = &diags;
13901384 return std.Target.Query.parse(opts_copy) catch |err| switch (err) {
13911385 error.UnknownCpuModel => {
1392 std.debug.print("unknown CPU: '{s}'\navailable CPUs for architecture '{t}':\n", .{
1386 std.debug.print("unknown CPU: {q}\navailable CPUs for architecture {t}:\n", .{
13931387 diags.cpu_name.?, diags.arch.?,
13941388 });
13951389 for (diags.arch.?.allCpuModels()) |cpu| {
......@@ -1399,7 +1393,7 @@ pub fn parseTargetQuery(options: std.Target.Query.ParseOptions) error{ParseFaile
13991393 },
14001394 error.UnknownCpuFeature => {
14011395 std.debug.print(
1402 \\unknown CPU feature: '{s}'
1396 \\unknown CPU feature: {q}
14031397 \\available CPU features for architecture '{t}':
14041398 \\
14051399 , .{
......@@ -1412,7 +1406,7 @@ pub fn parseTargetQuery(options: std.Target.Query.ParseOptions) error{ParseFaile
14121406 },
14131407 error.UnknownOperatingSystem => {
14141408 std.debug.print(
1415 \\unknown OS: '{s}'
1409 \\unknown OS: {q}
14161410 \\available operating systems:
14171411 \\
14181412 , .{diags.os_name.?});
......@@ -1422,9 +1416,7 @@ pub fn parseTargetQuery(options: std.Target.Query.ParseOptions) error{ParseFaile
14221416 return error.ParseFailed;
14231417 },
14241418 else => |e| {
1425 std.debug.print("unable to parse target '{s}': {s}\n", .{
1426 options.arch_os_abi, @errorName(e),
1427 });
1419 std.debug.print("unable to parse target {q}: {t}\n", .{ options.arch_os_abi, e });
14281420 return error.ParseFailed;
14291421 },
14301422 };
......@@ -1487,7 +1479,7 @@ pub fn standardTargetOptionsQueryOnly(b: *Build, args: StandardTargetOptionsArgs
14871479 q.serializeCpuAlloc(arena) catch @panic("OOM"),
14881480 });
14891481 }
1490 log.err("chosen target '{s}' does not match one of the allowed targets", .{
1482 log.err("chosen target {q} does not match one of the allowed targets", .{
14911483 selected_target.zigTriple(arena) catch @panic("OOM"),
14921484 });
14931485 b.markInvalidUserInput();
......@@ -1542,7 +1534,7 @@ pub fn addUserInputOption(b: *Build, name_raw: []const u8, value_raw: []const u8
15421534 return true;
15431535 },
15441536 .lazy_path, .lazy_path_list => {
1545 log.warn("the lazy path value type isn't added from the CLI, but somehow '{s}' is a .{f}", .{
1537 log.warn("the lazy path value type isn't added from the CLI, but somehow {q} is a .{f}", .{
15461538 name, std.zig.fmtId(@tagName(gop.value_ptr.value)),
15471539 });
15481540 return true;
......@@ -1710,9 +1702,7 @@ pub fn addCheckFile(
17101702/// References a file or directory relative to the source root.
17111703pub fn path(b: *Build, sub_path: []const u8) LazyPath {
17121704 if (fs.path.isAbsolute(sub_path)) {
1713 panic("sub_path is expected to be relative to the build root, but was this absolute path: '{s}'. Absolute paths can cause problems but can be created via Graph.cwdRelativePath", .{
1714 sub_path,
1715 });
1705 panic("sub_path is expected to be relative to the build root, but was this absolute path: {q}. Absolute paths can cause problems but can be created via Graph.cwdRelativePath", .{sub_path});
17161706 }
17171707 return .{ .src_path = .{
17181708 .owner = b,
......@@ -2033,34 +2023,34 @@ pub const Dependency = struct {
20332023 for (d.builder.install_tls.step.dependencies.items) |dep_step| {
20342024 const inst = dep_step.cast(Step.InstallArtifact) orelse continue;
20352025 if (mem.eql(u8, inst.artifact.name, name)) {
2036 if (found != null) panic("artifact name '{s}' is ambiguous", .{name});
2026 if (found != null) panic("artifact name {q} is ambiguous", .{name});
20372027 found = inst.artifact;
20382028 }
20392029 }
20402030 return found orelse {
20412031 for (d.builder.install_tls.step.dependencies.items) |dep_step| {
20422032 const inst = dep_step.cast(Step.InstallArtifact) orelse continue;
2043 log.info("available artifact: '{s}'", .{inst.artifact.name});
2033 log.info("available artifact: {q}", .{inst.artifact.name});
20442034 }
2045 panic("unable to find artifact '{s}'", .{name});
2035 panic("unable to find artifact {q}", .{name});
20462036 };
20472037 }
20482038
20492039 pub fn module(d: *Dependency, name: []const u8) *Module {
20502040 return d.builder.modules.get(name) orelse {
2051 panic("unable to find module '{s}'", .{name});
2041 panic("unable to find module {q}", .{name});
20522042 };
20532043 }
20542044
20552045 pub fn namedWriteFiles(d: *Dependency, name: []const u8) *Step.WriteFile {
20562046 return d.builder.named_writefiles.get(name) orelse {
2057 panic("unable to find named writefiles '{s}'", .{name});
2047 panic("unable to find named writefiles {q}", .{name});
20582048 };
20592049 }
20602050
20612051 pub fn namedLazyPath(d: *Dependency, name: []const u8) LazyPath {
20622052 return d.builder.named_lazy_paths.get(name) orelse {
2063 panic("unable to find named lazypath '{s}'", .{name});
2053 panic("unable to find named lazypath {q}", .{name});
20642054 };
20652055 }
20662056
......@@ -2628,7 +2618,7 @@ fn dumpBadDirnameHelp(
26282618
26292619 if (asking_step) |as| {
26302620 stderr.setColor(.red) catch {};
2631 try w.print(" The step '{s}' that is missing a dependency on the above step was created by this stack trace:\n", .{as.name});
2621 try w.print(" The step {q} that is missing a dependency on the above step was created by this stack trace:\n", .{as.name});
26322622 stderr.setColor(.reset) catch {};
26332623
26342624 as.dump(stderr);