authorgravatar for me@tadeo.caTadeo Kondrak <me@tadeo.ca> 2020-04-30 04:30:01-06:00
committergravatar for me@tadeo.caTadeo Kondrak <me@tadeo.ca> 2020-05-02 14:39:31-06:00
log647901b4a82dbb89656c620d4d4a89869fdf1fa0
tree19b297cc713d1ea63d64d4d42130f78d375d269f
parentca6db2d008cf3e0e3700e84400bd3d6e259e3c0f
signature Commit is signed but in an unrecognized format.

Constify TypeInfo


2 files changed, 15 insertions(+), 15 deletions(-)

lib/std/builtin.zig+9-9
...@@ -235,8 +235,8 @@ pub const TypeInfo = union(enum) {...@@ -235,8 +235,8 @@ pub const TypeInfo = union(enum) {
235 /// therefore must be kept in sync with the compiler implementation.235 /// therefore must be kept in sync with the compiler implementation.
236 pub const Struct = struct {236 pub const Struct = struct {
237 layout: ContainerLayout,237 layout: ContainerLayout,
238 fields: []StructField,238 fields: []const StructField,
239 decls: []Declaration,239 decls: []const Declaration,
240 };240 };
241241
242 /// This data structure is used by the Zig language code generation and242 /// This data structure is used by the Zig language code generation and
...@@ -261,7 +261,7 @@ pub const TypeInfo = union(enum) {...@@ -261,7 +261,7 @@ pub const TypeInfo = union(enum) {
261261
262 /// This data structure is used by the Zig language code generation and262 /// This data structure is used by the Zig language code generation and
263 /// therefore must be kept in sync with the compiler implementation.263 /// therefore must be kept in sync with the compiler implementation.
264 pub const ErrorSet = ?[]Error;264 pub const ErrorSet = ?[]const Error;
265265
266 /// This data structure is used by the Zig language code generation and266 /// This data structure is used by the Zig language code generation and
267 /// therefore must be kept in sync with the compiler implementation.267 /// therefore must be kept in sync with the compiler implementation.
...@@ -275,8 +275,8 @@ pub const TypeInfo = union(enum) {...@@ -275,8 +275,8 @@ pub const TypeInfo = union(enum) {
275 pub const Enum = struct {275 pub const Enum = struct {
276 layout: ContainerLayout,276 layout: ContainerLayout,
277 tag_type: type,277 tag_type: type,
278 fields: []EnumField,278 fields: []const EnumField,
279 decls: []Declaration,279 decls: []const Declaration,
280 is_exhaustive: bool,280 is_exhaustive: bool,
281 };281 };
282282
...@@ -293,8 +293,8 @@ pub const TypeInfo = union(enum) {...@@ -293,8 +293,8 @@ pub const TypeInfo = union(enum) {
293 pub const Union = struct {293 pub const Union = struct {
294 layout: ContainerLayout,294 layout: ContainerLayout,
295 tag_type: ?type,295 tag_type: ?type,
296 fields: []UnionField,296 fields: []const UnionField,
297 decls: []Declaration,297 decls: []const Declaration,
298 };298 };
299299
300 /// This data structure is used by the Zig language code generation and300 /// This data structure is used by the Zig language code generation and
...@@ -312,7 +312,7 @@ pub const TypeInfo = union(enum) {...@@ -312,7 +312,7 @@ pub const TypeInfo = union(enum) {
312 is_generic: bool,312 is_generic: bool,
313 is_var_args: bool,313 is_var_args: bool,
314 return_type: ?type,314 return_type: ?type,
315 args: []FnArg,315 args: []const FnArg,
316 };316 };
317317
318 /// This data structure is used by the Zig language code generation and318 /// This data structure is used by the Zig language code generation and
...@@ -358,7 +358,7 @@ pub const TypeInfo = union(enum) {...@@ -358,7 +358,7 @@ pub const TypeInfo = union(enum) {
358 is_export: bool,358 is_export: bool,
359 lib_name: ?[]const u8,359 lib_name: ?[]const u8,
360 return_type: type,360 return_type: type,
361 arg_names: [][]const u8,361 arg_names: []const []const u8,
362362
363 /// This data structure is used by the Zig language code generation and363 /// This data structure is used by the Zig language code generation and
364 /// therefore must be kept in sync with the compiler implementation.364 /// therefore must be kept in sync with the compiler implementation.
lib/std/meta.zig+6-6
...@@ -219,7 +219,7 @@ test "std.meta.containerLayout" {...@@ -219,7 +219,7 @@ test "std.meta.containerLayout" {
219 testing.expect(containerLayout(U3) == .Extern);219 testing.expect(containerLayout(U3) == .Extern);
220}220}
221221
222pub fn declarations(comptime T: type) []TypeInfo.Declaration {222pub fn declarations(comptime T: type) []const TypeInfo.Declaration {
223 return switch (@typeInfo(T)) {223 return switch (@typeInfo(T)) {
224 .Struct => |info| info.decls,224 .Struct => |info| info.decls,
225 .Enum => |info| info.decls,225 .Enum => |info| info.decls,
...@@ -243,7 +243,7 @@ test "std.meta.declarations" {...@@ -243,7 +243,7 @@ test "std.meta.declarations" {
243 fn a() void {}243 fn a() void {}
244 };244 };
245245
246 const decls = comptime [_][]TypeInfo.Declaration{246 const decls = comptime [_][]const TypeInfo.Declaration{
247 declarations(E1),247 declarations(E1),
248 declarations(S1),248 declarations(S1),
249 declarations(U1),249 declarations(U1),
...@@ -292,10 +292,10 @@ test "std.meta.declarationInfo" {...@@ -292,10 +292,10 @@ test "std.meta.declarationInfo" {
292}292}
293293
294pub fn fields(comptime T: type) switch (@typeInfo(T)) {294pub fn fields(comptime T: type) switch (@typeInfo(T)) {
295 .Struct => []TypeInfo.StructField,295 .Struct => []const TypeInfo.StructField,
296 .Union => []TypeInfo.UnionField,296 .Union => []const TypeInfo.UnionField,
297 .ErrorSet => []TypeInfo.Error,297 .ErrorSet => []const TypeInfo.Error,
298 .Enum => []TypeInfo.EnumField,298 .Enum => []const TypeInfo.EnumField,
299 else => @compileError("Expected struct, union, error set or enum type, found '" ++ @typeName(T) ++ "'"),299 else => @compileError("Expected struct, union, error set or enum type, found '" ++ @typeName(T) ++ "'"),
300} {300} {
301 return switch (@typeInfo(T)) {301 return switch (@typeInfo(T)) {