std: update std.builtin.Type fields to follow naming conventions

The compiler actually doesn't need any functional changes for this: Sema
does reification based on the tag indices of `std.builtin.Type` already!
So, no zig1.wasm update is necessary.

This change is necessary to disallow name clashes between fields and
decls on a type, which is a prerequisite of #9938.
This commit is contained in:
mlugg
2024-08-28 02:35:53 +01:00
parent 1a178d4995
commit 0fe3fd01dd
336 changed files with 4105 additions and 4112 deletions

View File

@@ -109,47 +109,47 @@ pub fn getOutput(config_header: *ConfigHeader) std.Build.LazyPath {
}
fn addValuesInner(config_header: *ConfigHeader, values: anytype) !void {
inline for (@typeInfo(@TypeOf(values)).Struct.fields) |field| {
inline for (@typeInfo(@TypeOf(values)).@"struct".fields) |field| {
try putValue(config_header, field.name, field.type, @field(values, field.name));
}
}
fn putValue(config_header: *ConfigHeader, field_name: []const u8, comptime T: type, v: T) !void {
switch (@typeInfo(T)) {
.Null => {
.null => {
try config_header.values.put(field_name, .undef);
},
.Void => {
.void => {
try config_header.values.put(field_name, .defined);
},
.Bool => {
.bool => {
try config_header.values.put(field_name, .{ .boolean = v });
},
.Int => {
.int => {
try config_header.values.put(field_name, .{ .int = v });
},
.ComptimeInt => {
.comptime_int => {
try config_header.values.put(field_name, .{ .int = v });
},
.EnumLiteral => {
.enum_literal => {
try config_header.values.put(field_name, .{ .ident = @tagName(v) });
},
.Optional => {
.optional => {
if (v) |x| {
return putValue(config_header, field_name, @TypeOf(x), x);
} else {
try config_header.values.put(field_name, .undef);
}
},
.Pointer => |ptr| {
.pointer => |ptr| {
switch (@typeInfo(ptr.child)) {
.Array => |array| {
.array => |array| {
if (ptr.size == .One and array.child == u8) {
try config_header.values.put(field_name, .{ .string = v });
return;
}
},
.Int => {
.int => {
if (ptr.size == .Slice and ptr.child == u8) {
try config_header.values.put(field_name, .{ .string = v });
return;

View File

@@ -151,7 +151,7 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent
}
switch (@typeInfo(T)) {
.Array => {
.array => {
if (name) |some| {
try out.print("pub const {}: {s} = ", .{ std.zig.fmtId(some), @typeName(T) });
}
@@ -171,7 +171,7 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent
}
return;
},
.Pointer => |p| {
.pointer => |p| {
if (p.size != .Slice) {
@compileError("Non-slice pointers are not yet supported in build options");
}
@@ -195,7 +195,7 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent
}
return;
},
.Optional => {
.optional => {
if (name) |some| {
try out.print("pub const {}: {s} = ", .{ std.zig.fmtId(some), @typeName(T) });
}
@@ -216,12 +216,12 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent
}
return;
},
.Void,
.Bool,
.Int,
.ComptimeInt,
.Float,
.Null,
.void,
.bool,
.int,
.comptime_int,
.float,
.null,
=> {
if (name) |some| {
try out.print("pub const {}: {s} = {any};\n", .{ std.zig.fmtId(some), @typeName(T), value });
@@ -230,7 +230,7 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent
}
return;
},
.Enum => |info| {
.@"enum" => |info| {
try printEnum(options, out, T, info, indent);
if (name) |some| {
@@ -242,7 +242,7 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent
}
return;
},
.Struct => |info| {
.@"struct" => |info| {
try printStruct(options, out, T, info, indent);
if (name) |some| {
@@ -260,10 +260,10 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent
fn printUserDefinedType(options: *Options, out: anytype, comptime T: type, indent: u8) !void {
switch (@typeInfo(T)) {
.Enum => |info| {
.@"enum" => |info| {
return try printEnum(options, out, T, info, indent);
},
.Struct => |info| {
.@"struct" => |info| {
return try printStruct(options, out, T, info, indent);
},
else => {},
@@ -323,8 +323,8 @@ fn printStruct(options: *Options, out: anytype, comptime T: type, comptime val:
try out.writeAll(" = ");
switch (@typeInfo(@TypeOf(default_value))) {
.Enum => try out.print(".{s},\n", .{@tagName(default_value)}),
.Struct => |info| {
.@"enum" => try out.print(".{s},\n", .{@tagName(default_value)}),
.@"struct" => |info| {
try printStructValue(options, out, info, default_value, indent + 4);
},
else => try printType(options, out, @TypeOf(default_value), default_value, indent, null),
@@ -359,8 +359,8 @@ fn printStructValue(options: *Options, out: anytype, comptime struct_val: std.bu
const field_name = @field(val, field.name);
switch (@typeInfo(@TypeOf(field_name))) {
.Enum => try out.print(".{s},\n", .{@tagName(field_name)}),
.Struct => |struct_info| {
.@"enum" => try out.print(".{s},\n", .{@tagName(field_name)}),
.@"struct" => |struct_info| {
try printStructValue(options, out, struct_info, field_name, indent + 4);
},
else => try printType(options, out, @TypeOf(field_name), field_name, indent, null),

View File

@@ -614,7 +614,7 @@ fn checksContainStderr(checks: []const StdIo.Check) bool {
const IndexedOutput = struct {
index: usize,
tag: @typeInfo(Arg).Union.tag_type.?,
tag: @typeInfo(Arg).@"union".tag_type.?,
output: *Output,
};
fn make(step: *Step, options: Step.MakeOptions) !void {