| author | |
| committer | |
| log | 40ed6ae8469fd599f0524d294f38365c3bb8a825 |
| tree | 6e37bbb58fef1ca3aae06e65e179dfa017cb7929 |
| parent | e9e804edc899d8392c9f93a19b92be603c26df79 |
| parent | 2a5e1426aa9469fadb78e837d0100d689213b034 |
| signature |
std.builtin: renamings76 files changed, 236 insertions(+), 280 deletions(-)
doc/langref.html.in+2-2| ... | @@ -4253,7 +4253,7 @@ fn isFieldOptional(comptime T: type, field_index: usize) !bool { | ... | @@ -4253,7 +4253,7 @@ fn isFieldOptional(comptime T: type, field_index: usize) !bool { |
| 4253 | return switch (field_index) { | 4253 | return switch (field_index) { |
| 4254 | // This prong is analyzed `fields.len - 1` times with `idx` being an | 4254 | // This prong is analyzed `fields.len - 1` times with `idx` being an |
| 4255 | // unique comptime-known value each time. | 4255 | // unique comptime-known value each time. |
| 4256 | inline 0...fields.len - 1 => |idx| @typeInfo(fields[idx].field_type) == .Optional, | 4256 | inline 0...fields.len - 1 => |idx| @typeInfo(fields[idx].type) == .Optional, |
| 4257 | else => return error.IndexOutOfBounds, | 4257 | else => return error.IndexOutOfBounds, |
| 4258 | }; | 4258 | }; |
| 4259 | } | 4259 | } |
| ... | @@ -5242,7 +5242,7 @@ const math = std.math; | ... | @@ -5242,7 +5242,7 @@ const math = std.math; |
| 5242 | const testing = std.testing; | 5242 | const testing = std.testing; |
| 5243 | 5243 | ||
| 5244 | test "fn reflection" { | 5244 | test "fn reflection" { |
| 5245 | try testing.expect(@typeInfo(@TypeOf(testing.expect)).Fn.args[0].arg_type.? == bool); | 5245 | try testing.expect(@typeInfo(@TypeOf(testing.expect)).Fn.params[0].type.? == bool); |
| 5246 | try testing.expect(@typeInfo(@TypeOf(testing.tmpDir)).Fn.return_type.? == testing.TmpDir); | 5246 | try testing.expect(@typeInfo(@TypeOf(testing.tmpDir)).Fn.return_type.? == testing.TmpDir); |
| 5247 | 5247 | ||
| 5248 | try testing.expect(@typeInfo(@TypeOf(math.Log2Int)).Fn.is_generic); | 5248 | try testing.expect(@typeInfo(@TypeOf(math.Log2Int)).Fn.is_generic); |
lib/std/array_hash_map.zig+4-4| ... | @@ -2270,13 +2270,13 @@ test "reIndex" { | ... | @@ -2270,13 +2270,13 @@ test "reIndex" { |
| 2270 | test "auto store_hash" { | 2270 | test "auto store_hash" { |
| 2271 | const HasCheapEql = AutoArrayHashMap(i32, i32); | 2271 | const HasCheapEql = AutoArrayHashMap(i32, i32); |
| 2272 | const HasExpensiveEql = AutoArrayHashMap([32]i32, i32); | 2272 | const HasExpensiveEql = AutoArrayHashMap([32]i32, i32); |
| 2273 | try testing.expect(meta.fieldInfo(HasCheapEql.Data, .hash).field_type == void); | 2273 | try testing.expect(meta.fieldInfo(HasCheapEql.Data, .hash).type == void); |
| 2274 | try testing.expect(meta.fieldInfo(HasExpensiveEql.Data, .hash).field_type != void); | 2274 | try testing.expect(meta.fieldInfo(HasExpensiveEql.Data, .hash).type != void); |
| 2275 | 2275 | ||
| 2276 | const HasCheapEqlUn = AutoArrayHashMapUnmanaged(i32, i32); | 2276 | const HasCheapEqlUn = AutoArrayHashMapUnmanaged(i32, i32); |
| 2277 | const HasExpensiveEqlUn = AutoArrayHashMapUnmanaged([32]i32, i32); | 2277 | const HasExpensiveEqlUn = AutoArrayHashMapUnmanaged([32]i32, i32); |
| 2278 | try testing.expect(meta.fieldInfo(HasCheapEqlUn.Data, .hash).field_type == void); | 2278 | try testing.expect(meta.fieldInfo(HasCheapEqlUn.Data, .hash).type == void); |
| 2279 | try testing.expect(meta.fieldInfo(HasExpensiveEqlUn.Data, .hash).field_type != void); | 2279 | try testing.expect(meta.fieldInfo(HasExpensiveEqlUn.Data, .hash).type != void); |
| 2280 | } | 2280 | } |
| 2281 | 2281 | ||
| 2282 | test "sort" { | 2282 | test "sort" { |
lib/std/builtin.zig+4-7| ... | @@ -280,8 +280,7 @@ pub const Type = union(enum) { | ... | @@ -280,8 +280,7 @@ pub const Type = union(enum) { |
| 280 | /// therefore must be kept in sync with the compiler implementation. | 280 | /// therefore must be kept in sync with the compiler implementation. |
| 281 | pub const StructField = struct { | 281 | pub const StructField = struct { |
| 282 | name: []const u8, | 282 | name: []const u8, |
| 283 | /// TODO rename to `type` | 283 | type: type, |
| 284 | field_type: type, | ||
| 285 | default_value: ?*const anyopaque, | 284 | default_value: ?*const anyopaque, |
| 286 | is_comptime: bool, | 285 | is_comptime: bool, |
| 287 | alignment: comptime_int, | 286 | alignment: comptime_int, |
| ... | @@ -331,8 +330,6 @@ pub const Type = union(enum) { | ... | @@ -331,8 +330,6 @@ pub const Type = union(enum) { |
| 331 | /// This data structure is used by the Zig language code generation and | 330 | /// This data structure is used by the Zig language code generation and |
| 332 | /// therefore must be kept in sync with the compiler implementation. | 331 | /// therefore must be kept in sync with the compiler implementation. |
| 333 | pub const Enum = struct { | 332 | pub const Enum = struct { |
| 334 | /// TODO enums should no longer have this field in type info. | ||
| 335 | layout: ContainerLayout, | ||
| 336 | tag_type: type, | 333 | tag_type: type, |
| 337 | fields: []const EnumField, | 334 | fields: []const EnumField, |
| 338 | decls: []const Declaration, | 335 | decls: []const Declaration, |
| ... | @@ -343,7 +340,7 @@ pub const Type = union(enum) { | ... | @@ -343,7 +340,7 @@ pub const Type = union(enum) { |
| 343 | /// therefore must be kept in sync with the compiler implementation. | 340 | /// therefore must be kept in sync with the compiler implementation. |
| 344 | pub const UnionField = struct { | 341 | pub const UnionField = struct { |
| 345 | name: []const u8, | 342 | name: []const u8, |
| 346 | field_type: type, | 343 | type: type, |
| 347 | alignment: comptime_int, | 344 | alignment: comptime_int, |
| 348 | }; | 345 | }; |
| 349 | 346 | ||
| ... | @@ -367,14 +364,14 @@ pub const Type = union(enum) { | ... | @@ -367,14 +364,14 @@ pub const Type = union(enum) { |
| 367 | is_var_args: bool, | 364 | is_var_args: bool, |
| 368 | /// TODO change the language spec to make this not optional. | 365 | /// TODO change the language spec to make this not optional. |
| 369 | return_type: ?type, | 366 | return_type: ?type, |
| 370 | args: []const Param, | 367 | params: []const Param, |
| 371 | 368 | ||
| 372 | /// This data structure is used by the Zig language code generation and | 369 | /// This data structure is used by the Zig language code generation and |
| 373 | /// therefore must be kept in sync with the compiler implementation. | 370 | /// therefore must be kept in sync with the compiler implementation. |
| 374 | pub const Param = struct { | 371 | pub const Param = struct { |
| 375 | is_generic: bool, | 372 | is_generic: bool, |
| 376 | is_noalias: bool, | 373 | is_noalias: bool, |
| 377 | arg_type: ?type, | 374 | type: ?type, |
| 378 | }; | 375 | }; |
| 379 | }; | 376 | }; |
| 380 | 377 |
lib/std/crypto/phc_encoding.zig+4-4| ... | @@ -110,9 +110,9 @@ pub fn deserialize(comptime HashResult: type, str: []const u8) Error!HashResult | ... | @@ -110,9 +110,9 @@ pub fn deserialize(comptime HashResult: type, str: []const u8) Error!HashResult |
| 110 | var found = false; | 110 | var found = false; |
| 111 | inline for (comptime meta.fields(HashResult)) |p| { | 111 | inline for (comptime meta.fields(HashResult)) |p| { |
| 112 | if (mem.eql(u8, p.name, param.key)) { | 112 | if (mem.eql(u8, p.name, param.key)) { |
| 113 | switch (@typeInfo(p.field_type)) { | 113 | switch (@typeInfo(p.type)) { |
| 114 | .Int => @field(out, p.name) = fmt.parseUnsigned( | 114 | .Int => @field(out, p.name) = fmt.parseUnsigned( |
| 115 | p.field_type, | 115 | p.type, |
| 116 | param.value, | 116 | param.value, |
| 117 | 10, | 117 | 10, |
| 118 | ) catch return Error.InvalidEncoding, | 118 | ) catch return Error.InvalidEncoding, |
| ... | @@ -161,7 +161,7 @@ pub fn deserialize(comptime HashResult: type, str: []const u8) Error!HashResult | ... | @@ -161,7 +161,7 @@ pub fn deserialize(comptime HashResult: type, str: []const u8) Error!HashResult |
| 161 | // with default values | 161 | // with default values |
| 162 | var expected_fields: usize = 0; | 162 | var expected_fields: usize = 0; |
| 163 | inline for (comptime meta.fields(HashResult)) |p| { | 163 | inline for (comptime meta.fields(HashResult)) |p| { |
| 164 | if (@typeInfo(p.field_type) != .Optional and p.default_value == null) { | 164 | if (@typeInfo(p.type) != .Optional and p.default_value == null) { |
| 165 | expected_fields += 1; | 165 | expected_fields += 1; |
| 166 | } | 166 | } |
| 167 | } | 167 | } |
| ... | @@ -223,7 +223,7 @@ fn serializeTo(params: anytype, out: anytype) !void { | ... | @@ -223,7 +223,7 @@ fn serializeTo(params: anytype, out: anytype) !void { |
| 223 | { | 223 | { |
| 224 | const value = @field(params, p.name); | 224 | const value = @field(params, p.name); |
| 225 | try out.writeAll(if (has_params) params_delimiter else fields_delimiter); | 225 | try out.writeAll(if (has_params) params_delimiter else fields_delimiter); |
| 226 | if (@typeInfo(p.field_type) == .Struct) { | 226 | if (@typeInfo(p.type) == .Struct) { |
| 227 | var buf: [@TypeOf(value).max_encoded_length]u8 = undefined; | 227 | var buf: [@TypeOf(value).max_encoded_length]u8 = undefined; |
| 228 | try out.print("{s}{s}{s}", .{ p.name, kv_delimiter, try value.toB64(&buf) }); | 228 | try out.print("{s}{s}{s}", .{ p.name, kv_delimiter, try value.toB64(&buf) }); |
| 229 | } else { | 229 | } else { |
lib/std/enums.zig+1-1| ... | @@ -15,7 +15,7 @@ pub fn EnumFieldStruct(comptime E: type, comptime Data: type, comptime field_def | ... | @@ -15,7 +15,7 @@ pub fn EnumFieldStruct(comptime E: type, comptime Data: type, comptime field_def |
| 15 | for (std.meta.fields(E)) |field| { | 15 | for (std.meta.fields(E)) |field| { |
| 16 | fields = fields ++ &[_]StructField{.{ | 16 | fields = fields ++ &[_]StructField{.{ |
| 17 | .name = field.name, | 17 | .name = field.name, |
| 18 | .field_type = Data, | 18 | .type = Data, |
| 19 | .default_value = if (field_default) |d| @ptrCast(?*const anyopaque, &d) else null, | 19 | .default_value = if (field_default) |d| @ptrCast(?*const anyopaque, &d) else null, |
| 20 | .is_comptime = false, | 20 | .is_comptime = false, |
| 21 | .alignment = if (@sizeOf(Data) > 0) @alignOf(Data) else 0, | 21 | .alignment = if (@sizeOf(Data) > 0) @alignOf(Data) else 0, |
lib/std/fmt.zig+1-1| ... | @@ -1724,7 +1724,7 @@ pub const ParseIntError = error{ | ... | @@ -1724,7 +1724,7 @@ pub const ParseIntError = error{ |
| 1724 | /// ) !void; | 1724 | /// ) !void; |
| 1725 | /// | 1725 | /// |
| 1726 | pub fn Formatter(comptime format_fn: anytype) type { | 1726 | pub fn Formatter(comptime format_fn: anytype) type { |
| 1727 | const Data = @typeInfo(@TypeOf(format_fn)).Fn.args[0].arg_type.?; | 1727 | const Data = @typeInfo(@TypeOf(format_fn)).Fn.params[0].type.?; |
| 1728 | return struct { | 1728 | return struct { |
| 1729 | data: Data, | 1729 | data: Data, |
| 1730 | pub fn format( | 1730 | pub fn format( |
lib/std/hash/auto_hash.zig+3-3| ... | @@ -134,7 +134,7 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void { | ... | @@ -134,7 +134,7 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void { |
| 134 | hash(hasher, tag, strat); | 134 | hash(hasher, tag, strat); |
| 135 | inline for (info.fields) |field| { | 135 | inline for (info.fields) |field| { |
| 136 | if (@field(tag_type, field.name) == tag) { | 136 | if (@field(tag_type, field.name) == tag) { |
| 137 | if (field.field_type != void) { | 137 | if (field.type != void) { |
| 138 | hash(hasher, @field(key, field.name), strat); | 138 | hash(hasher, @field(key, field.name), strat); |
| 139 | } | 139 | } |
| 140 | // TODO use a labelled break when it does not crash the compiler. cf #2908 | 140 | // TODO use a labelled break when it does not crash the compiler. cf #2908 |
| ... | @@ -163,14 +163,14 @@ fn typeContainsSlice(comptime K: type) bool { | ... | @@ -163,14 +163,14 @@ fn typeContainsSlice(comptime K: type) bool { |
| 163 | } | 163 | } |
| 164 | if (meta.trait.is(.Struct)(K)) { | 164 | if (meta.trait.is(.Struct)(K)) { |
| 165 | inline for (@typeInfo(K).Struct.fields) |field| { | 165 | inline for (@typeInfo(K).Struct.fields) |field| { |
| 166 | if (typeContainsSlice(field.field_type)) { | 166 | if (typeContainsSlice(field.type)) { |
| 167 | return true; | 167 | return true; |
| 168 | } | 168 | } |
| 169 | } | 169 | } |
| 170 | } | 170 | } |
| 171 | if (meta.trait.is(.Union)(K)) { | 171 | if (meta.trait.is(.Union)(K)) { |
| 172 | inline for (@typeInfo(K).Union.fields) |field| { | 172 | inline for (@typeInfo(K).Union.fields) |field| { |
| 173 | if (typeContainsSlice(field.field_type)) { | 173 | if (typeContainsSlice(field.type)) { |
| 174 | return true; | 174 | return true; |
| 175 | } | 175 | } |
| 176 | } | 176 | } |
lib/std/hash_map.zig+10-10| ... | @@ -186,11 +186,11 @@ pub fn verifyContext( | ... | @@ -186,11 +186,11 @@ pub fn verifyContext( |
| 186 | const info = @typeInfo(@TypeOf(hash)); | 186 | const info = @typeInfo(@TypeOf(hash)); |
| 187 | if (info == .Fn) { | 187 | if (info == .Fn) { |
| 188 | const func = info.Fn; | 188 | const func = info.Fn; |
| 189 | if (func.args.len != 2) { | 189 | if (func.params.len != 2) { |
| 190 | errors = errors ++ lazy.err_invalid_hash_signature; | 190 | errors = errors ++ lazy.err_invalid_hash_signature; |
| 191 | } else { | 191 | } else { |
| 192 | var emitted_signature = false; | 192 | var emitted_signature = false; |
| 193 | if (func.args[0].arg_type) |Self| { | 193 | if (func.params[0].type) |Self| { |
| 194 | if (Self == Context) { | 194 | if (Self == Context) { |
| 195 | // pass, this is always fine. | 195 | // pass, this is always fine. |
| 196 | } else if (Self == *const Context) { | 196 | } else if (Self == *const Context) { |
| ... | @@ -231,12 +231,12 @@ pub fn verifyContext( | ... | @@ -231,12 +231,12 @@ pub fn verifyContext( |
| 231 | errors = errors ++ ", but is " ++ @typeName(Self); | 231 | errors = errors ++ ", but is " ++ @typeName(Self); |
| 232 | } | 232 | } |
| 233 | } | 233 | } |
| 234 | if (func.args[1].arg_type != null and func.args[1].arg_type.? != PseudoKey) { | 234 | if (func.params[1].type != null and func.params[1].type.? != PseudoKey) { |
| 235 | if (!emitted_signature) { | 235 | if (!emitted_signature) { |
| 236 | errors = errors ++ lazy.err_invalid_hash_signature; | 236 | errors = errors ++ lazy.err_invalid_hash_signature; |
| 237 | emitted_signature = true; | 237 | emitted_signature = true; |
| 238 | } | 238 | } |
| 239 | errors = errors ++ lazy.deep_prefix ++ "Second parameter must be " ++ @typeName(PseudoKey) ++ ", but is " ++ @typeName(func.args[1].arg_type.?); | 239 | errors = errors ++ lazy.deep_prefix ++ "Second parameter must be " ++ @typeName(PseudoKey) ++ ", but is " ++ @typeName(func.params[1].type.?); |
| 240 | } | 240 | } |
| 241 | if (func.return_type != null and func.return_type.? != Hash) { | 241 | if (func.return_type != null and func.return_type.? != Hash) { |
| 242 | if (!emitted_signature) { | 242 | if (!emitted_signature) { |
| ... | @@ -263,11 +263,11 @@ pub fn verifyContext( | ... | @@ -263,11 +263,11 @@ pub fn verifyContext( |
| 263 | if (info == .Fn) { | 263 | if (info == .Fn) { |
| 264 | const func = info.Fn; | 264 | const func = info.Fn; |
| 265 | const args_len = if (is_array) 4 else 3; | 265 | const args_len = if (is_array) 4 else 3; |
| 266 | if (func.args.len != args_len) { | 266 | if (func.params.len != args_len) { |
| 267 | errors = errors ++ lazy.err_invalid_eql_signature; | 267 | errors = errors ++ lazy.err_invalid_eql_signature; |
| 268 | } else { | 268 | } else { |
| 269 | var emitted_signature = false; | 269 | var emitted_signature = false; |
| 270 | if (func.args[0].arg_type) |Self| { | 270 | if (func.params[0].type) |Self| { |
| 271 | if (Self == Context) { | 271 | if (Self == Context) { |
| 272 | // pass, this is always fine. | 272 | // pass, this is always fine. |
| 273 | } else if (Self == *const Context) { | 273 | } else if (Self == *const Context) { |
| ... | @@ -308,19 +308,19 @@ pub fn verifyContext( | ... | @@ -308,19 +308,19 @@ pub fn verifyContext( |
| 308 | errors = errors ++ ", but is " ++ @typeName(Self); | 308 | errors = errors ++ ", but is " ++ @typeName(Self); |
| 309 | } | 309 | } |
| 310 | } | 310 | } |
| 311 | if (func.args[1].arg_type.? != PseudoKey) { | 311 | if (func.params[1].type.? != PseudoKey) { |
| 312 | if (!emitted_signature) { | 312 | if (!emitted_signature) { |
| 313 | errors = errors ++ lazy.err_invalid_eql_signature; | 313 | errors = errors ++ lazy.err_invalid_eql_signature; |
| 314 | emitted_signature = true; | 314 | emitted_signature = true; |
| 315 | } | 315 | } |
| 316 | errors = errors ++ lazy.deep_prefix ++ "Second parameter must be " ++ @typeName(PseudoKey) ++ ", but is " ++ @typeName(func.args[1].arg_type.?); | 316 | errors = errors ++ lazy.deep_prefix ++ "Second parameter must be " ++ @typeName(PseudoKey) ++ ", but is " ++ @typeName(func.params[1].type.?); |
| 317 | } | 317 | } |
| 318 | if (func.args[2].arg_type.? != Key) { | 318 | if (func.params[2].type.? != Key) { |
| 319 | if (!emitted_signature) { | 319 | if (!emitted_signature) { |
| 320 | errors = errors ++ lazy.err_invalid_eql_signature; | 320 | errors = errors ++ lazy.err_invalid_eql_signature; |
| 321 | emitted_signature = true; | 321 | emitted_signature = true; |
| 322 | } | 322 | } |
| 323 | errors = errors ++ lazy.deep_prefix ++ "Third parameter must be " ++ @typeName(Key) ++ ", but is " ++ @typeName(func.args[2].arg_type.?); | 323 | errors = errors ++ lazy.deep_prefix ++ "Third parameter must be " ++ @typeName(Key) ++ ", but is " ++ @typeName(func.params[2].type.?); |
| 324 | } | 324 | } |
| 325 | if (func.return_type.? != bool) { | 325 | if (func.return_type.? != bool) { |
| 326 | if (!emitted_signature) { | 326 | if (!emitted_signature) { |
lib/std/io/multi_writer.zig+1-1| ... | @@ -6,7 +6,7 @@ const testing = std.testing; | ... | @@ -6,7 +6,7 @@ const testing = std.testing; |
| 6 | pub fn MultiWriter(comptime Writers: type) type { | 6 | pub fn MultiWriter(comptime Writers: type) type { |
| 7 | comptime var ErrSet = error{}; | 7 | comptime var ErrSet = error{}; |
| 8 | inline for (@typeInfo(Writers).Struct.fields) |field| { | 8 | inline for (@typeInfo(Writers).Struct.fields) |field| { |
| 9 | const StreamType = field.field_type; | 9 | const StreamType = field.type; |
| 10 | ErrSet = ErrSet || StreamType.Error; | 10 | ErrSet = ErrSet || StreamType.Error; |
| 11 | } | 11 | } |
| 12 | 12 |
lib/std/json.zig+13-13| ... | @@ -1362,7 +1362,7 @@ fn ParseInternalErrorImpl(comptime T: type, comptime inferred_types: []const typ | ... | @@ -1362,7 +1362,7 @@ fn ParseInternalErrorImpl(comptime T: type, comptime inferred_types: []const typ |
| 1362 | if (unionInfo.tag_type) |_| { | 1362 | if (unionInfo.tag_type) |_| { |
| 1363 | var errors = error{NoUnionMembersMatched}; | 1363 | var errors = error{NoUnionMembersMatched}; |
| 1364 | for (unionInfo.fields) |u_field| { | 1364 | for (unionInfo.fields) |u_field| { |
| 1365 | errors = errors || ParseInternalErrorImpl(u_field.field_type, inferred_types ++ [_]type{T}); | 1365 | errors = errors || ParseInternalErrorImpl(u_field.type, inferred_types ++ [_]type{T}); |
| 1366 | } | 1366 | } |
| 1367 | return errors; | 1367 | return errors; |
| 1368 | } else { | 1368 | } else { |
| ... | @@ -1379,7 +1379,7 @@ fn ParseInternalErrorImpl(comptime T: type, comptime inferred_types: []const typ | ... | @@ -1379,7 +1379,7 @@ fn ParseInternalErrorImpl(comptime T: type, comptime inferred_types: []const typ |
| 1379 | MissingField, | 1379 | MissingField, |
| 1380 | } || SkipValueError || TokenStream.Error; | 1380 | } || SkipValueError || TokenStream.Error; |
| 1381 | for (structInfo.fields) |field| { | 1381 | for (structInfo.fields) |field| { |
| 1382 | errors = errors || ParseInternalErrorImpl(field.field_type, inferred_types ++ [_]type{T}); | 1382 | errors = errors || ParseInternalErrorImpl(field.type, inferred_types ++ [_]type{T}); |
| 1383 | } | 1383 | } |
| 1384 | return errors; | 1384 | return errors; |
| 1385 | }, | 1385 | }, |
| ... | @@ -1491,7 +1491,7 @@ fn parseInternal( | ... | @@ -1491,7 +1491,7 @@ fn parseInternal( |
| 1491 | inline for (unionInfo.fields) |u_field| { | 1491 | inline for (unionInfo.fields) |u_field| { |
| 1492 | // take a copy of tokens so we can withhold mutations until success | 1492 | // take a copy of tokens so we can withhold mutations until success |
| 1493 | var tokens_copy = tokens.*; | 1493 | var tokens_copy = tokens.*; |
| 1494 | if (parseInternal(u_field.field_type, token, &tokens_copy, options)) |value| { | 1494 | if (parseInternal(u_field.type, token, &tokens_copy, options)) |value| { |
| 1495 | tokens.* = tokens_copy; | 1495 | tokens.* = tokens_copy; |
| 1496 | return @unionInit(T, u_field.name, value); | 1496 | return @unionInit(T, u_field.name, value); |
| 1497 | } else |err| { | 1497 | } else |err| { |
| ... | @@ -1519,7 +1519,7 @@ fn parseInternal( | ... | @@ -1519,7 +1519,7 @@ fn parseInternal( |
| 1519 | errdefer { | 1519 | errdefer { |
| 1520 | inline for (structInfo.fields) |field, i| { | 1520 | inline for (structInfo.fields) |field, i| { |
| 1521 | if (fields_seen[i] and !field.is_comptime) { | 1521 | if (fields_seen[i] and !field.is_comptime) { |
| 1522 | parseFree(field.field_type, @field(r, field.name), options); | 1522 | parseFree(field.type, @field(r, field.name), options); |
| 1523 | } | 1523 | } |
| 1524 | } | 1524 | } |
| 1525 | } | 1525 | } |
| ... | @@ -1547,24 +1547,24 @@ fn parseInternal( | ... | @@ -1547,24 +1547,24 @@ fn parseInternal( |
| 1547 | // } | 1547 | // } |
| 1548 | if (options.duplicate_field_behavior == .UseFirst) { | 1548 | if (options.duplicate_field_behavior == .UseFirst) { |
| 1549 | // unconditonally ignore value. for comptime fields, this skips check against default_value | 1549 | // unconditonally ignore value. for comptime fields, this skips check against default_value |
| 1550 | parseFree(field.field_type, try parse(field.field_type, tokens, child_options), child_options); | 1550 | parseFree(field.type, try parse(field.type, tokens, child_options), child_options); |
| 1551 | found = true; | 1551 | found = true; |
| 1552 | break; | 1552 | break; |
| 1553 | } else if (options.duplicate_field_behavior == .Error) { | 1553 | } else if (options.duplicate_field_behavior == .Error) { |
| 1554 | return error.DuplicateJSONField; | 1554 | return error.DuplicateJSONField; |
| 1555 | } else if (options.duplicate_field_behavior == .UseLast) { | 1555 | } else if (options.duplicate_field_behavior == .UseLast) { |
| 1556 | if (!field.is_comptime) { | 1556 | if (!field.is_comptime) { |
| 1557 | parseFree(field.field_type, @field(r, field.name), child_options); | 1557 | parseFree(field.type, @field(r, field.name), child_options); |
| 1558 | } | 1558 | } |
| 1559 | fields_seen[i] = false; | 1559 | fields_seen[i] = false; |
| 1560 | } | 1560 | } |
| 1561 | } | 1561 | } |
| 1562 | if (field.is_comptime) { | 1562 | if (field.is_comptime) { |
| 1563 | if (!try parsesTo(field.field_type, @ptrCast(*align(1) const field.field_type, field.default_value.?).*, tokens, child_options)) { | 1563 | if (!try parsesTo(field.type, @ptrCast(*align(1) const field.type, field.default_value.?).*, tokens, child_options)) { |
| 1564 | return error.UnexpectedValue; | 1564 | return error.UnexpectedValue; |
| 1565 | } | 1565 | } |
| 1566 | } else { | 1566 | } else { |
| 1567 | @field(r, field.name) = try parse(field.field_type, tokens, child_options); | 1567 | @field(r, field.name) = try parse(field.type, tokens, child_options); |
| 1568 | } | 1568 | } |
| 1569 | fields_seen[i] = true; | 1569 | fields_seen[i] = true; |
| 1570 | found = true; | 1570 | found = true; |
| ... | @@ -1587,7 +1587,7 @@ fn parseInternal( | ... | @@ -1587,7 +1587,7 @@ fn parseInternal( |
| 1587 | if (!fields_seen[i]) { | 1587 | if (!fields_seen[i]) { |
| 1588 | if (field.default_value) |default_ptr| { | 1588 | if (field.default_value) |default_ptr| { |
| 1589 | if (!field.is_comptime) { | 1589 | if (!field.is_comptime) { |
| 1590 | const default = @ptrCast(*align(1) const field.field_type, default_ptr).*; | 1590 | const default = @ptrCast(*align(1) const field.type, default_ptr).*; |
| 1591 | @field(r, field.name) = default; | 1591 | @field(r, field.name) = default; |
| 1592 | } | 1592 | } |
| 1593 | } else { | 1593 | } else { |
| ... | @@ -1732,7 +1732,7 @@ pub fn parseFree(comptime T: type, value: T, options: ParseOptions) void { | ... | @@ -1732,7 +1732,7 @@ pub fn parseFree(comptime T: type, value: T, options: ParseOptions) void { |
| 1732 | if (unionInfo.tag_type) |UnionTagType| { | 1732 | if (unionInfo.tag_type) |UnionTagType| { |
| 1733 | inline for (unionInfo.fields) |u_field| { | 1733 | inline for (unionInfo.fields) |u_field| { |
| 1734 | if (value == @field(UnionTagType, u_field.name)) { | 1734 | if (value == @field(UnionTagType, u_field.name)) { |
| 1735 | parseFree(u_field.field_type, @field(value, u_field.name), options); | 1735 | parseFree(u_field.type, @field(value, u_field.name), options); |
| 1736 | break; | 1736 | break; |
| 1737 | } | 1737 | } |
| 1738 | } | 1738 | } |
| ... | @@ -1743,7 +1743,7 @@ pub fn parseFree(comptime T: type, value: T, options: ParseOptions) void { | ... | @@ -1743,7 +1743,7 @@ pub fn parseFree(comptime T: type, value: T, options: ParseOptions) void { |
| 1743 | .Struct => |structInfo| { | 1743 | .Struct => |structInfo| { |
| 1744 | inline for (structInfo.fields) |field| { | 1744 | inline for (structInfo.fields) |field| { |
| 1745 | if (!field.is_comptime) { | 1745 | if (!field.is_comptime) { |
| 1746 | parseFree(field.field_type, @field(value, field.name), options); | 1746 | parseFree(field.type, @field(value, field.name), options); |
| 1747 | } | 1747 | } |
| 1748 | } | 1748 | } |
| 1749 | }, | 1749 | }, |
| ... | @@ -2270,12 +2270,12 @@ pub fn stringify( | ... | @@ -2270,12 +2270,12 @@ pub fn stringify( |
| 2270 | } | 2270 | } |
| 2271 | inline for (S.fields) |Field| { | 2271 | inline for (S.fields) |Field| { |
| 2272 | // don't include void fields | 2272 | // don't include void fields |
| 2273 | if (Field.field_type == void) continue; | 2273 | if (Field.type == void) continue; |
| 2274 | 2274 | ||
| 2275 | var emit_field = true; | 2275 | var emit_field = true; |
| 2276 | 2276 | ||
| 2277 | // don't include optional fields that are null when emit_null_optional_fields is set to false | 2277 | // don't include optional fields that are null when emit_null_optional_fields is set to false |
| 2278 | if (@typeInfo(Field.field_type) == .Optional) { | 2278 | if (@typeInfo(Field.type) == .Optional) { |
| 2279 | if (options.emit_null_optional_fields == false) { | 2279 | if (options.emit_null_optional_fields == false) { |
| 2280 | if (@field(value, Field.name) == null) { | 2280 | if (@field(value, Field.name) == null) { |
| 2281 | emit_field = false; | 2281 | emit_field = false; |
lib/std/mem.zig+4-4| ... | @@ -300,7 +300,7 @@ pub fn zeroes(comptime T: type) T { | ... | @@ -300,7 +300,7 @@ pub fn zeroes(comptime T: type) T { |
| 300 | if (comptime meta.containerLayout(T) == .Extern) { | 300 | if (comptime meta.containerLayout(T) == .Extern) { |
| 301 | // The C language specification states that (global) unions | 301 | // The C language specification states that (global) unions |
| 302 | // should be zero initialized to the first named member. | 302 | // should be zero initialized to the first named member. |
| 303 | return @unionInit(T, info.fields[0].name, zeroes(info.fields[0].field_type)); | 303 | return @unionInit(T, info.fields[0].name, zeroes(info.fields[0].type)); |
| 304 | } | 304 | } |
| 305 | 305 | ||
| 306 | @compileError("Can't set a " ++ @typeName(T) ++ " to zero."); | 306 | @compileError("Can't set a " ++ @typeName(T) ++ " to zero."); |
| ... | @@ -435,7 +435,7 @@ pub fn zeroInit(comptime T: type, init: anytype) T { | ... | @@ -435,7 +435,7 @@ pub fn zeroInit(comptime T: type, init: anytype) T { |
| 435 | 435 | ||
| 436 | inline for (struct_info.fields) |field| { | 436 | inline for (struct_info.fields) |field| { |
| 437 | if (field.default_value) |default_value_ptr| { | 437 | if (field.default_value) |default_value_ptr| { |
| 438 | const default_value = @ptrCast(*align(1) const field.field_type, default_value_ptr).*; | 438 | const default_value = @ptrCast(*align(1) const field.type, default_value_ptr).*; |
| 439 | @field(value, field.name) = default_value; | 439 | @field(value, field.name) = default_value; |
| 440 | } | 440 | } |
| 441 | } | 441 | } |
| ... | @@ -452,9 +452,9 @@ pub fn zeroInit(comptime T: type, init: anytype) T { | ... | @@ -452,9 +452,9 @@ pub fn zeroInit(comptime T: type, init: anytype) T { |
| 452 | @compileError("Encountered an initializer for `" ++ field.name ++ "`, but it is not a field of " ++ @typeName(T)); | 452 | @compileError("Encountered an initializer for `" ++ field.name ++ "`, but it is not a field of " ++ @typeName(T)); |
| 453 | } | 453 | } |
| 454 | 454 | ||
| 455 | switch (@typeInfo(field.field_type)) { | 455 | switch (@typeInfo(field.type)) { |
| 456 | .Struct => { | 456 | .Struct => { |
| 457 | @field(value, field.name) = zeroInit(field.field_type, @field(init, field.name)); | 457 | @field(value, field.name) = zeroInit(field.type, @field(init, field.name)); |
| 458 | }, | 458 | }, |
| 459 | else => { | 459 | else => { |
| 460 | @field(value, field.name) = @field(init, field.name); | 460 | @field(value, field.name) = @field(init, field.name); |
lib/std/meta.zig+12-24| ... | @@ -371,16 +371,12 @@ test "std.meta.assumeSentinel" { | ... | @@ -371,16 +371,12 @@ test "std.meta.assumeSentinel" { |
| 371 | pub fn containerLayout(comptime T: type) Type.ContainerLayout { | 371 | pub fn containerLayout(comptime T: type) Type.ContainerLayout { |
| 372 | return switch (@typeInfo(T)) { | 372 | return switch (@typeInfo(T)) { |
| 373 | .Struct => |info| info.layout, | 373 | .Struct => |info| info.layout, |
| 374 | .Enum => |info| info.layout, | ||
| 375 | .Union => |info| info.layout, | 374 | .Union => |info| info.layout, |
| 376 | else => @compileError("Expected struct, enum or union type, found '" ++ @typeName(T) ++ "'"), | 375 | else => @compileError("expected struct or union type, found '" ++ @typeName(T) ++ "'"), |
| 377 | }; | 376 | }; |
| 378 | } | 377 | } |
| 379 | 378 | ||
| 380 | test "std.meta.containerLayout" { | 379 | test "std.meta.containerLayout" { |
| 381 | const E1 = enum { | ||
| 382 | A, | ||
| 383 | }; | ||
| 384 | const S1 = struct {}; | 380 | const S1 = struct {}; |
| 385 | const S2 = packed struct {}; | 381 | const S2 = packed struct {}; |
| 386 | const S3 = extern struct {}; | 382 | const S3 = extern struct {}; |
| ... | @@ -394,7 +390,6 @@ test "std.meta.containerLayout" { | ... | @@ -394,7 +390,6 @@ test "std.meta.containerLayout" { |
| 394 | a: u8, | 390 | a: u8, |
| 395 | }; | 391 | }; |
| 396 | 392 | ||
| 397 | try testing.expect(containerLayout(E1) == .Auto); | ||
| 398 | try testing.expect(containerLayout(S1) == .Auto); | 393 | try testing.expect(containerLayout(S1) == .Auto); |
| 399 | try testing.expect(containerLayout(S2) == .Packed); | 394 | try testing.expect(containerLayout(S2) == .Packed); |
| 400 | try testing.expect(containerLayout(S3) == .Extern); | 395 | try testing.expect(containerLayout(S3) == .Extern); |
| ... | @@ -522,8 +517,8 @@ test "std.meta.fields" { | ... | @@ -522,8 +517,8 @@ test "std.meta.fields" { |
| 522 | try testing.expect(mem.eql(u8, e2f[0].name, "A")); | 517 | try testing.expect(mem.eql(u8, e2f[0].name, "A")); |
| 523 | try testing.expect(mem.eql(u8, sf[0].name, "a")); | 518 | try testing.expect(mem.eql(u8, sf[0].name, "a")); |
| 524 | try testing.expect(mem.eql(u8, uf[0].name, "a")); | 519 | try testing.expect(mem.eql(u8, uf[0].name, "a")); |
| 525 | try testing.expect(comptime sf[0].field_type == u8); | 520 | try testing.expect(comptime sf[0].type == u8); |
| 526 | try testing.expect(comptime uf[0].field_type == u8); | 521 | try testing.expect(comptime uf[0].type == u8); |
| 527 | } | 522 | } |
| 528 | 523 | ||
| 529 | pub fn fieldInfo(comptime T: type, comptime field: FieldEnum(T)) switch (@typeInfo(T)) { | 524 | pub fn fieldInfo(comptime T: type, comptime field: FieldEnum(T)) switch (@typeInfo(T)) { |
| ... | @@ -557,8 +552,8 @@ test "std.meta.fieldInfo" { | ... | @@ -557,8 +552,8 @@ test "std.meta.fieldInfo" { |
| 557 | try testing.expect(mem.eql(u8, e2f.name, "A")); | 552 | try testing.expect(mem.eql(u8, e2f.name, "A")); |
| 558 | try testing.expect(mem.eql(u8, sf.name, "a")); | 553 | try testing.expect(mem.eql(u8, sf.name, "a")); |
| 559 | try testing.expect(mem.eql(u8, uf.name, "a")); | 554 | try testing.expect(mem.eql(u8, uf.name, "a")); |
| 560 | try testing.expect(comptime sf.field_type == u8); | 555 | try testing.expect(comptime sf.type == u8); |
| 561 | try testing.expect(comptime uf.field_type == u8); | 556 | try testing.expect(comptime uf.type == u8); |
| 562 | } | 557 | } |
| 563 | 558 | ||
| 564 | pub fn fieldNames(comptime T: type) *const [fields(T).len][]const u8 { | 559 | pub fn fieldNames(comptime T: type) *const [fields(T).len][]const u8 { |
| ... | @@ -634,7 +629,6 @@ pub fn FieldEnum(comptime T: type) type { | ... | @@ -634,7 +629,6 @@ pub fn FieldEnum(comptime T: type) type { |
| 634 | if (field_infos.len == 0) { | 629 | if (field_infos.len == 0) { |
| 635 | return @Type(.{ | 630 | return @Type(.{ |
| 636 | .Enum = .{ | 631 | .Enum = .{ |
| 637 | .layout = .Auto, | ||
| 638 | .tag_type = u0, | 632 | .tag_type = u0, |
| 639 | .fields = &.{}, | 633 | .fields = &.{}, |
| 640 | .decls = &.{}, | 634 | .decls = &.{}, |
| ... | @@ -664,7 +658,6 @@ pub fn FieldEnum(comptime T: type) type { | ... | @@ -664,7 +658,6 @@ pub fn FieldEnum(comptime T: type) type { |
| 664 | } | 658 | } |
| 665 | return @Type(.{ | 659 | return @Type(.{ |
| 666 | .Enum = .{ | 660 | .Enum = .{ |
| 667 | .layout = .Auto, | ||
| 668 | .tag_type = std.math.IntFittingRange(0, field_infos.len - 1), | 661 | .tag_type = std.math.IntFittingRange(0, field_infos.len - 1), |
| 669 | .fields = &enumFields, | 662 | .fields = &enumFields, |
| 670 | .decls = &decls, | 663 | .decls = &decls, |
| ... | @@ -676,10 +669,6 @@ pub fn FieldEnum(comptime T: type) type { | ... | @@ -676,10 +669,6 @@ pub fn FieldEnum(comptime T: type) type { |
| 676 | fn expectEqualEnum(expected: anytype, actual: @TypeOf(expected)) !void { | 669 | fn expectEqualEnum(expected: anytype, actual: @TypeOf(expected)) !void { |
| 677 | // TODO: https://github.com/ziglang/zig/issues/7419 | 670 | // TODO: https://github.com/ziglang/zig/issues/7419 |
| 678 | // testing.expectEqual(@typeInfo(expected).Enum, @typeInfo(actual).Enum); | 671 | // testing.expectEqual(@typeInfo(expected).Enum, @typeInfo(actual).Enum); |
| 679 | try testing.expectEqual( | ||
| 680 | @typeInfo(expected).Enum.layout, | ||
| 681 | @typeInfo(actual).Enum.layout, | ||
| 682 | ); | ||
| 683 | try testing.expectEqual( | 672 | try testing.expectEqual( |
| 684 | @typeInfo(expected).Enum.tag_type, | 673 | @typeInfo(expected).Enum.tag_type, |
| 685 | @typeInfo(actual).Enum.tag_type, | 674 | @typeInfo(actual).Enum.tag_type, |
| ... | @@ -740,7 +729,6 @@ pub fn DeclEnum(comptime T: type) type { | ... | @@ -740,7 +729,6 @@ pub fn DeclEnum(comptime T: type) type { |
| 740 | } | 729 | } |
| 741 | return @Type(.{ | 730 | return @Type(.{ |
| 742 | .Enum = .{ | 731 | .Enum = .{ |
| 743 | .layout = .Auto, | ||
| 744 | .tag_type = std.math.IntFittingRange(0, fieldInfos.len - 1), | 732 | .tag_type = std.math.IntFittingRange(0, fieldInfos.len - 1), |
| 745 | .fields = &enumDecls, | 733 | .fields = &enumDecls, |
| 746 | .decls = &decls, | 734 | .decls = &decls, |
| ... | @@ -831,7 +819,7 @@ pub fn TagPayload(comptime U: type, comptime tag: Tag(U)) type { | ... | @@ -831,7 +819,7 @@ pub fn TagPayload(comptime U: type, comptime tag: Tag(U)) type { |
| 831 | 819 | ||
| 832 | inline for (info.fields) |field_info| { | 820 | inline for (info.fields) |field_info| { |
| 833 | if (comptime mem.eql(u8, field_info.name, @tagName(tag))) | 821 | if (comptime mem.eql(u8, field_info.name, @tagName(tag))) |
| 834 | return field_info.field_type; | 822 | return field_info.type; |
| 835 | } | 823 | } |
| 836 | 824 | ||
| 837 | unreachable; | 825 | unreachable; |
| ... | @@ -1084,9 +1072,9 @@ pub fn ArgsTuple(comptime Function: type) type { | ... | @@ -1084,9 +1072,9 @@ pub fn ArgsTuple(comptime Function: type) type { |
| 1084 | if (function_info.is_var_args) | 1072 | if (function_info.is_var_args) |
| 1085 | @compileError("Cannot create ArgsTuple for variadic function"); | 1073 | @compileError("Cannot create ArgsTuple for variadic function"); |
| 1086 | 1074 | ||
| 1087 | var argument_field_list: [function_info.args.len]type = undefined; | 1075 | var argument_field_list: [function_info.params.len]type = undefined; |
| 1088 | inline for (function_info.args) |arg, i| { | 1076 | inline for (function_info.params) |arg, i| { |
| 1089 | const T = arg.arg_type.?; | 1077 | const T = arg.type.?; |
| 1090 | argument_field_list[i] = T; | 1078 | argument_field_list[i] = T; |
| 1091 | } | 1079 | } |
| 1092 | 1080 | ||
| ... | @@ -1111,7 +1099,7 @@ fn CreateUniqueTuple(comptime N: comptime_int, comptime types: [N]type) type { | ... | @@ -1111,7 +1099,7 @@ fn CreateUniqueTuple(comptime N: comptime_int, comptime types: [N]type) type { |
| 1111 | var num_buf: [128]u8 = undefined; | 1099 | var num_buf: [128]u8 = undefined; |
| 1112 | tuple_fields[i] = .{ | 1100 | tuple_fields[i] = .{ |
| 1113 | .name = std.fmt.bufPrint(&num_buf, "{d}", .{i}) catch unreachable, | 1101 | .name = std.fmt.bufPrint(&num_buf, "{d}", .{i}) catch unreachable, |
| 1114 | .field_type = T, | 1102 | .type = T, |
| 1115 | .default_value = null, | 1103 | .default_value = null, |
| 1116 | .is_comptime = false, | 1104 | .is_comptime = false, |
| 1117 | .alignment = if (@sizeOf(T) > 0) @alignOf(T) else 0, | 1105 | .alignment = if (@sizeOf(T) > 0) @alignOf(T) else 0, |
| ... | @@ -1146,8 +1134,8 @@ const TupleTester = struct { | ... | @@ -1146,8 +1134,8 @@ const TupleTester = struct { |
| 1146 | @compileError("Argument count mismatch"); | 1134 | @compileError("Argument count mismatch"); |
| 1147 | 1135 | ||
| 1148 | inline for (fields_list) |fld, i| { | 1136 | inline for (fields_list) |fld, i| { |
| 1149 | if (expected[i] != fld.field_type) { | 1137 | if (expected[i] != fld.type) { |
| 1150 | @compileError("Field " ++ fld.name ++ " expected to be type " ++ @typeName(expected[i]) ++ ", but was type " ++ @typeName(fld.field_type)); | 1138 | @compileError("Field " ++ fld.name ++ " expected to be type " ++ @typeName(expected[i]) ++ ", but was type " ++ @typeName(fld.type)); |
| 1151 | } | 1139 | } |
| 1152 | } | 1140 | } |
| 1153 | } | 1141 | } |
lib/std/meta/trailer_flags.zig+10-10| ... | @@ -24,10 +24,10 @@ pub fn TrailerFlags(comptime Fields: type) type { | ... | @@ -24,10 +24,10 @@ pub fn TrailerFlags(comptime Fields: type) type { |
| 24 | inline for (@typeInfo(Fields).Struct.fields) |struct_field, i| { | 24 | inline for (@typeInfo(Fields).Struct.fields) |struct_field, i| { |
| 25 | fields[i] = Type.StructField{ | 25 | fields[i] = Type.StructField{ |
| 26 | .name = struct_field.name, | 26 | .name = struct_field.name, |
| 27 | .field_type = ?struct_field.field_type, | 27 | .type = ?struct_field.type, |
| 28 | .default_value = &@as(?struct_field.field_type, null), | 28 | .default_value = &@as(?struct_field.type, null), |
| 29 | .is_comptime = false, | 29 | .is_comptime = false, |
| 30 | .alignment = @alignOf(?struct_field.field_type), | 30 | .alignment = @alignOf(?struct_field.type), |
| 31 | }; | 31 | }; |
| 32 | } | 32 | } |
| 33 | break :blk @Type(.{ | 33 | break :blk @Type(.{ |
| ... | @@ -105,26 +105,26 @@ pub fn TrailerFlags(comptime Fields: type) type { | ... | @@ -105,26 +105,26 @@ pub fn TrailerFlags(comptime Fields: type) type { |
| 105 | const active = (self.bits & (1 << i)) != 0; | 105 | const active = (self.bits & (1 << i)) != 0; |
| 106 | if (i == @enumToInt(field)) { | 106 | if (i == @enumToInt(field)) { |
| 107 | assert(active); | 107 | assert(active); |
| 108 | return mem.alignForwardGeneric(usize, off, @alignOf(field_info.field_type)); | 108 | return mem.alignForwardGeneric(usize, off, @alignOf(field_info.type)); |
| 109 | } else if (active) { | 109 | } else if (active) { |
| 110 | off = mem.alignForwardGeneric(usize, off, @alignOf(field_info.field_type)); | 110 | off = mem.alignForwardGeneric(usize, off, @alignOf(field_info.type)); |
| 111 | off += @sizeOf(field_info.field_type); | 111 | off += @sizeOf(field_info.type); |
| 112 | } | 112 | } |
| 113 | } | 113 | } |
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | pub fn Field(comptime field: FieldEnum) type { | 116 | pub fn Field(comptime field: FieldEnum) type { |
| 117 | return @typeInfo(Fields).Struct.fields[@enumToInt(field)].field_type; | 117 | return @typeInfo(Fields).Struct.fields[@enumToInt(field)].type; |
| 118 | } | 118 | } |
| 119 | 119 | ||
| 120 | pub fn sizeInBytes(self: Self) usize { | 120 | pub fn sizeInBytes(self: Self) usize { |
| 121 | var off: usize = 0; | 121 | var off: usize = 0; |
| 122 | inline for (@typeInfo(Fields).Struct.fields) |field, i| { | 122 | inline for (@typeInfo(Fields).Struct.fields) |field, i| { |
| 123 | if (@sizeOf(field.field_type) == 0) | 123 | if (@sizeOf(field.type) == 0) |
| 124 | continue; | 124 | continue; |
| 125 | if ((self.bits & (1 << i)) != 0) { | 125 | if ((self.bits & (1 << i)) != 0) { |
| 126 | off = mem.alignForwardGeneric(usize, off, @alignOf(field.field_type)); | 126 | off = mem.alignForwardGeneric(usize, off, @alignOf(field.type)); |
| 127 | off += @sizeOf(field.field_type); | 127 | off += @sizeOf(field.type); |
| 128 | } | 128 | } |
| 129 | } | 129 | } |
| 130 | return off; | 130 | return off; |
lib/std/meta/trait.zig+1-3| ... | @@ -154,7 +154,6 @@ pub fn isExtern(comptime T: type) bool { | ... | @@ -154,7 +154,6 @@ pub fn isExtern(comptime T: type) bool { |
| 154 | return switch (@typeInfo(T)) { | 154 | return switch (@typeInfo(T)) { |
| 155 | .Struct => |s| s.layout == .Extern, | 155 | .Struct => |s| s.layout == .Extern, |
| 156 | .Union => |u| u.layout == .Extern, | 156 | .Union => |u| u.layout == .Extern, |
| 157 | .Enum => |e| e.layout == .Extern, | ||
| 158 | else => false, | 157 | else => false, |
| 159 | }; | 158 | }; |
| 160 | } | 159 | } |
| ... | @@ -172,7 +171,6 @@ pub fn isPacked(comptime T: type) bool { | ... | @@ -172,7 +171,6 @@ pub fn isPacked(comptime T: type) bool { |
| 172 | return switch (@typeInfo(T)) { | 171 | return switch (@typeInfo(T)) { |
| 173 | .Struct => |s| s.layout == .Packed, | 172 | .Struct => |s| s.layout == .Packed, |
| 174 | .Union => |u| u.layout == .Packed, | 173 | .Union => |u| u.layout == .Packed, |
| 175 | .Enum => |e| e.layout == .Packed, | ||
| 176 | else => false, | 174 | else => false, |
| 177 | }; | 175 | }; |
| 178 | } | 176 | } |
| ... | @@ -566,7 +564,7 @@ pub fn hasUniqueRepresentation(comptime T: type) bool { | ... | @@ -566,7 +564,7 @@ pub fn hasUniqueRepresentation(comptime T: type) bool { |
| 566 | var sum_size = @as(usize, 0); | 564 | var sum_size = @as(usize, 0); |
| 567 | 565 | ||
| 568 | inline for (info.fields) |field| { | 566 | inline for (info.fields) |field| { |
| 569 | const FieldType = field.field_type; | 567 | const FieldType = field.type; |
| 570 | if (comptime !hasUniqueRepresentation(FieldType)) return false; | 568 | if (comptime !hasUniqueRepresentation(FieldType)) return false; |
| 571 | sum_size += @sizeOf(FieldType); | 569 | sum_size += @sizeOf(FieldType); |
| 572 | } | 570 | } |
lib/std/multi_array_list.zig+13-13| ... | @@ -84,9 +84,9 @@ pub fn MultiArrayList(comptime S: type) type { | ... | @@ -84,9 +84,9 @@ pub fn MultiArrayList(comptime S: type) type { |
| 84 | var data: [fields.len]Data = undefined; | 84 | var data: [fields.len]Data = undefined; |
| 85 | for (fields) |field_info, i| { | 85 | for (fields) |field_info, i| { |
| 86 | data[i] = .{ | 86 | data[i] = .{ |
| 87 | .size = @sizeOf(field_info.field_type), | 87 | .size = @sizeOf(field_info.type), |
| 88 | .size_index = i, | 88 | .size_index = i, |
| 89 | .alignment = if (@sizeOf(field_info.field_type) == 0) 1 else field_info.alignment, | 89 | .alignment = if (@sizeOf(field_info.type) == 0) 1 else field_info.alignment, |
| 90 | }; | 90 | }; |
| 91 | } | 91 | } |
| 92 | const Sort = struct { | 92 | const Sort = struct { |
| ... | @@ -294,10 +294,10 @@ pub fn MultiArrayList(comptime S: type) type { | ... | @@ -294,10 +294,10 @@ pub fn MultiArrayList(comptime S: type) type { |
| 294 | ) catch { | 294 | ) catch { |
| 295 | const self_slice = self.slice(); | 295 | const self_slice = self.slice(); |
| 296 | inline for (fields) |field_info, i| { | 296 | inline for (fields) |field_info, i| { |
| 297 | if (@sizeOf(field_info.field_type) != 0) { | 297 | if (@sizeOf(field_info.type) != 0) { |
| 298 | const field = @intToEnum(Field, i); | 298 | const field = @intToEnum(Field, i); |
| 299 | const dest_slice = self_slice.items(field)[new_len..]; | 299 | const dest_slice = self_slice.items(field)[new_len..]; |
| 300 | const byte_count = dest_slice.len * @sizeOf(field_info.field_type); | 300 | const byte_count = dest_slice.len * @sizeOf(field_info.type); |
| 301 | // We use memset here for more efficient codegen in safety-checked, | 301 | // We use memset here for more efficient codegen in safety-checked, |
| 302 | // valgrind-enabled builds. Otherwise the valgrind client request | 302 | // valgrind-enabled builds. Otherwise the valgrind client request |
| 303 | // will be repeated for every element. | 303 | // will be repeated for every element. |
| ... | @@ -316,9 +316,9 @@ pub fn MultiArrayList(comptime S: type) type { | ... | @@ -316,9 +316,9 @@ pub fn MultiArrayList(comptime S: type) type { |
| 316 | const self_slice = self.slice(); | 316 | const self_slice = self.slice(); |
| 317 | const other_slice = other.slice(); | 317 | const other_slice = other.slice(); |
| 318 | inline for (fields) |field_info, i| { | 318 | inline for (fields) |field_info, i| { |
| 319 | if (@sizeOf(field_info.field_type) != 0) { | 319 | if (@sizeOf(field_info.type) != 0) { |
| 320 | const field = @intToEnum(Field, i); | 320 | const field = @intToEnum(Field, i); |
| 321 | mem.copy(field_info.field_type, other_slice.items(field), self_slice.items(field)); | 321 | mem.copy(field_info.type, other_slice.items(field), self_slice.items(field)); |
| 322 | } | 322 | } |
| 323 | } | 323 | } |
| 324 | gpa.free(self.allocatedBytes()); | 324 | gpa.free(self.allocatedBytes()); |
| ... | @@ -377,9 +377,9 @@ pub fn MultiArrayList(comptime S: type) type { | ... | @@ -377,9 +377,9 @@ pub fn MultiArrayList(comptime S: type) type { |
| 377 | const self_slice = self.slice(); | 377 | const self_slice = self.slice(); |
| 378 | const other_slice = other.slice(); | 378 | const other_slice = other.slice(); |
| 379 | inline for (fields) |field_info, i| { | 379 | inline for (fields) |field_info, i| { |
| 380 | if (@sizeOf(field_info.field_type) != 0) { | 380 | if (@sizeOf(field_info.type) != 0) { |
| 381 | const field = @intToEnum(Field, i); | 381 | const field = @intToEnum(Field, i); |
| 382 | mem.copy(field_info.field_type, other_slice.items(field), self_slice.items(field)); | 382 | mem.copy(field_info.type, other_slice.items(field), self_slice.items(field)); |
| 383 | } | 383 | } |
| 384 | } | 384 | } |
| 385 | gpa.free(self.allocatedBytes()); | 385 | gpa.free(self.allocatedBytes()); |
| ... | @@ -396,9 +396,9 @@ pub fn MultiArrayList(comptime S: type) type { | ... | @@ -396,9 +396,9 @@ pub fn MultiArrayList(comptime S: type) type { |
| 396 | const self_slice = self.slice(); | 396 | const self_slice = self.slice(); |
| 397 | const result_slice = result.slice(); | 397 | const result_slice = result.slice(); |
| 398 | inline for (fields) |field_info, i| { | 398 | inline for (fields) |field_info, i| { |
| 399 | if (@sizeOf(field_info.field_type) != 0) { | 399 | if (@sizeOf(field_info.type) != 0) { |
| 400 | const field = @intToEnum(Field, i); | 400 | const field = @intToEnum(Field, i); |
| 401 | mem.copy(field_info.field_type, result_slice.items(field), self_slice.items(field)); | 401 | mem.copy(field_info.type, result_slice.items(field), self_slice.items(field)); |
| 402 | } | 402 | } |
| 403 | } | 403 | } |
| 404 | return result; | 404 | return result; |
| ... | @@ -413,10 +413,10 @@ pub fn MultiArrayList(comptime S: type) type { | ... | @@ -413,10 +413,10 @@ pub fn MultiArrayList(comptime S: type) type { |
| 413 | 413 | ||
| 414 | pub fn swap(sc: @This(), a_index: usize, b_index: usize) void { | 414 | pub fn swap(sc: @This(), a_index: usize, b_index: usize) void { |
| 415 | inline for (fields) |field_info, i| { | 415 | inline for (fields) |field_info, i| { |
| 416 | if (@sizeOf(field_info.field_type) != 0) { | 416 | if (@sizeOf(field_info.type) != 0) { |
| 417 | const field = @intToEnum(Field, i); | 417 | const field = @intToEnum(Field, i); |
| 418 | const ptr = sc.slice.items(field); | 418 | const ptr = sc.slice.items(field); |
| 419 | mem.swap(field_info.field_type, &ptr[a_index], &ptr[b_index]); | 419 | mem.swap(field_info.type, &ptr[a_index], &ptr[b_index]); |
| 420 | } | 420 | } |
| 421 | } | 421 | } |
| 422 | } | 422 | } |
| ... | @@ -449,7 +449,7 @@ pub fn MultiArrayList(comptime S: type) type { | ... | @@ -449,7 +449,7 @@ pub fn MultiArrayList(comptime S: type) type { |
| 449 | } | 449 | } |
| 450 | 450 | ||
| 451 | fn FieldType(comptime field: Field) type { | 451 | fn FieldType(comptime field: Field) type { |
| 452 | return meta.fieldInfo(S, field).field_type; | 452 | return meta.fieldInfo(S, field).type; |
| 453 | } | 453 | } |
| 454 | 454 | ||
| 455 | /// This function is used in tools/zig-gdb.py to fetch the child type to facilitate | 455 | /// This function is used in tools/zig-gdb.py to fetch the child type to facilitate |
lib/std/os/uefi/protocols/device_path_protocol.zig+2-2| ... | @@ -81,7 +81,7 @@ pub const DevicePathProtocol = extern struct { | ... | @@ -81,7 +81,7 @@ pub const DevicePathProtocol = extern struct { |
| 81 | // Got the associated union type for self.type, now | 81 | // Got the associated union type for self.type, now |
| 82 | // we need to initialize it and its subtype | 82 | // we need to initialize it and its subtype |
| 83 | if (self.type == enum_value) { | 83 | if (self.type == enum_value) { |
| 84 | var subtype = self.initSubtype(ufield.field_type); | 84 | var subtype = self.initSubtype(ufield.type); |
| 85 | 85 | ||
| 86 | if (subtype) |sb| { | 86 | if (subtype) |sb| { |
| 87 | // e.g. return .{ .Hardware = .{ .Pci = @ptrCast(...) } } | 87 | // e.g. return .{ .Hardware = .{ .Pci = @ptrCast(...) } } |
| ... | @@ -103,7 +103,7 @@ pub const DevicePathProtocol = extern struct { | ... | @@ -103,7 +103,7 @@ pub const DevicePathProtocol = extern struct { |
| 103 | 103 | ||
| 104 | if (self.subtype == tag_val) { | 104 | if (self.subtype == tag_val) { |
| 105 | // e.g. expr = .{ .Pci = @ptrCast(...) } | 105 | // e.g. expr = .{ .Pci = @ptrCast(...) } |
| 106 | return @unionInit(TUnion, subtype.name, @ptrCast(subtype.field_type, self)); | 106 | return @unionInit(TUnion, subtype.name, @ptrCast(subtype.type, self)); |
| 107 | } | 107 | } |
| 108 | } | 108 | } |
| 109 | 109 |
lib/std/start.zig+1-1| ... | @@ -634,7 +634,7 @@ pub fn callMain() u8 { | ... | @@ -634,7 +634,7 @@ pub fn callMain() u8 { |
| 634 | } | 634 | } |
| 635 | 635 | ||
| 636 | pub fn call_wWinMain() std.os.windows.INT { | 636 | pub fn call_wWinMain() std.os.windows.INT { |
| 637 | const MAIN_HINSTANCE = @typeInfo(@TypeOf(root.wWinMain)).Fn.args[0].arg_type.?; | 637 | const MAIN_HINSTANCE = @typeInfo(@TypeOf(root.wWinMain)).Fn.params[0].type.?; |
| 638 | const hInstance = @ptrCast(MAIN_HINSTANCE, std.os.windows.kernel32.GetModuleHandleW(null).?); | 638 | const hInstance = @ptrCast(MAIN_HINSTANCE, std.os.windows.kernel32.GetModuleHandleW(null).?); |
| 639 | const lpCmdLine = std.os.windows.kernel32.GetCommandLineW(); | 639 | const lpCmdLine = std.os.windows.kernel32.GetCommandLineW(); |
| 640 | 640 |
lib/std/testing.zig+1-1| ... | @@ -802,7 +802,7 @@ pub fn checkAllAllocationFailures(backing_allocator: std.mem.Allocator, comptime | ... | @@ -802,7 +802,7 @@ pub fn checkAllAllocationFailures(backing_allocator: std.mem.Allocator, comptime |
| 802 | 802 | ||
| 803 | const ArgsTuple = std.meta.ArgsTuple(@TypeOf(test_fn)); | 803 | const ArgsTuple = std.meta.ArgsTuple(@TypeOf(test_fn)); |
| 804 | const fn_args_fields = @typeInfo(ArgsTuple).Struct.fields; | 804 | const fn_args_fields = @typeInfo(ArgsTuple).Struct.fields; |
| 805 | if (fn_args_fields.len == 0 or fn_args_fields[0].field_type != std.mem.Allocator) { | 805 | if (fn_args_fields.len == 0 or fn_args_fields[0].type != std.mem.Allocator) { |
| 806 | @compileError("The provided function must have an " ++ @typeName(std.mem.Allocator) ++ " as its first argument"); | 806 | @compileError("The provided function must have an " ++ @typeName(std.mem.Allocator) ++ " as its first argument"); |
| 807 | } | 807 | } |
| 808 | const expected_args_tuple_len = fn_args_fields.len - 1; | 808 | const expected_args_tuple_len = fn_args_fields.len - 1; |
lib/std/x/os/socket.zig+4-4| ... | @@ -230,12 +230,12 @@ pub const Socket = struct { | ... | @@ -230,12 +230,12 @@ pub const Socket = struct { |
| 230 | 230 | ||
| 231 | pub fn setName(self: *Self, name: []const u8) void { | 231 | pub fn setName(self: *Self, name: []const u8) void { |
| 232 | self.name = @ptrToInt(name.ptr); | 232 | self.name = @ptrToInt(name.ptr); |
| 233 | self.name_len = @intCast(meta.fieldInfo(Self, .name_len).field_type, name.len); | 233 | self.name_len = @intCast(meta.fieldInfo(Self, .name_len).type, name.len); |
| 234 | } | 234 | } |
| 235 | 235 | ||
| 236 | pub fn setBuffers(self: *Self, buffers: []const Buffer) void { | 236 | pub fn setBuffers(self: *Self, buffers: []const Buffer) void { |
| 237 | self.buffers = @ptrToInt(buffers.ptr); | 237 | self.buffers = @ptrToInt(buffers.ptr); |
| 238 | self.buffers_len = @intCast(meta.fieldInfo(Self, .buffers_len).field_type, buffers.len); | 238 | self.buffers_len = @intCast(meta.fieldInfo(Self, .buffers_len).type, buffers.len); |
| 239 | } | 239 | } |
| 240 | 240 | ||
| 241 | pub fn setControl(self: *Self, control: []const u8) void { | 241 | pub fn setControl(self: *Self, control: []const u8) void { |
| ... | @@ -243,12 +243,12 @@ pub const Socket = struct { | ... | @@ -243,12 +243,12 @@ pub const Socket = struct { |
| 243 | self.control = Buffer.from(control); | 243 | self.control = Buffer.from(control); |
| 244 | } else { | 244 | } else { |
| 245 | self.control = @ptrToInt(control.ptr); | 245 | self.control = @ptrToInt(control.ptr); |
| 246 | self.control_len = @intCast(meta.fieldInfo(Self, .control_len).field_type, control.len); | 246 | self.control_len = @intCast(meta.fieldInfo(Self, .control_len).type, control.len); |
| 247 | } | 247 | } |
| 248 | } | 248 | } |
| 249 | 249 | ||
| 250 | pub fn setFlags(self: *Self, flags: u32) void { | 250 | pub fn setFlags(self: *Self, flags: u32) void { |
| 251 | self.flags = @intCast(meta.fieldInfo(Self, .flags).field_type, flags); | 251 | self.flags = @intCast(meta.fieldInfo(Self, .flags).type, flags); |
| 252 | } | 252 | } |
| 253 | 253 | ||
| 254 | pub fn getName(self: Self) []const u8 { | 254 | pub fn getName(self: Self) []const u8 { |
lib/std/zig/Ast.zig+1-1| ... | @@ -125,7 +125,7 @@ pub fn extraData(tree: Ast, index: usize, comptime T: type) T { | ... | @@ -125,7 +125,7 @@ pub fn extraData(tree: Ast, index: usize, comptime T: type) T { |
| 125 | const fields = std.meta.fields(T); | 125 | const fields = std.meta.fields(T); |
| 126 | var result: T = undefined; | 126 | var result: T = undefined; |
| 127 | inline for (fields) |field, i| { | 127 | inline for (fields) |field, i| { |
| 128 | comptime assert(field.field_type == Node.Index); | 128 | comptime assert(field.type == Node.Index); |
| 129 | @field(result, field.name) = tree.extra_data[index + i]; | 129 | @field(result, field.name) = tree.extra_data[index + i]; |
| 130 | } | 130 | } |
| 131 | return result; | 131 | return result; |
lib/std/zig/c_translation.zig+1-1| ... | @@ -50,7 +50,7 @@ pub fn cast(comptime DestType: type, target: anytype) DestType { | ... | @@ -50,7 +50,7 @@ pub fn cast(comptime DestType: type, target: anytype) DestType { |
| 50 | }, | 50 | }, |
| 51 | .Union => |info| { | 51 | .Union => |info| { |
| 52 | inline for (info.fields) |field| { | 52 | inline for (info.fields) |field| { |
| 53 | if (field.field_type == SourceType) return @unionInit(DestType, field.name, target); | 53 | if (field.type == SourceType) return @unionInit(DestType, field.name, target); |
| 54 | } | 54 | } |
| 55 | @compileError("cast to union type '" ++ @typeName(DestType) ++ "' from type '" ++ @typeName(SourceType) ++ "' which is not present in union"); | 55 | @compileError("cast to union type '" ++ @typeName(DestType) ++ "' from type '" ++ @typeName(SourceType) ++ "' which is not present in union"); |
| 56 | }, | 56 | }, |
lib/std/zig/parse.zig+1-1| ... | @@ -153,7 +153,7 @@ const Parser = struct { | ... | @@ -153,7 +153,7 @@ const Parser = struct { |
| 153 | try p.extra_data.ensureUnusedCapacity(p.gpa, fields.len); | 153 | try p.extra_data.ensureUnusedCapacity(p.gpa, fields.len); |
| 154 | const result = @intCast(u32, p.extra_data.items.len); | 154 | const result = @intCast(u32, p.extra_data.items.len); |
| 155 | inline for (fields) |field| { | 155 | inline for (fields) |field| { |
| 156 | comptime assert(field.field_type == Node.Index); | 156 | comptime assert(field.type == Node.Index); |
| 157 | p.extra_data.appendAssumeCapacity(@field(extra, field.name)); | 157 | p.extra_data.appendAssumeCapacity(@field(extra, field.name)); |
| 158 | } | 158 | } |
| 159 | return result; | 159 | return result; |
src/Air.zig+1-1| ... | @@ -1260,7 +1260,7 @@ pub fn extraData(air: Air, comptime T: type, index: usize) struct { data: T, end | ... | @@ -1260,7 +1260,7 @@ pub fn extraData(air: Air, comptime T: type, index: usize) struct { data: T, end |
| 1260 | var i: usize = index; | 1260 | var i: usize = index; |
| 1261 | var result: T = undefined; | 1261 | var result: T = undefined; |
| 1262 | inline for (fields) |field| { | 1262 | inline for (fields) |field| { |
| 1263 | @field(result, field.name) = switch (field.field_type) { | 1263 | @field(result, field.name) = switch (field.type) { |
| 1264 | u32 => air.extra[i], | 1264 | u32 => air.extra[i], |
| 1265 | Inst.Ref => @intToEnum(Inst.Ref, air.extra[i]), | 1265 | Inst.Ref => @intToEnum(Inst.Ref, air.extra[i]), |
| 1266 | i32 => @bitCast(i32, air.extra[i]), | 1266 | i32 => @bitCast(i32, air.extra[i]), |
src/AstGen.zig+1-1| ... | @@ -79,7 +79,7 @@ fn setExtra(astgen: *AstGen, index: usize, extra: anytype) void { | ... | @@ -79,7 +79,7 @@ fn setExtra(astgen: *AstGen, index: usize, extra: anytype) void { |
| 79 | const fields = std.meta.fields(@TypeOf(extra)); | 79 | const fields = std.meta.fields(@TypeOf(extra)); |
| 80 | var i = index; | 80 | var i = index; |
| 81 | inline for (fields) |field| { | 81 | inline for (fields) |field| { |
| 82 | astgen.extra.items[i] = switch (field.field_type) { | 82 | astgen.extra.items[i] = switch (field.type) { |
| 83 | u32 => @field(extra, field.name), | 83 | u32 => @field(extra, field.name), |
| 84 | Zir.Inst.Ref => @enumToInt(@field(extra, field.name)), | 84 | Zir.Inst.Ref => @enumToInt(@field(extra, field.name)), |
| 85 | i32 => @bitCast(u32, @field(extra, field.name)), | 85 | i32 => @bitCast(u32, @field(extra, field.name)), |
src/Autodoc.zig+2-2| ... | @@ -637,9 +637,9 @@ const DocData = struct { | ... | @@ -637,9 +637,9 @@ const DocData = struct { |
| 637 | inline for (comptime std.meta.fields(Type)) |case| { | 637 | inline for (comptime std.meta.fields(Type)) |case| { |
| 638 | if (@field(Type, case.name) == active_tag) { | 638 | if (@field(Type, case.name) == active_tag) { |
| 639 | const current_value = @field(self, case.name); | 639 | const current_value = @field(self, case.name); |
| 640 | inline for (comptime std.meta.fields(case.field_type)) |f| { | 640 | inline for (comptime std.meta.fields(case.type)) |f| { |
| 641 | try jsw.arrayElem(); | 641 | try jsw.arrayElem(); |
| 642 | if (f.field_type == std.builtin.Type.Pointer.Size) { | 642 | if (f.type == std.builtin.Type.Pointer.Size) { |
| 643 | try jsw.emitNumber(@enumToInt(@field(current_value, f.name))); | 643 | try jsw.emitNumber(@enumToInt(@field(current_value, f.name))); |
| 644 | } else { | 644 | } else { |
| 645 | try std.json.stringify(@field(current_value, f.name), opts, w); | 645 | try std.json.stringify(@field(current_value, f.name), opts, w); |
src/InternPool.zig+2-2| ... | @@ -259,7 +259,7 @@ fn addExtraAssumeCapacity(ip: *InternPool, extra: anytype) u32 { | ... | @@ -259,7 +259,7 @@ fn addExtraAssumeCapacity(ip: *InternPool, extra: anytype) u32 { |
| 259 | const fields = std.meta.fields(@TypeOf(extra)); | 259 | const fields = std.meta.fields(@TypeOf(extra)); |
| 260 | const result = @intCast(u32, ip.extra.items.len); | 260 | const result = @intCast(u32, ip.extra.items.len); |
| 261 | inline for (fields) |field| { | 261 | inline for (fields) |field| { |
| 262 | ip.extra.appendAssumeCapacity(switch (field.field_type) { | 262 | ip.extra.appendAssumeCapacity(switch (field.type) { |
| 263 | u32 => @field(extra, field.name), | 263 | u32 => @field(extra, field.name), |
| 264 | Index => @enumToInt(@field(extra, field.name)), | 264 | Index => @enumToInt(@field(extra, field.name)), |
| 265 | i32 => @bitCast(u32, @field(extra, field.name)), | 265 | i32 => @bitCast(u32, @field(extra, field.name)), |
| ... | @@ -274,7 +274,7 @@ fn extraData(ip: InternPool, comptime T: type, index: usize) T { | ... | @@ -274,7 +274,7 @@ fn extraData(ip: InternPool, comptime T: type, index: usize) T { |
| 274 | var i: usize = index; | 274 | var i: usize = index; |
| 275 | var result: T = undefined; | 275 | var result: T = undefined; |
| 276 | inline for (fields) |field| { | 276 | inline for (fields) |field| { |
| 277 | @field(result, field.name) = switch (field.field_type) { | 277 | @field(result, field.name) = switch (field.type) { |
| 278 | u32 => ip.extra.items[i], | 278 | u32 => ip.extra.items[i], |
| 279 | Index => @intToEnum(Index, ip.extra.items[i]), | 279 | Index => @intToEnum(Index, ip.extra.items[i]), |
| 280 | i32 => @bitCast(i32, ip.extra.items[i]), | 280 | i32 => @bitCast(i32, ip.extra.items[i]), |
src/Liveness.zig+1-1| ... | @@ -718,7 +718,7 @@ const Analysis = struct { | ... | @@ -718,7 +718,7 @@ const Analysis = struct { |
| 718 | const fields = std.meta.fields(@TypeOf(extra)); | 718 | const fields = std.meta.fields(@TypeOf(extra)); |
| 719 | const result = @intCast(u32, a.extra.items.len); | 719 | const result = @intCast(u32, a.extra.items.len); |
| 720 | inline for (fields) |field| { | 720 | inline for (fields) |field| { |
| 721 | a.extra.appendAssumeCapacity(switch (field.field_type) { | 721 | a.extra.appendAssumeCapacity(switch (field.type) { |
| 722 | u32 => @field(extra, field.name), | 722 | u32 => @field(extra, field.name), |
| 723 | else => @compileError("bad field type"), | 723 | else => @compileError("bad field type"), |
| 724 | }); | 724 | }); |
src/Sema.zig+18-32| ... | @@ -15319,7 +15319,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -15319,7 +15319,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 15319 | Value.makeBool(is_generic), | 15319 | Value.makeBool(is_generic), |
| 15320 | // is_noalias: bool, | 15320 | // is_noalias: bool, |
| 15321 | Value.makeBool(is_noalias), | 15321 | Value.makeBool(is_noalias), |
| 15322 | // arg_type: ?type, | 15322 | // type: ?type, |
| 15323 | param_ty_val, | 15323 | param_ty_val, |
| 15324 | }; | 15324 | }; |
| 15325 | param_val.* = try Value.Tag.aggregate.create(params_anon_decl.arena(), param_fields); | 15325 | param_val.* = try Value.Tag.aggregate.create(params_anon_decl.arena(), param_fields); |
| ... | @@ -15693,14 +15693,8 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -15693,14 +15693,8 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 15693 | 15693 | ||
| 15694 | const decls_val = try sema.typeInfoDecls(block, src, type_info_ty, ty.getNamespace()); | 15694 | const decls_val = try sema.typeInfoDecls(block, src, type_info_ty, ty.getNamespace()); |
| 15695 | 15695 | ||
| 15696 | const field_values = try sema.arena.create([5]Value); | 15696 | const field_values = try sema.arena.create([4]Value); |
| 15697 | field_values.* = .{ | 15697 | field_values.* = .{ |
| 15698 | // layout: ContainerLayout, | ||
| 15699 | try Value.Tag.enum_field_index.create( | ||
| 15700 | sema.arena, | ||
| 15701 | @enumToInt(std.builtin.Type.ContainerLayout.Auto), | ||
| 15702 | ), | ||
| 15703 | |||
| 15704 | // tag_type: type, | 15698 | // tag_type: type, |
| 15705 | try Value.Tag.ty.create(sema.arena, int_tag_ty), | 15699 | try Value.Tag.ty.create(sema.arena, int_tag_ty), |
| 15706 | // fields: []const EnumField, | 15700 | // fields: []const EnumField, |
| ... | @@ -15770,7 +15764,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -15770,7 +15764,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 15770 | union_field_fields.* = .{ | 15764 | union_field_fields.* = .{ |
| 15771 | // name: []const u8, | 15765 | // name: []const u8, |
| 15772 | name_val, | 15766 | name_val, |
| 15773 | // field_type: type, | 15767 | // type: type, |
| 15774 | try Value.Tag.ty.create(fields_anon_decl.arena(), field.ty), | 15768 | try Value.Tag.ty.create(fields_anon_decl.arena(), field.ty), |
| 15775 | // alignment: comptime_int, | 15769 | // alignment: comptime_int, |
| 15776 | try Value.Tag.int_u64.create(fields_anon_decl.arena(), alignment), | 15770 | try Value.Tag.int_u64.create(fields_anon_decl.arena(), alignment), |
| ... | @@ -15883,7 +15877,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -15883,7 +15877,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 15883 | struct_field_fields.* = .{ | 15877 | struct_field_fields.* = .{ |
| 15884 | // name: []const u8, | 15878 | // name: []const u8, |
| 15885 | name_val, | 15879 | name_val, |
| 15886 | // field_type: type, | 15880 | // type: type, |
| 15887 | try Value.Tag.ty.create(fields_anon_decl.arena(), field_ty), | 15881 | try Value.Tag.ty.create(fields_anon_decl.arena(), field_ty), |
| 15888 | // default_value: ?*const anyopaque, | 15882 | // default_value: ?*const anyopaque, |
| 15889 | try default_val_ptr.copy(fields_anon_decl.arena()), | 15883 | try default_val_ptr.copy(fields_anon_decl.arena()), |
| ... | @@ -15928,7 +15922,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -15928,7 +15922,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 15928 | struct_field_fields.* = .{ | 15922 | struct_field_fields.* = .{ |
| 15929 | // name: []const u8, | 15923 | // name: []const u8, |
| 15930 | name_val, | 15924 | name_val, |
| 15931 | // field_type: type, | 15925 | // type: type, |
| 15932 | try Value.Tag.ty.create(fields_anon_decl.arena(), field.ty), | 15926 | try Value.Tag.ty.create(fields_anon_decl.arena(), field.ty), |
| 15933 | // default_value: ?*const anyopaque, | 15927 | // default_value: ?*const anyopaque, |
| 15934 | try default_val_ptr.copy(fields_anon_decl.arena()), | 15928 | try default_val_ptr.copy(fields_anon_decl.arena()), |
| ... | @@ -18315,22 +18309,14 @@ fn zirReify(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData, in | ... | @@ -18315,22 +18309,14 @@ fn zirReify(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData, in |
| 18315 | .Enum => { | 18309 | .Enum => { |
| 18316 | const struct_val: []const Value = union_val.val.castTag(.aggregate).?.data; | 18310 | const struct_val: []const Value = union_val.val.castTag(.aggregate).?.data; |
| 18317 | // TODO use reflection instead of magic numbers here | 18311 | // TODO use reflection instead of magic numbers here |
| 18318 | // layout: ContainerLayout, | ||
| 18319 | const layout_val = struct_val[0]; | ||
| 18320 | // tag_type: type, | 18312 | // tag_type: type, |
| 18321 | const tag_type_val = struct_val[1]; | 18313 | const tag_type_val = struct_val[0]; |
| 18322 | // fields: []const EnumField, | 18314 | // fields: []const EnumField, |
| 18323 | const fields_val = struct_val[2]; | 18315 | const fields_val = struct_val[1]; |
| 18324 | // decls: []const Declaration, | 18316 | // decls: []const Declaration, |
| 18325 | const decls_val = struct_val[3]; | 18317 | const decls_val = struct_val[2]; |
| 18326 | // is_exhaustive: bool, | 18318 | // is_exhaustive: bool, |
| 18327 | const is_exhaustive_val = struct_val[4]; | 18319 | const is_exhaustive_val = struct_val[3]; |
| 18328 | |||
| 18329 | // enum layout is always auto | ||
| 18330 | const layout = layout_val.toEnum(std.builtin.Type.ContainerLayout); | ||
| 18331 | if (layout != .Auto) { | ||
| 18332 | return sema.fail(block, src, "reified enums must have a layout .Auto", .{}); | ||
| 18333 | } | ||
| 18334 | 18320 | ||
| 18335 | // Decls | 18321 | // Decls |
| 18336 | if (decls_val.sliceLen(mod) > 0) { | 18322 | if (decls_val.sliceLen(mod) > 0) { |
| ... | @@ -18577,8 +18563,8 @@ fn zirReify(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData, in | ... | @@ -18577,8 +18563,8 @@ fn zirReify(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData, in |
| 18577 | // TODO use reflection instead of magic numbers here | 18563 | // TODO use reflection instead of magic numbers here |
| 18578 | // name: []const u8 | 18564 | // name: []const u8 |
| 18579 | const name_val = field_struct_val[0]; | 18565 | const name_val = field_struct_val[0]; |
| 18580 | // field_type: type, | 18566 | // type: type, |
| 18581 | const field_type_val = field_struct_val[1]; | 18567 | const type_val = field_struct_val[1]; |
| 18582 | // alignment: comptime_int, | 18568 | // alignment: comptime_int, |
| 18583 | const alignment_val = field_struct_val[2]; | 18569 | const alignment_val = field_struct_val[2]; |
| 18584 | 18570 | ||
| ... | @@ -18612,7 +18598,7 @@ fn zirReify(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData, in | ... | @@ -18612,7 +18598,7 @@ fn zirReify(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData, in |
| 18612 | } | 18598 | } |
| 18613 | 18599 | ||
| 18614 | var buffer: Value.ToTypeBuffer = undefined; | 18600 | var buffer: Value.ToTypeBuffer = undefined; |
| 18615 | const field_ty = try field_type_val.toType(&buffer).copy(new_decl_arena_allocator); | 18601 | const field_ty = try type_val.toType(&buffer).copy(new_decl_arena_allocator); |
| 18616 | gop.value_ptr.* = .{ | 18602 | gop.value_ptr.* = .{ |
| 18617 | .ty = field_ty, | 18603 | .ty = field_ty, |
| 18618 | .abi_align = @intCast(u32, (try alignment_val.getUnsignedIntAdvanced(target, sema)).?), | 18604 | .abi_align = @intCast(u32, (try alignment_val.getUnsignedIntAdvanced(target, sema)).?), |
| ... | @@ -18733,7 +18719,7 @@ fn zirReify(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData, in | ... | @@ -18733,7 +18719,7 @@ fn zirReify(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData, in |
| 18733 | const arg_is_generic = arg_val[0].toBool(); | 18719 | const arg_is_generic = arg_val[0].toBool(); |
| 18734 | // is_noalias: bool, | 18720 | // is_noalias: bool, |
| 18735 | const arg_is_noalias = arg_val[1].toBool(); | 18721 | const arg_is_noalias = arg_val[1].toBool(); |
| 18736 | // arg_type: ?type, | 18722 | // type: ?type, |
| 18737 | const param_type_opt_val = arg_val[2]; | 18723 | const param_type_opt_val = arg_val[2]; |
| 18738 | 18724 | ||
| 18739 | if (arg_is_generic) { | 18725 | if (arg_is_generic) { |
| ... | @@ -18831,9 +18817,9 @@ fn reifyStruct( | ... | @@ -18831,9 +18817,9 @@ fn reifyStruct( |
| 18831 | // TODO use reflection instead of magic numbers here | 18817 | // TODO use reflection instead of magic numbers here |
| 18832 | // name: []const u8 | 18818 | // name: []const u8 |
| 18833 | const name_val = field_struct_val[0]; | 18819 | const name_val = field_struct_val[0]; |
| 18834 | // field_type: type, | 18820 | // type: type, |
| 18835 | const field_type_val = field_struct_val[1]; | 18821 | const type_val = field_struct_val[1]; |
| 18836 | //default_value: ?*const anyopaque, | 18822 | // default_value: ?*const anyopaque, |
| 18837 | const default_value_val = field_struct_val[2]; | 18823 | const default_value_val = field_struct_val[2]; |
| 18838 | // is_comptime: bool, | 18824 | // is_comptime: bool, |
| 18839 | const is_comptime_val = field_struct_val[3]; | 18825 | const is_comptime_val = field_struct_val[3]; |
| ... | @@ -18896,7 +18882,7 @@ fn reifyStruct( | ... | @@ -18896,7 +18882,7 @@ fn reifyStruct( |
| 18896 | } | 18882 | } |
| 18897 | 18883 | ||
| 18898 | var buffer: Value.ToTypeBuffer = undefined; | 18884 | var buffer: Value.ToTypeBuffer = undefined; |
| 18899 | const field_ty = try field_type_val.toType(&buffer).copy(new_decl_arena_allocator); | 18885 | const field_ty = try type_val.toType(&buffer).copy(new_decl_arena_allocator); |
| 18900 | gop.value_ptr.* = .{ | 18886 | gop.value_ptr.* = .{ |
| 18901 | .ty = field_ty, | 18887 | .ty = field_ty, |
| 18902 | .abi_align = abi_align, | 18888 | .abi_align = abi_align, |
| ... | @@ -31572,7 +31558,7 @@ pub fn addExtraAssumeCapacity(sema: *Sema, extra: anytype) u32 { | ... | @@ -31572,7 +31558,7 @@ pub fn addExtraAssumeCapacity(sema: *Sema, extra: anytype) u32 { |
| 31572 | const fields = std.meta.fields(@TypeOf(extra)); | 31558 | const fields = std.meta.fields(@TypeOf(extra)); |
| 31573 | const result = @intCast(u32, sema.air_extra.items.len); | 31559 | const result = @intCast(u32, sema.air_extra.items.len); |
| 31574 | inline for (fields) |field| { | 31560 | inline for (fields) |field| { |
| 31575 | sema.air_extra.appendAssumeCapacity(switch (field.field_type) { | 31561 | sema.air_extra.appendAssumeCapacity(switch (field.type) { |
| 31576 | u32 => @field(extra, field.name), | 31562 | u32 => @field(extra, field.name), |
| 31577 | Air.Inst.Ref => @enumToInt(@field(extra, field.name)), | 31563 | Air.Inst.Ref => @enumToInt(@field(extra, field.name)), |
| 31578 | i32 => @bitCast(u32, @field(extra, field.name)), | 31564 | i32 => @bitCast(u32, @field(extra, field.name)), |
src/Zir.zig+1-1| ... | @@ -71,7 +71,7 @@ pub fn extraData(code: Zir, comptime T: type, index: usize) struct { data: T, en | ... | @@ -71,7 +71,7 @@ pub fn extraData(code: Zir, comptime T: type, index: usize) struct { data: T, en |
| 71 | var i: usize = index; | 71 | var i: usize = index; |
| 72 | var result: T = undefined; | 72 | var result: T = undefined; |
| 73 | inline for (fields) |field| { | 73 | inline for (fields) |field| { |
| 74 | @field(result, field.name) = switch (field.field_type) { | 74 | @field(result, field.name) = switch (field.type) { |
| 75 | u32 => code.extra[i], | 75 | u32 => code.extra[i], |
| 76 | Inst.Ref => @intToEnum(Inst.Ref, code.extra[i]), | 76 | Inst.Ref => @intToEnum(Inst.Ref, code.extra[i]), |
| 77 | i32 => @bitCast(i32, code.extra[i]), | 77 | i32 => @bitCast(i32, code.extra[i]), |
src/arch/aarch64/CodeGen.zig+1-1| ... | @@ -477,7 +477,7 @@ pub fn addExtraAssumeCapacity(self: *Self, extra: anytype) u32 { | ... | @@ -477,7 +477,7 @@ pub fn addExtraAssumeCapacity(self: *Self, extra: anytype) u32 { |
| 477 | const fields = std.meta.fields(@TypeOf(extra)); | 477 | const fields = std.meta.fields(@TypeOf(extra)); |
| 478 | const result = @intCast(u32, self.mir_extra.items.len); | 478 | const result = @intCast(u32, self.mir_extra.items.len); |
| 479 | inline for (fields) |field| { | 479 | inline for (fields) |field| { |
| 480 | self.mir_extra.appendAssumeCapacity(switch (field.field_type) { | 480 | self.mir_extra.appendAssumeCapacity(switch (field.type) { |
| 481 | u32 => @field(extra, field.name), | 481 | u32 => @field(extra, field.name), |
| 482 | i32 => @bitCast(u32, @field(extra, field.name)), | 482 | i32 => @bitCast(u32, @field(extra, field.name)), |
| 483 | else => @compileError("bad field type"), | 483 | else => @compileError("bad field type"), |
src/arch/aarch64/Mir.zig+1-1| ... | @@ -505,7 +505,7 @@ pub fn extraData(mir: Mir, comptime T: type, index: usize) struct { data: T, end | ... | @@ -505,7 +505,7 @@ pub fn extraData(mir: Mir, comptime T: type, index: usize) struct { data: T, end |
| 505 | var i: usize = index; | 505 | var i: usize = index; |
| 506 | var result: T = undefined; | 506 | var result: T = undefined; |
| 507 | inline for (fields) |field| { | 507 | inline for (fields) |field| { |
| 508 | @field(result, field.name) = switch (field.field_type) { | 508 | @field(result, field.name) = switch (field.type) { |
| 509 | u32 => mir.extra[i], | 509 | u32 => mir.extra[i], |
| 510 | i32 => @bitCast(i32, mir.extra[i]), | 510 | i32 => @bitCast(i32, mir.extra[i]), |
| 511 | else => @compileError("bad field type"), | 511 | else => @compileError("bad field type"), |
src/arch/arm/CodeGen.zig+1-1| ... | @@ -386,7 +386,7 @@ pub fn addExtraAssumeCapacity(self: *Self, extra: anytype) u32 { | ... | @@ -386,7 +386,7 @@ pub fn addExtraAssumeCapacity(self: *Self, extra: anytype) u32 { |
| 386 | const fields = std.meta.fields(@TypeOf(extra)); | 386 | const fields = std.meta.fields(@TypeOf(extra)); |
| 387 | const result = @intCast(u32, self.mir_extra.items.len); | 387 | const result = @intCast(u32, self.mir_extra.items.len); |
| 388 | inline for (fields) |field| { | 388 | inline for (fields) |field| { |
| 389 | self.mir_extra.appendAssumeCapacity(switch (field.field_type) { | 389 | self.mir_extra.appendAssumeCapacity(switch (field.type) { |
| 390 | u32 => @field(extra, field.name), | 390 | u32 => @field(extra, field.name), |
| 391 | i32 => @bitCast(u32, @field(extra, field.name)), | 391 | i32 => @bitCast(u32, @field(extra, field.name)), |
| 392 | else => @compileError("bad field type"), | 392 | else => @compileError("bad field type"), |
src/arch/arm/Mir.zig+1-1| ... | @@ -283,7 +283,7 @@ pub fn extraData(mir: Mir, comptime T: type, index: usize) struct { data: T, end | ... | @@ -283,7 +283,7 @@ pub fn extraData(mir: Mir, comptime T: type, index: usize) struct { data: T, end |
| 283 | var i: usize = index; | 283 | var i: usize = index; |
| 284 | var result: T = undefined; | 284 | var result: T = undefined; |
| 285 | inline for (fields) |field| { | 285 | inline for (fields) |field| { |
| 286 | @field(result, field.name) = switch (field.field_type) { | 286 | @field(result, field.name) = switch (field.type) { |
| 287 | u32 => mir.extra[i], | 287 | u32 => mir.extra[i], |
| 288 | i32 => @bitCast(i32, mir.extra[i]), | 288 | i32 => @bitCast(i32, mir.extra[i]), |
| 289 | else => @compileError("bad field type"), | 289 | else => @compileError("bad field type"), |
src/arch/riscv64/CodeGen.zig+1-1| ... | @@ -340,7 +340,7 @@ pub fn addExtraAssumeCapacity(self: *Self, extra: anytype) u32 { | ... | @@ -340,7 +340,7 @@ pub fn addExtraAssumeCapacity(self: *Self, extra: anytype) u32 { |
| 340 | const fields = std.meta.fields(@TypeOf(extra)); | 340 | const fields = std.meta.fields(@TypeOf(extra)); |
| 341 | const result = @intCast(u32, self.mir_extra.items.len); | 341 | const result = @intCast(u32, self.mir_extra.items.len); |
| 342 | inline for (fields) |field| { | 342 | inline for (fields) |field| { |
| 343 | self.mir_extra.appendAssumeCapacity(switch (field.field_type) { | 343 | self.mir_extra.appendAssumeCapacity(switch (field.type) { |
| 344 | u32 => @field(extra, field.name), | 344 | u32 => @field(extra, field.name), |
| 345 | i32 => @bitCast(u32, @field(extra, field.name)), | 345 | i32 => @bitCast(u32, @field(extra, field.name)), |
| 346 | else => @compileError("bad field type"), | 346 | else => @compileError("bad field type"), |
src/arch/riscv64/Mir.zig+1-1| ... | @@ -132,7 +132,7 @@ pub fn extraData(mir: Mir, comptime T: type, index: usize) struct { data: T, end | ... | @@ -132,7 +132,7 @@ pub fn extraData(mir: Mir, comptime T: type, index: usize) struct { data: T, end |
| 132 | var i: usize = index; | 132 | var i: usize = index; |
| 133 | var result: T = undefined; | 133 | var result: T = undefined; |
| 134 | inline for (fields) |field| { | 134 | inline for (fields) |field| { |
| 135 | @field(result, field.name) = switch (field.field_type) { | 135 | @field(result, field.name) = switch (field.type) { |
| 136 | u32 => mir.extra[i], | 136 | u32 => mir.extra[i], |
| 137 | i32 => @bitCast(i32, mir.extra[i]), | 137 | i32 => @bitCast(i32, mir.extra[i]), |
| 138 | else => @compileError("bad field type"), | 138 | else => @compileError("bad field type"), |
src/arch/sparc64/Mir.zig+1-1| ... | @@ -347,7 +347,7 @@ pub fn extraData(mir: Mir, comptime T: type, index: usize) struct { data: T, end | ... | @@ -347,7 +347,7 @@ pub fn extraData(mir: Mir, comptime T: type, index: usize) struct { data: T, end |
| 347 | var i: usize = index; | 347 | var i: usize = index; |
| 348 | var result: T = undefined; | 348 | var result: T = undefined; |
| 349 | inline for (fields) |field| { | 349 | inline for (fields) |field| { |
| 350 | @field(result, field.name) = switch (field.field_type) { | 350 | @field(result, field.name) = switch (field.type) { |
| 351 | u32 => mir.extra[i], | 351 | u32 => mir.extra[i], |
| 352 | i32 => @bitCast(i32, mir.extra[i]), | 352 | i32 => @bitCast(i32, mir.extra[i]), |
| 353 | else => @compileError("bad field type"), | 353 | else => @compileError("bad field type"), |
src/arch/wasm/CodeGen.zig+1-1| ... | @@ -960,7 +960,7 @@ fn addExtraAssumeCapacity(func: *CodeGen, extra: anytype) error{OutOfMemory}!u32 | ... | @@ -960,7 +960,7 @@ fn addExtraAssumeCapacity(func: *CodeGen, extra: anytype) error{OutOfMemory}!u32 |
| 960 | const fields = std.meta.fields(@TypeOf(extra)); | 960 | const fields = std.meta.fields(@TypeOf(extra)); |
| 961 | const result = @intCast(u32, func.mir_extra.items.len); | 961 | const result = @intCast(u32, func.mir_extra.items.len); |
| 962 | inline for (fields) |field| { | 962 | inline for (fields) |field| { |
| 963 | func.mir_extra.appendAssumeCapacity(switch (field.field_type) { | 963 | func.mir_extra.appendAssumeCapacity(switch (field.type) { |
| 964 | u32 => @field(extra, field.name), | 964 | u32 => @field(extra, field.name), |
| 965 | else => |field_type| @compileError("Unsupported field type " ++ @typeName(field_type)), | 965 | else => |field_type| @compileError("Unsupported field type " ++ @typeName(field_type)), |
| 966 | }); | 966 | }); |
src/arch/wasm/Mir.zig+1-1| ... | @@ -589,7 +589,7 @@ pub fn extraData(self: *const Mir, comptime T: type, index: usize) struct { data | ... | @@ -589,7 +589,7 @@ pub fn extraData(self: *const Mir, comptime T: type, index: usize) struct { data |
| 589 | var i: usize = index; | 589 | var i: usize = index; |
| 590 | var result: T = undefined; | 590 | var result: T = undefined; |
| 591 | inline for (fields) |field| { | 591 | inline for (fields) |field| { |
| 592 | @field(result, field.name) = switch (field.field_type) { | 592 | @field(result, field.name) = switch (field.type) { |
| 593 | u32 => self.extra[i], | 593 | u32 => self.extra[i], |
| 594 | else => |field_type| @compileError("Unsupported field type " ++ @typeName(field_type)), | 594 | else => |field_type| @compileError("Unsupported field type " ++ @typeName(field_type)), |
| 595 | }; | 595 | }; |
src/arch/x86_64/CodeGen.zig+1-1| ... | @@ -374,7 +374,7 @@ pub fn addExtraAssumeCapacity(self: *Self, extra: anytype) u32 { | ... | @@ -374,7 +374,7 @@ pub fn addExtraAssumeCapacity(self: *Self, extra: anytype) u32 { |
| 374 | const fields = std.meta.fields(@TypeOf(extra)); | 374 | const fields = std.meta.fields(@TypeOf(extra)); |
| 375 | const result = @intCast(u32, self.mir_extra.items.len); | 375 | const result = @intCast(u32, self.mir_extra.items.len); |
| 376 | inline for (fields) |field| { | 376 | inline for (fields) |field| { |
| 377 | self.mir_extra.appendAssumeCapacity(switch (field.field_type) { | 377 | self.mir_extra.appendAssumeCapacity(switch (field.type) { |
| 378 | u32 => @field(extra, field.name), | 378 | u32 => @field(extra, field.name), |
| 379 | i32 => @bitCast(u32, @field(extra, field.name)), | 379 | i32 => @bitCast(u32, @field(extra, field.name)), |
| 380 | else => @compileError("bad field type"), | 380 | else => @compileError("bad field type"), |
src/arch/x86_64/Mir.zig+1-1| ... | @@ -612,7 +612,7 @@ pub fn extraData(mir: Mir, comptime T: type, index: usize) struct { data: T, end | ... | @@ -612,7 +612,7 @@ pub fn extraData(mir: Mir, comptime T: type, index: usize) struct { data: T, end |
| 612 | var i: usize = index; | 612 | var i: usize = index; |
| 613 | var result: T = undefined; | 613 | var result: T = undefined; |
| 614 | inline for (fields) |field| { | 614 | inline for (fields) |field| { |
| 615 | @field(result, field.name) = switch (field.field_type) { | 615 | @field(result, field.name) = switch (field.type) { |
| 616 | u32 => mir.extra[i], | 616 | u32 => mir.extra[i], |
| 617 | i32 => @bitCast(i32, mir.extra[i]), | 617 | i32 => @bitCast(i32, mir.extra[i]), |
| 618 | else => @compileError("bad field type"), | 618 | else => @compileError("bad field type"), |
src/codegen/spirv/Section.zig+7-7| ... | @@ -116,7 +116,7 @@ fn writeOperands(section: *Section, comptime Operands: type, operands: Operands) | ... | @@ -116,7 +116,7 @@ fn writeOperands(section: *Section, comptime Operands: type, operands: Operands) |
| 116 | }; | 116 | }; |
| 117 | 117 | ||
| 118 | inline for (fields) |field| { | 118 | inline for (fields) |field| { |
| 119 | section.writeOperand(field.field_type, @field(operands, field.name)); | 119 | section.writeOperand(field.type, @field(operands, field.name)); |
| 120 | } | 120 | } |
| 121 | } | 121 | } |
| 122 | 122 | ||
| ... | @@ -196,7 +196,7 @@ fn writeContextDependentNumber(section: *Section, operand: spec.LiteralContextDe | ... | @@ -196,7 +196,7 @@ fn writeContextDependentNumber(section: *Section, operand: spec.LiteralContextDe |
| 196 | fn writeExtendedMask(section: *Section, comptime Operand: type, operand: Operand) void { | 196 | fn writeExtendedMask(section: *Section, comptime Operand: type, operand: Operand) void { |
| 197 | var mask: Word = 0; | 197 | var mask: Word = 0; |
| 198 | inline for (@typeInfo(Operand).Struct.fields) |field, bit| { | 198 | inline for (@typeInfo(Operand).Struct.fields) |field, bit| { |
| 199 | switch (@typeInfo(field.field_type)) { | 199 | switch (@typeInfo(field.type)) { |
| 200 | .Optional => if (@field(operand, field.name) != null) { | 200 | .Optional => if (@field(operand, field.name) != null) { |
| 201 | mask |= 1 << @intCast(u5, bit); | 201 | mask |= 1 << @intCast(u5, bit); |
| 202 | }, | 202 | }, |
| ... | @@ -214,7 +214,7 @@ fn writeExtendedMask(section: *Section, comptime Operand: type, operand: Operand | ... | @@ -214,7 +214,7 @@ fn writeExtendedMask(section: *Section, comptime Operand: type, operand: Operand |
| 214 | section.writeWord(mask); | 214 | section.writeWord(mask); |
| 215 | 215 | ||
| 216 | inline for (@typeInfo(Operand).Struct.fields) |field| { | 216 | inline for (@typeInfo(Operand).Struct.fields) |field| { |
| 217 | switch (@typeInfo(field.field_type)) { | 217 | switch (@typeInfo(field.type)) { |
| 218 | .Optional => |info| if (@field(operand, field.name)) |child| { | 218 | .Optional => |info| if (@field(operand, field.name)) |child| { |
| 219 | section.writeOperands(info.child, child); | 219 | section.writeOperands(info.child, child); |
| 220 | }, | 220 | }, |
| ... | @@ -230,7 +230,7 @@ fn writeExtendedUnion(section: *Section, comptime Operand: type, operand: Operan | ... | @@ -230,7 +230,7 @@ fn writeExtendedUnion(section: *Section, comptime Operand: type, operand: Operan |
| 230 | 230 | ||
| 231 | inline for (@typeInfo(Operand).Union.fields) |field| { | 231 | inline for (@typeInfo(Operand).Union.fields) |field| { |
| 232 | if (@field(Operand, field.name) == tag) { | 232 | if (@field(Operand, field.name) == tag) { |
| 233 | section.writeOperands(field.field_type, @field(operand, field.name)); | 233 | section.writeOperands(field.type, @field(operand, field.name)); |
| 234 | return; | 234 | return; |
| 235 | } | 235 | } |
| 236 | } | 236 | } |
| ... | @@ -250,7 +250,7 @@ fn operandsSize(comptime Operands: type, operands: Operands) usize { | ... | @@ -250,7 +250,7 @@ fn operandsSize(comptime Operands: type, operands: Operands) usize { |
| 250 | 250 | ||
| 251 | var total: usize = 0; | 251 | var total: usize = 0; |
| 252 | inline for (fields) |field| { | 252 | inline for (fields) |field| { |
| 253 | total += operandSize(field.field_type, @field(operands, field.name)); | 253 | total += operandSize(field.type, @field(operands, field.name)); |
| 254 | } | 254 | } |
| 255 | 255 | ||
| 256 | return total; | 256 | return total; |
| ... | @@ -304,7 +304,7 @@ fn extendedMaskSize(comptime Operand: type, operand: Operand) usize { | ... | @@ -304,7 +304,7 @@ fn extendedMaskSize(comptime Operand: type, operand: Operand) usize { |
| 304 | var total: usize = 0; | 304 | var total: usize = 0; |
| 305 | var any_set = false; | 305 | var any_set = false; |
| 306 | inline for (@typeInfo(Operand).Struct.fields) |field| { | 306 | inline for (@typeInfo(Operand).Struct.fields) |field| { |
| 307 | switch (@typeInfo(field.field_type)) { | 307 | switch (@typeInfo(field.type)) { |
| 308 | .Optional => |info| if (@field(operand, field.name)) |child| { | 308 | .Optional => |info| if (@field(operand, field.name)) |child| { |
| 309 | total += operandsSize(info.child, child); | 309 | total += operandsSize(info.child, child); |
| 310 | any_set = true; | 310 | any_set = true; |
| ... | @@ -326,7 +326,7 @@ fn extendedUnionSize(comptime Operand: type, operand: Operand) usize { | ... | @@ -326,7 +326,7 @@ fn extendedUnionSize(comptime Operand: type, operand: Operand) usize { |
| 326 | inline for (@typeInfo(Operand).Union.fields) |field| { | 326 | inline for (@typeInfo(Operand).Union.fields) |field| { |
| 327 | if (@field(Operand, field.name) == tag) { | 327 | if (@field(Operand, field.name) == tag) { |
| 328 | // Add one for the tag itself. | 328 | // Add one for the tag itself. |
| 329 | return 1 + operandsSize(field.field_type, @field(operand, field.name)); | 329 | return 1 + operandsSize(field.type, @field(operand, field.name)); |
| 330 | } | 330 | } |
| 331 | } | 331 | } |
| 332 | unreachable; | 332 | unreachable; |
src/link/tapi/yaml.zig+5-5| ... | @@ -339,7 +339,7 @@ pub const Yaml = struct { | ... | @@ -339,7 +339,7 @@ pub const Yaml = struct { |
| 339 | 339 | ||
| 340 | if (union_info.tag_type) |_| { | 340 | if (union_info.tag_type) |_| { |
| 341 | inline for (union_info.fields) |field| { | 341 | inline for (union_info.fields) |field| { |
| 342 | if (self.parseValue(field.field_type, value)) |u_value| { | 342 | if (self.parseValue(field.type, value)) |u_value| { |
| 343 | return @unionInit(T, field.name, u_value); | 343 | return @unionInit(T, field.name, u_value); |
| 344 | } else |err| { | 344 | } else |err| { |
| 345 | if (@as(@TypeOf(err) || error{TypeMismatch}, err) != error.TypeMismatch) return err; | 345 | if (@as(@TypeOf(err) || error{TypeMismatch}, err) != error.TypeMismatch) return err; |
| ... | @@ -366,16 +366,16 @@ pub const Yaml = struct { | ... | @@ -366,16 +366,16 @@ pub const Yaml = struct { |
| 366 | break :blk map.get(field_name); | 366 | break :blk map.get(field_name); |
| 367 | }; | 367 | }; |
| 368 | 368 | ||
| 369 | if (@typeInfo(field.field_type) == .Optional) { | 369 | if (@typeInfo(field.type) == .Optional) { |
| 370 | @field(parsed, field.name) = try self.parseOptional(field.field_type, value); | 370 | @field(parsed, field.name) = try self.parseOptional(field.type, value); |
| 371 | continue; | 371 | continue; |
| 372 | } | 372 | } |
| 373 | 373 | ||
| 374 | const unwrapped = value orelse { | 374 | const unwrapped = value orelse { |
| 375 | log.debug("missing struct field: {s}: {s}", .{ field.name, @typeName(field.field_type) }); | 375 | log.debug("missing struct field: {s}: {s}", .{ field.name, @typeName(field.type) }); |
| 376 | return error.StructFieldMissing; | 376 | return error.StructFieldMissing; |
| 377 | }; | 377 | }; |
| 378 | @field(parsed, field.name) = try self.parseValue(field.field_type, unwrapped); | 378 | @field(parsed, field.name) = try self.parseValue(field.type, unwrapped); |
| 379 | } | 379 | } |
| 380 | 380 | ||
| 381 | return parsed; | 381 | return parsed; |
src/print_zir.zig+4-4| ... | @@ -1312,7 +1312,7 @@ const Writer = struct { | ... | @@ -1312,7 +1312,7 @@ const Writer = struct { |
| 1312 | type_len: u32 = 0, | 1312 | type_len: u32 = 0, |
| 1313 | align_len: u32 = 0, | 1313 | align_len: u32 = 0, |
| 1314 | init_len: u32 = 0, | 1314 | init_len: u32 = 0, |
| 1315 | field_type: Zir.Inst.Ref = .none, | 1315 | type: Zir.Inst.Ref = .none, |
| 1316 | name: u32, | 1316 | name: u32, |
| 1317 | is_comptime: bool, | 1317 | is_comptime: bool, |
| 1318 | }; | 1318 | }; |
| ... | @@ -1353,7 +1353,7 @@ const Writer = struct { | ... | @@ -1353,7 +1353,7 @@ const Writer = struct { |
| 1353 | if (has_type_body) { | 1353 | if (has_type_body) { |
| 1354 | fields[field_i].type_len = self.code.extra[extra_index]; | 1354 | fields[field_i].type_len = self.code.extra[extra_index]; |
| 1355 | } else { | 1355 | } else { |
| 1356 | fields[field_i].field_type = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]); | 1356 | fields[field_i].type = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]); |
| 1357 | } | 1357 | } |
| 1358 | extra_index += 1; | 1358 | extra_index += 1; |
| 1359 | 1359 | ||
| ... | @@ -1384,8 +1384,8 @@ const Writer = struct { | ... | @@ -1384,8 +1384,8 @@ const Writer = struct { |
| 1384 | } else { | 1384 | } else { |
| 1385 | try stream.print("@\"{d}\": ", .{i}); | 1385 | try stream.print("@\"{d}\": ", .{i}); |
| 1386 | } | 1386 | } |
| 1387 | if (field.field_type != .none) { | 1387 | if (field.type != .none) { |
| 1388 | try self.writeInstRef(stream, field.field_type); | 1388 | try self.writeInstRef(stream, field.type); |
| 1389 | } | 1389 | } |
| 1390 | 1390 | ||
| 1391 | if (field.type_len > 0) { | 1391 | if (field.type_len > 0) { |
src/translate_c/ast.zig+2-2| ... | @@ -392,7 +392,7 @@ pub const Node = extern union { | ... | @@ -392,7 +392,7 @@ pub const Node = extern union { |
| 392 | } | 392 | } |
| 393 | 393 | ||
| 394 | pub fn Data(comptime t: Tag) type { | 394 | pub fn Data(comptime t: Tag) type { |
| 395 | return std.meta.fieldInfo(t.Type(), .data).field_type; | 395 | return std.meta.fieldInfo(t.Type(), .data).type; |
| 396 | } | 396 | } |
| 397 | }; | 397 | }; |
| 398 | 398 | ||
| ... | @@ -845,7 +845,7 @@ const Context = struct { | ... | @@ -845,7 +845,7 @@ const Context = struct { |
| 845 | try c.extra_data.ensureUnusedCapacity(c.gpa, fields.len); | 845 | try c.extra_data.ensureUnusedCapacity(c.gpa, fields.len); |
| 846 | const result = @intCast(u32, c.extra_data.items.len); | 846 | const result = @intCast(u32, c.extra_data.items.len); |
| 847 | inline for (fields) |field| { | 847 | inline for (fields) |field| { |
| 848 | comptime std.debug.assert(field.field_type == NodeIndex); | 848 | comptime std.debug.assert(field.type == NodeIndex); |
| 849 | c.extra_data.appendAssumeCapacity(@field(extra, field.name)); | 849 | c.extra_data.appendAssumeCapacity(@field(extra, field.name)); |
| 850 | } | 850 | } |
| 851 | return result; | 851 | return result; |
src/type.zig+1-1| ... | @@ -6216,7 +6216,7 @@ pub const Type = extern union { | ... | @@ -6216,7 +6216,7 @@ pub const Type = extern union { |
| 6216 | } | 6216 | } |
| 6217 | 6217 | ||
| 6218 | pub fn Data(comptime t: Tag) type { | 6218 | pub fn Data(comptime t: Tag) type { |
| 6219 | return std.meta.fieldInfo(t.Type(), .data).field_type; | 6219 | return std.meta.fieldInfo(t.Type(), .data).type; |
| 6220 | } | 6220 | } |
| 6221 | }; | 6221 | }; |
| 6222 | 6222 |
src/value.zig+1-1| ... | @@ -338,7 +338,7 @@ pub const Value = extern union { | ... | @@ -338,7 +338,7 @@ pub const Value = extern union { |
| 338 | } | 338 | } |
| 339 | 339 | ||
| 340 | pub fn Data(comptime t: Tag) type { | 340 | pub fn Data(comptime t: Tag) type { |
| 341 | return std.meta.fieldInfo(t.Type(), .data).field_type; | 341 | return std.meta.fieldInfo(t.Type(), .data).type; |
| 342 | } | 342 | } |
| 343 | }; | 343 | }; |
| 344 | 344 |
stage1/zig1.wasm| Binary files a/stage1/zig1.wasm and b/stage1/zig1.wasm differ | |||
test/behavior/bitcast.zig+1-1| ... | @@ -358,7 +358,7 @@ test "comptime @bitCast packed struct to int and back" { | ... | @@ -358,7 +358,7 @@ test "comptime @bitCast packed struct to int and back" { |
| 358 | const rt_cast = @bitCast(S, i); | 358 | const rt_cast = @bitCast(S, i); |
| 359 | const ct_cast = comptime @bitCast(S, @as(Int, 0)); | 359 | const ct_cast = comptime @bitCast(S, @as(Int, 0)); |
| 360 | inline for (@typeInfo(S).Struct.fields) |field| { | 360 | inline for (@typeInfo(S).Struct.fields) |field| { |
| 361 | if (@typeInfo(field.field_type) == .Vector) | 361 | if (@typeInfo(field.type) == .Vector) |
| 362 | continue; //TODO: https://github.com/ziglang/zig/issues/13201 | 362 | continue; //TODO: https://github.com/ziglang/zig/issues/13201 |
| 363 | 363 | ||
| 364 | try expectEqual(@field(rt_cast, field.name), @field(ct_cast, field.name)); | 364 | try expectEqual(@field(rt_cast, field.name), @field(ct_cast, field.name)); |
test/behavior/bugs/12786.zig+1-1| ... | @@ -8,7 +8,7 @@ fn NamespacedGlobals(comptime modules: anytype) type { | ... | @@ -8,7 +8,7 @@ fn NamespacedGlobals(comptime modules: anytype) type { |
| 8 | .fields = &.{ | 8 | .fields = &.{ |
| 9 | .{ | 9 | .{ |
| 10 | .name = "globals", | 10 | .name = "globals", |
| 11 | .field_type = modules.mach.globals, | 11 | .type = modules.mach.globals, |
| 12 | .default_value = null, | 12 | .default_value = null, |
| 13 | .is_comptime = false, | 13 | .is_comptime = false, |
| 14 | .alignment = @alignOf(modules.mach.globals), | 14 | .alignment = @alignOf(modules.mach.globals), |
test/behavior/bugs/12794.zig+1-1| ... | @@ -7,7 +7,7 @@ fn NamespacedComponents(comptime modules: anytype) type { | ... | @@ -7,7 +7,7 @@ fn NamespacedComponents(comptime modules: anytype) type { |
| 7 | .is_tuple = false, | 7 | .is_tuple = false, |
| 8 | .fields = &.{.{ | 8 | .fields = &.{.{ |
| 9 | .name = "components", | 9 | .name = "components", |
| 10 | .field_type = @TypeOf(modules.components), | 10 | .type = @TypeOf(modules.components), |
| 11 | .default_value = null, | 11 | .default_value = null, |
| 12 | .is_comptime = false, | 12 | .is_comptime = false, |
| 13 | .alignment = @alignOf(@TypeOf(modules.components)), | 13 | .alignment = @alignOf(@TypeOf(modules.components)), |
test/behavior/bugs/12885.zig+3-3| ... | @@ -15,8 +15,8 @@ test "ErrorSet comptime_field_ptr" { | ... | @@ -15,8 +15,8 @@ test "ErrorSet comptime_field_ptr" { |
| 15 | } | 15 | } |
| 16 | 16 | ||
| 17 | const fn_info = .{ | 17 | const fn_info = .{ |
| 18 | .args = [_]builtin.Type.Fn.Param{ | 18 | .params = [_]builtin.Type.Fn.Param{ |
| 19 | .{ .is_generic = false, .is_noalias = false, .arg_type = u8 }, | 19 | .{ .is_generic = false, .is_noalias = false, .type = u8 }, |
| 20 | }, | 20 | }, |
| 21 | }; | 21 | }; |
| 22 | const Bar = @Type(.{ | 22 | const Bar = @Type(.{ |
| ... | @@ -26,7 +26,7 @@ const Bar = @Type(.{ | ... | @@ -26,7 +26,7 @@ const Bar = @Type(.{ |
| 26 | .is_generic = false, | 26 | .is_generic = false, |
| 27 | .is_var_args = false, | 27 | .is_var_args = false, |
| 28 | .return_type = void, | 28 | .return_type = void, |
| 29 | .args = &fn_info.args, | 29 | .params = &fn_info.params, |
| 30 | }, | 30 | }, |
| 31 | }); | 31 | }); |
| 32 | test "fn comptime_field_ptr" { | 32 | test "fn comptime_field_ptr" { |
test/behavior/bugs/13435.zig+1-1| ... | @@ -8,7 +8,7 @@ fn CreateUnion(comptime T: type) type { | ... | @@ -8,7 +8,7 @@ fn CreateUnion(comptime T: type) type { |
| 8 | .fields = &[_]std.builtin.Type.UnionField{ | 8 | .fields = &[_]std.builtin.Type.UnionField{ |
| 9 | .{ | 9 | .{ |
| 10 | .name = "field", | 10 | .name = "field", |
| 11 | .field_type = T, | 11 | .type = T, |
| 12 | .alignment = @alignOf(T), | 12 | .alignment = @alignOf(T), |
| 13 | }, | 13 | }, |
| 14 | }, | 14 | }, |
test/behavior/bugs/6456.zig+1-1| ... | @@ -23,7 +23,7 @@ test "issue 6456" { | ... | @@ -23,7 +23,7 @@ test "issue 6456" { |
| 23 | fields = fields ++ &[_]StructField{StructField{ | 23 | fields = fields ++ &[_]StructField{StructField{ |
| 24 | .alignment = 0, | 24 | .alignment = 0, |
| 25 | .name = name, | 25 | .name = name, |
| 26 | .field_type = usize, | 26 | .type = usize, |
| 27 | .default_value = &@as(?usize, null), | 27 | .default_value = &@as(?usize, null), |
| 28 | .is_comptime = false, | 28 | .is_comptime = false, |
| 29 | }}; | 29 | }}; |
test/behavior/generics.zig-1| ... | @@ -273,7 +273,6 @@ test "generic function instantiation turns into comptime call" { | ... | @@ -273,7 +273,6 @@ test "generic function instantiation turns into comptime call" { |
| 273 | var enumFields: [1]std.builtin.Type.EnumField = .{.{ .name = "A", .value = 0 }}; | 273 | var enumFields: [1]std.builtin.Type.EnumField = .{.{ .name = "A", .value = 0 }}; |
| 274 | return @Type(.{ | 274 | return @Type(.{ |
| 275 | .Enum = .{ | 275 | .Enum = .{ |
| 276 | .layout = .Auto, | ||
| 277 | .tag_type = u0, | 276 | .tag_type = u0, |
| 278 | .fields = &enumFields, | 277 | .fields = &enumFields, |
| 279 | .decls = &.{}, | 278 | .decls = &.{}, |
test/behavior/reflection.zig+4-4| ... | @@ -9,10 +9,10 @@ test "reflection: function return type, var args, and param types" { | ... | @@ -9,10 +9,10 @@ test "reflection: function return type, var args, and param types" { |
| 9 | const info = @typeInfo(@TypeOf(dummy)).Fn; | 9 | const info = @typeInfo(@TypeOf(dummy)).Fn; |
| 10 | try expect(info.return_type.? == i32); | 10 | try expect(info.return_type.? == i32); |
| 11 | try expect(!info.is_var_args); | 11 | try expect(!info.is_var_args); |
| 12 | try expect(info.args.len == 3); | 12 | try expect(info.params.len == 3); |
| 13 | try expect(info.args[0].arg_type.? == bool); | 13 | try expect(info.params[0].type.? == bool); |
| 14 | try expect(info.args[1].arg_type.? == i32); | 14 | try expect(info.params[1].type.? == i32); |
| 15 | try expect(info.args[2].arg_type.? == f32); | 15 | try expect(info.params[2].type.? == f32); |
| 16 | } | 16 | } |
| 17 | } | 17 | } |
| 18 | 18 |
test/behavior/tuple.zig+3-3| ... | @@ -136,14 +136,14 @@ test "array-like initializer for tuple types" { | ... | @@ -136,14 +136,14 @@ test "array-like initializer for tuple types" { |
| 136 | .fields = &.{ | 136 | .fields = &.{ |
| 137 | .{ | 137 | .{ |
| 138 | .name = "0", | 138 | .name = "0", |
| 139 | .field_type = i32, | 139 | .type = i32, |
| 140 | .default_value = null, | 140 | .default_value = null, |
| 141 | .is_comptime = false, | 141 | .is_comptime = false, |
| 142 | .alignment = @alignOf(i32), | 142 | .alignment = @alignOf(i32), |
| 143 | }, | 143 | }, |
| 144 | .{ | 144 | .{ |
| 145 | .name = "1", | 145 | .name = "1", |
| 146 | .field_type = u8, | 146 | .type = u8, |
| 147 | .default_value = null, | 147 | .default_value = null, |
| 148 | .is_comptime = false, | 148 | .is_comptime = false, |
| 149 | .alignment = @alignOf(i32), | 149 | .alignment = @alignOf(i32), |
| ... | @@ -314,7 +314,7 @@ test "zero sized struct in tuple handled correctly" { | ... | @@ -314,7 +314,7 @@ test "zero sized struct in tuple handled correctly" { |
| 314 | .decls = &.{}, | 314 | .decls = &.{}, |
| 315 | .fields = &.{.{ | 315 | .fields = &.{.{ |
| 316 | .name = "0", | 316 | .name = "0", |
| 317 | .field_type = struct {}, | 317 | .type = struct {}, |
| 318 | .default_value = null, | 318 | .default_value = null, |
| 319 | .is_comptime = false, | 319 | .is_comptime = false, |
| 320 | .alignment = 0, | 320 | .alignment = 0, |
test/behavior/tuple_declarations.zig+5-5| ... | @@ -20,13 +20,13 @@ test "tuple declaration type info" { | ... | @@ -20,13 +20,13 @@ test "tuple declaration type info" { |
| 20 | try expect(info.is_tuple); | 20 | try expect(info.is_tuple); |
| 21 | 21 | ||
| 22 | try expectEqualStrings(info.fields[0].name, "0"); | 22 | try expectEqualStrings(info.fields[0].name, "0"); |
| 23 | try expect(info.fields[0].field_type == u32); | 23 | try expect(info.fields[0].type == u32); |
| 24 | try expect(@ptrCast(*const u32, @alignCast(@alignOf(u32), info.fields[0].default_value)).* == 1); | 24 | try expect(@ptrCast(*const u32, @alignCast(@alignOf(u32), info.fields[0].default_value)).* == 1); |
| 25 | try expect(info.fields[0].is_comptime); | 25 | try expect(info.fields[0].is_comptime); |
| 26 | try expect(info.fields[0].alignment == 2); | 26 | try expect(info.fields[0].alignment == 2); |
| 27 | 27 | ||
| 28 | try expectEqualStrings(info.fields[1].name, "1"); | 28 | try expectEqualStrings(info.fields[1].name, "1"); |
| 29 | try expect(info.fields[1].field_type == []const u8); | 29 | try expect(info.fields[1].type == []const u8); |
| 30 | try expect(info.fields[1].default_value == null); | 30 | try expect(info.fields[1].default_value == null); |
| 31 | try expect(!info.fields[1].is_comptime); | 31 | try expect(!info.fields[1].is_comptime); |
| 32 | try expect(info.fields[1].alignment == @alignOf([]const u8)); | 32 | try expect(info.fields[1].alignment == @alignOf([]const u8)); |
| ... | @@ -44,13 +44,13 @@ test "tuple declaration type info" { | ... | @@ -44,13 +44,13 @@ test "tuple declaration type info" { |
| 44 | try expect(info.is_tuple); | 44 | try expect(info.is_tuple); |
| 45 | 45 | ||
| 46 | try expectEqualStrings(info.fields[0].name, "0"); | 46 | try expectEqualStrings(info.fields[0].name, "0"); |
| 47 | try expect(info.fields[0].field_type == u1); | 47 | try expect(info.fields[0].type == u1); |
| 48 | 48 | ||
| 49 | try expectEqualStrings(info.fields[1].name, "1"); | 49 | try expectEqualStrings(info.fields[1].name, "1"); |
| 50 | try expect(info.fields[1].field_type == u30); | 50 | try expect(info.fields[1].type == u30); |
| 51 | 51 | ||
| 52 | try expectEqualStrings(info.fields[2].name, "2"); | 52 | try expectEqualStrings(info.fields[2].name, "2"); |
| 53 | try expect(info.fields[2].field_type == u1); | 53 | try expect(info.fields[2].type == u1); |
| 54 | } | 54 | } |
| 55 | } | 55 | } |
| 56 | 56 |
test/behavior/type.zig+22-26| ... | @@ -268,10 +268,10 @@ test "Type.Struct" { | ... | @@ -268,10 +268,10 @@ test "Type.Struct" { |
| 268 | const infoA = @typeInfo(A).Struct; | 268 | const infoA = @typeInfo(A).Struct; |
| 269 | try testing.expectEqual(Type.ContainerLayout.Auto, infoA.layout); | 269 | try testing.expectEqual(Type.ContainerLayout.Auto, infoA.layout); |
| 270 | try testing.expectEqualSlices(u8, "x", infoA.fields[0].name); | 270 | try testing.expectEqualSlices(u8, "x", infoA.fields[0].name); |
| 271 | try testing.expectEqual(u8, infoA.fields[0].field_type); | 271 | try testing.expectEqual(u8, infoA.fields[0].type); |
| 272 | try testing.expectEqual(@as(?*const anyopaque, null), infoA.fields[0].default_value); | 272 | try testing.expectEqual(@as(?*const anyopaque, null), infoA.fields[0].default_value); |
| 273 | try testing.expectEqualSlices(u8, "y", infoA.fields[1].name); | 273 | try testing.expectEqualSlices(u8, "y", infoA.fields[1].name); |
| 274 | try testing.expectEqual(u32, infoA.fields[1].field_type); | 274 | try testing.expectEqual(u32, infoA.fields[1].type); |
| 275 | try testing.expectEqual(@as(?*const anyopaque, null), infoA.fields[1].default_value); | 275 | try testing.expectEqual(@as(?*const anyopaque, null), infoA.fields[1].default_value); |
| 276 | try testing.expectEqualSlices(Type.Declaration, &.{}, infoA.decls); | 276 | try testing.expectEqualSlices(Type.Declaration, &.{}, infoA.decls); |
| 277 | try testing.expectEqual(@as(bool, false), infoA.is_tuple); | 277 | try testing.expectEqual(@as(bool, false), infoA.is_tuple); |
| ... | @@ -286,10 +286,10 @@ test "Type.Struct" { | ... | @@ -286,10 +286,10 @@ test "Type.Struct" { |
| 286 | const infoB = @typeInfo(B).Struct; | 286 | const infoB = @typeInfo(B).Struct; |
| 287 | try testing.expectEqual(Type.ContainerLayout.Extern, infoB.layout); | 287 | try testing.expectEqual(Type.ContainerLayout.Extern, infoB.layout); |
| 288 | try testing.expectEqualSlices(u8, "x", infoB.fields[0].name); | 288 | try testing.expectEqualSlices(u8, "x", infoB.fields[0].name); |
| 289 | try testing.expectEqual(u8, infoB.fields[0].field_type); | 289 | try testing.expectEqual(u8, infoB.fields[0].type); |
| 290 | try testing.expectEqual(@as(?*const anyopaque, null), infoB.fields[0].default_value); | 290 | try testing.expectEqual(@as(?*const anyopaque, null), infoB.fields[0].default_value); |
| 291 | try testing.expectEqualSlices(u8, "y", infoB.fields[1].name); | 291 | try testing.expectEqualSlices(u8, "y", infoB.fields[1].name); |
| 292 | try testing.expectEqual(u32, infoB.fields[1].field_type); | 292 | try testing.expectEqual(u32, infoB.fields[1].type); |
| 293 | try testing.expectEqual(@as(u32, 5), @ptrCast(*align(1) const u32, infoB.fields[1].default_value.?).*); | 293 | try testing.expectEqual(@as(u32, 5), @ptrCast(*align(1) const u32, infoB.fields[1].default_value.?).*); |
| 294 | try testing.expectEqual(@as(usize, 0), infoB.decls.len); | 294 | try testing.expectEqual(@as(usize, 0), infoB.decls.len); |
| 295 | try testing.expectEqual(@as(bool, false), infoB.is_tuple); | 295 | try testing.expectEqual(@as(bool, false), infoB.is_tuple); |
| ... | @@ -298,10 +298,10 @@ test "Type.Struct" { | ... | @@ -298,10 +298,10 @@ test "Type.Struct" { |
| 298 | const infoC = @typeInfo(C).Struct; | 298 | const infoC = @typeInfo(C).Struct; |
| 299 | try testing.expectEqual(Type.ContainerLayout.Packed, infoC.layout); | 299 | try testing.expectEqual(Type.ContainerLayout.Packed, infoC.layout); |
| 300 | try testing.expectEqualSlices(u8, "x", infoC.fields[0].name); | 300 | try testing.expectEqualSlices(u8, "x", infoC.fields[0].name); |
| 301 | try testing.expectEqual(u8, infoC.fields[0].field_type); | 301 | try testing.expectEqual(u8, infoC.fields[0].type); |
| 302 | try testing.expectEqual(@as(u8, 3), @ptrCast(*const u8, infoC.fields[0].default_value.?).*); | 302 | try testing.expectEqual(@as(u8, 3), @ptrCast(*const u8, infoC.fields[0].default_value.?).*); |
| 303 | try testing.expectEqualSlices(u8, "y", infoC.fields[1].name); | 303 | try testing.expectEqualSlices(u8, "y", infoC.fields[1].name); |
| 304 | try testing.expectEqual(u32, infoC.fields[1].field_type); | 304 | try testing.expectEqual(u32, infoC.fields[1].type); |
| 305 | try testing.expectEqual(@as(u32, 5), @ptrCast(*align(1) const u32, infoC.fields[1].default_value.?).*); | 305 | try testing.expectEqual(@as(u32, 5), @ptrCast(*align(1) const u32, infoC.fields[1].default_value.?).*); |
| 306 | try testing.expectEqual(@as(usize, 0), infoC.decls.len); | 306 | try testing.expectEqual(@as(usize, 0), infoC.decls.len); |
| 307 | try testing.expectEqual(@as(bool, false), infoC.is_tuple); | 307 | try testing.expectEqual(@as(bool, false), infoC.is_tuple); |
| ... | @@ -311,10 +311,10 @@ test "Type.Struct" { | ... | @@ -311,10 +311,10 @@ test "Type.Struct" { |
| 311 | const infoD = @typeInfo(D).Struct; | 311 | const infoD = @typeInfo(D).Struct; |
| 312 | try testing.expectEqual(Type.ContainerLayout.Auto, infoD.layout); | 312 | try testing.expectEqual(Type.ContainerLayout.Auto, infoD.layout); |
| 313 | try testing.expectEqualSlices(u8, "x", infoD.fields[0].name); | 313 | try testing.expectEqualSlices(u8, "x", infoD.fields[0].name); |
| 314 | try testing.expectEqual(comptime_int, infoD.fields[0].field_type); | 314 | try testing.expectEqual(comptime_int, infoD.fields[0].type); |
| 315 | try testing.expectEqual(@as(comptime_int, 3), @ptrCast(*const comptime_int, infoD.fields[0].default_value.?).*); | 315 | try testing.expectEqual(@as(comptime_int, 3), @ptrCast(*const comptime_int, infoD.fields[0].default_value.?).*); |
| 316 | try testing.expectEqualSlices(u8, "y", infoD.fields[1].name); | 316 | try testing.expectEqualSlices(u8, "y", infoD.fields[1].name); |
| 317 | try testing.expectEqual(comptime_int, infoD.fields[1].field_type); | 317 | try testing.expectEqual(comptime_int, infoD.fields[1].type); |
| 318 | try testing.expectEqual(@as(comptime_int, 5), @ptrCast(*const comptime_int, infoD.fields[1].default_value.?).*); | 318 | try testing.expectEqual(@as(comptime_int, 5), @ptrCast(*const comptime_int, infoD.fields[1].default_value.?).*); |
| 319 | try testing.expectEqual(@as(usize, 0), infoD.decls.len); | 319 | try testing.expectEqual(@as(usize, 0), infoD.decls.len); |
| 320 | try testing.expectEqual(@as(bool, false), infoD.is_tuple); | 320 | try testing.expectEqual(@as(bool, false), infoD.is_tuple); |
| ... | @@ -324,10 +324,10 @@ test "Type.Struct" { | ... | @@ -324,10 +324,10 @@ test "Type.Struct" { |
| 324 | const infoE = @typeInfo(E).Struct; | 324 | const infoE = @typeInfo(E).Struct; |
| 325 | try testing.expectEqual(Type.ContainerLayout.Auto, infoE.layout); | 325 | try testing.expectEqual(Type.ContainerLayout.Auto, infoE.layout); |
| 326 | try testing.expectEqualSlices(u8, "0", infoE.fields[0].name); | 326 | try testing.expectEqualSlices(u8, "0", infoE.fields[0].name); |
| 327 | try testing.expectEqual(comptime_int, infoE.fields[0].field_type); | 327 | try testing.expectEqual(comptime_int, infoE.fields[0].type); |
| 328 | try testing.expectEqual(@as(comptime_int, 1), @ptrCast(*const comptime_int, infoE.fields[0].default_value.?).*); | 328 | try testing.expectEqual(@as(comptime_int, 1), @ptrCast(*const comptime_int, infoE.fields[0].default_value.?).*); |
| 329 | try testing.expectEqualSlices(u8, "1", infoE.fields[1].name); | 329 | try testing.expectEqualSlices(u8, "1", infoE.fields[1].name); |
| 330 | try testing.expectEqual(comptime_int, infoE.fields[1].field_type); | 330 | try testing.expectEqual(comptime_int, infoE.fields[1].type); |
| 331 | try testing.expectEqual(@as(comptime_int, 2), @ptrCast(*const comptime_int, infoE.fields[1].default_value.?).*); | 331 | try testing.expectEqual(@as(comptime_int, 2), @ptrCast(*const comptime_int, infoE.fields[1].default_value.?).*); |
| 332 | try testing.expectEqual(@as(usize, 0), infoE.decls.len); | 332 | try testing.expectEqual(@as(usize, 0), infoE.decls.len); |
| 333 | try testing.expectEqual(@as(bool, true), infoE.is_tuple); | 333 | try testing.expectEqual(@as(bool, true), infoE.is_tuple); |
| ... | @@ -354,7 +354,6 @@ test "Type.Enum" { | ... | @@ -354,7 +354,6 @@ test "Type.Enum" { |
| 354 | 354 | ||
| 355 | const Foo = @Type(.{ | 355 | const Foo = @Type(.{ |
| 356 | .Enum = .{ | 356 | .Enum = .{ |
| 357 | .layout = .Auto, | ||
| 358 | .tag_type = u8, | 357 | .tag_type = u8, |
| 359 | .fields = &.{ | 358 | .fields = &.{ |
| 360 | .{ .name = "a", .value = 1 }, | 359 | .{ .name = "a", .value = 1 }, |
| ... | @@ -369,7 +368,6 @@ test "Type.Enum" { | ... | @@ -369,7 +368,6 @@ test "Type.Enum" { |
| 369 | try testing.expectEqual(@as(u8, 5), @enumToInt(Foo.b)); | 368 | try testing.expectEqual(@as(u8, 5), @enumToInt(Foo.b)); |
| 370 | const Bar = @Type(.{ | 369 | const Bar = @Type(.{ |
| 371 | .Enum = .{ | 370 | .Enum = .{ |
| 372 | .layout = .Auto, | ||
| 373 | .tag_type = u32, | 371 | .tag_type = u32, |
| 374 | .fields = &.{ | 372 | .fields = &.{ |
| 375 | .{ .name = "a", .value = 1 }, | 373 | .{ .name = "a", .value = 1 }, |
| ... | @@ -396,8 +394,8 @@ test "Type.Union" { | ... | @@ -396,8 +394,8 @@ test "Type.Union" { |
| 396 | .layout = .Extern, | 394 | .layout = .Extern, |
| 397 | .tag_type = null, | 395 | .tag_type = null, |
| 398 | .fields = &.{ | 396 | .fields = &.{ |
| 399 | .{ .name = "int", .field_type = i32, .alignment = @alignOf(f32) }, | 397 | .{ .name = "int", .type = i32, .alignment = @alignOf(f32) }, |
| 400 | .{ .name = "float", .field_type = f32, .alignment = @alignOf(f32) }, | 398 | .{ .name = "float", .type = f32, .alignment = @alignOf(f32) }, |
| 401 | }, | 399 | }, |
| 402 | .decls = &.{}, | 400 | .decls = &.{}, |
| 403 | }, | 401 | }, |
| ... | @@ -412,8 +410,8 @@ test "Type.Union" { | ... | @@ -412,8 +410,8 @@ test "Type.Union" { |
| 412 | .layout = .Packed, | 410 | .layout = .Packed, |
| 413 | .tag_type = null, | 411 | .tag_type = null, |
| 414 | .fields = &.{ | 412 | .fields = &.{ |
| 415 | .{ .name = "signed", .field_type = i32, .alignment = @alignOf(i32) }, | 413 | .{ .name = "signed", .type = i32, .alignment = @alignOf(i32) }, |
| 416 | .{ .name = "unsigned", .field_type = u32, .alignment = @alignOf(u32) }, | 414 | .{ .name = "unsigned", .type = u32, .alignment = @alignOf(u32) }, |
| 417 | }, | 415 | }, |
| 418 | .decls = &.{}, | 416 | .decls = &.{}, |
| 419 | }, | 417 | }, |
| ... | @@ -424,7 +422,6 @@ test "Type.Union" { | ... | @@ -424,7 +422,6 @@ test "Type.Union" { |
| 424 | 422 | ||
| 425 | const Tag = @Type(.{ | 423 | const Tag = @Type(.{ |
| 426 | .Enum = .{ | 424 | .Enum = .{ |
| 427 | .layout = .Auto, | ||
| 428 | .tag_type = u1, | 425 | .tag_type = u1, |
| 429 | .fields = &.{ | 426 | .fields = &.{ |
| 430 | .{ .name = "signed", .value = 0 }, | 427 | .{ .name = "signed", .value = 0 }, |
| ... | @@ -439,8 +436,8 @@ test "Type.Union" { | ... | @@ -439,8 +436,8 @@ test "Type.Union" { |
| 439 | .layout = .Auto, | 436 | .layout = .Auto, |
| 440 | .tag_type = Tag, | 437 | .tag_type = Tag, |
| 441 | .fields = &.{ | 438 | .fields = &.{ |
| 442 | .{ .name = "signed", .field_type = i32, .alignment = @alignOf(i32) }, | 439 | .{ .name = "signed", .type = i32, .alignment = @alignOf(i32) }, |
| 443 | .{ .name = "unsigned", .field_type = u32, .alignment = @alignOf(u32) }, | 440 | .{ .name = "unsigned", .type = u32, .alignment = @alignOf(u32) }, |
| 444 | }, | 441 | }, |
| 445 | .decls = &.{}, | 442 | .decls = &.{}, |
| 446 | }, | 443 | }, |
| ... | @@ -456,7 +453,6 @@ test "Type.Union from Type.Enum" { | ... | @@ -456,7 +453,6 @@ test "Type.Union from Type.Enum" { |
| 456 | 453 | ||
| 457 | const Tag = @Type(.{ | 454 | const Tag = @Type(.{ |
| 458 | .Enum = .{ | 455 | .Enum = .{ |
| 459 | .layout = .Auto, | ||
| 460 | .tag_type = u0, | 456 | .tag_type = u0, |
| 461 | .fields = &.{ | 457 | .fields = &.{ |
| 462 | .{ .name = "working_as_expected", .value = 0 }, | 458 | .{ .name = "working_as_expected", .value = 0 }, |
| ... | @@ -470,7 +466,7 @@ test "Type.Union from Type.Enum" { | ... | @@ -470,7 +466,7 @@ test "Type.Union from Type.Enum" { |
| 470 | .layout = .Auto, | 466 | .layout = .Auto, |
| 471 | .tag_type = Tag, | 467 | .tag_type = Tag, |
| 472 | .fields = &.{ | 468 | .fields = &.{ |
| 473 | .{ .name = "working_as_expected", .field_type = u32, .alignment = @alignOf(u32) }, | 469 | .{ .name = "working_as_expected", .type = u32, .alignment = @alignOf(u32) }, |
| 474 | }, | 470 | }, |
| 475 | .decls = &.{}, | 471 | .decls = &.{}, |
| 476 | }, | 472 | }, |
| ... | @@ -487,7 +483,7 @@ test "Type.Union from regular enum" { | ... | @@ -487,7 +483,7 @@ test "Type.Union from regular enum" { |
| 487 | .layout = .Auto, | 483 | .layout = .Auto, |
| 488 | .tag_type = E, | 484 | .tag_type = E, |
| 489 | .fields = &.{ | 485 | .fields = &.{ |
| 490 | .{ .name = "working_as_expected", .field_type = u32, .alignment = @alignOf(u32) }, | 486 | .{ .name = "working_as_expected", .type = u32, .alignment = @alignOf(u32) }, |
| 491 | }, | 487 | }, |
| 492 | .decls = &.{}, | 488 | .decls = &.{}, |
| 493 | }, | 489 | }, |
| ... | @@ -512,9 +508,9 @@ test "Type.Fn" { | ... | @@ -512,9 +508,9 @@ test "Type.Fn" { |
| 512 | .is_generic = false, | 508 | .is_generic = false, |
| 513 | .is_var_args = false, | 509 | .is_var_args = false, |
| 514 | .return_type = void, | 510 | .return_type = void, |
| 515 | .args = &.{ | 511 | .params = &.{ |
| 516 | .{ .is_generic = false, .is_noalias = false, .arg_type = c_int }, | 512 | .{ .is_generic = false, .is_noalias = false, .type = c_int }, |
| 517 | .{ .is_generic = false, .is_noalias = false, .arg_type = some_ptr }, | 513 | .{ .is_generic = false, .is_noalias = false, .type = some_ptr }, |
| 518 | }, | 514 | }, |
| 519 | } }; | 515 | } }; |
| 520 | 516 | ||
| ... | @@ -537,7 +533,7 @@ test "reified struct field name from optional payload" { | ... | @@ -537,7 +533,7 @@ test "reified struct field name from optional payload" { |
| 537 | .layout = .Auto, | 533 | .layout = .Auto, |
| 538 | .fields = &.{.{ | 534 | .fields = &.{.{ |
| 539 | .name = name, | 535 | .name = name, |
| 540 | .field_type = u8, | 536 | .type = u8, |
| 541 | .default_value = null, | 537 | .default_value = null, |
| 542 | .is_comptime = false, | 538 | .is_comptime = false, |
| 543 | .alignment = 1, | 539 | .alignment = 1, |
test/behavior/type_info.zig+21-22| ... | @@ -238,7 +238,6 @@ fn testEnum() !void { | ... | @@ -238,7 +238,6 @@ fn testEnum() !void { |
| 238 | 238 | ||
| 239 | const os_info = @typeInfo(Os); | 239 | const os_info = @typeInfo(Os); |
| 240 | try expect(os_info == .Enum); | 240 | try expect(os_info == .Enum); |
| 241 | try expect(os_info.Enum.layout == .Auto); | ||
| 242 | try expect(os_info.Enum.fields.len == 4); | 241 | try expect(os_info.Enum.fields.len == 4); |
| 243 | try expect(mem.eql(u8, os_info.Enum.fields[1].name, "Macos")); | 242 | try expect(mem.eql(u8, os_info.Enum.fields[1].name, "Macos")); |
| 244 | try expect(os_info.Enum.fields[3].value == 3); | 243 | try expect(os_info.Enum.fields[3].value == 3); |
| ... | @@ -257,7 +256,7 @@ fn testUnion() !void { | ... | @@ -257,7 +256,7 @@ fn testUnion() !void { |
| 257 | try expect(typeinfo_info.Union.layout == .Auto); | 256 | try expect(typeinfo_info.Union.layout == .Auto); |
| 258 | try expect(typeinfo_info.Union.tag_type.? == TypeId); | 257 | try expect(typeinfo_info.Union.tag_type.? == TypeId); |
| 259 | try expect(typeinfo_info.Union.fields.len == 24); | 258 | try expect(typeinfo_info.Union.fields.len == 24); |
| 260 | try expect(typeinfo_info.Union.fields[4].field_type == @TypeOf(@typeInfo(u8).Int)); | 259 | try expect(typeinfo_info.Union.fields[4].type == @TypeOf(@typeInfo(u8).Int)); |
| 261 | try expect(typeinfo_info.Union.decls.len == 22); | 260 | try expect(typeinfo_info.Union.decls.len == 22); |
| 262 | 261 | ||
| 263 | const TestNoTagUnion = union { | 262 | const TestNoTagUnion = union { |
| ... | @@ -271,7 +270,7 @@ fn testUnion() !void { | ... | @@ -271,7 +270,7 @@ fn testUnion() !void { |
| 271 | try expect(notag_union_info.Union.layout == .Auto); | 270 | try expect(notag_union_info.Union.layout == .Auto); |
| 272 | try expect(notag_union_info.Union.fields.len == 2); | 271 | try expect(notag_union_info.Union.fields.len == 2); |
| 273 | try expect(notag_union_info.Union.fields[0].alignment == @alignOf(void)); | 272 | try expect(notag_union_info.Union.fields[0].alignment == @alignOf(void)); |
| 274 | try expect(notag_union_info.Union.fields[1].field_type == u32); | 273 | try expect(notag_union_info.Union.fields[1].type == u32); |
| 275 | try expect(notag_union_info.Union.fields[1].alignment == @alignOf(u32)); | 274 | try expect(notag_union_info.Union.fields[1].alignment == @alignOf(u32)); |
| 276 | 275 | ||
| 277 | const TestExternUnion = extern union { | 276 | const TestExternUnion = extern union { |
| ... | @@ -281,7 +280,7 @@ fn testUnion() !void { | ... | @@ -281,7 +280,7 @@ fn testUnion() !void { |
| 281 | const extern_union_info = @typeInfo(TestExternUnion); | 280 | const extern_union_info = @typeInfo(TestExternUnion); |
| 282 | try expect(extern_union_info.Union.layout == .Extern); | 281 | try expect(extern_union_info.Union.layout == .Extern); |
| 283 | try expect(extern_union_info.Union.tag_type == null); | 282 | try expect(extern_union_info.Union.tag_type == null); |
| 284 | try expect(extern_union_info.Union.fields[0].field_type == *anyopaque); | 283 | try expect(extern_union_info.Union.fields[0].type == *anyopaque); |
| 285 | } | 284 | } |
| 286 | 285 | ||
| 287 | test "type info: struct info" { | 286 | test "type info: struct info" { |
| ... | @@ -319,7 +318,7 @@ fn testPackedStruct() !void { | ... | @@ -319,7 +318,7 @@ fn testPackedStruct() !void { |
| 319 | try expect(struct_info.Struct.backing_integer == u128); | 318 | try expect(struct_info.Struct.backing_integer == u128); |
| 320 | try expect(struct_info.Struct.fields.len == 4); | 319 | try expect(struct_info.Struct.fields.len == 4); |
| 321 | try expect(struct_info.Struct.fields[0].alignment == 0); | 320 | try expect(struct_info.Struct.fields[0].alignment == 0); |
| 322 | try expect(struct_info.Struct.fields[2].field_type == f32); | 321 | try expect(struct_info.Struct.fields[2].type == f32); |
| 323 | try expect(struct_info.Struct.fields[2].default_value == null); | 322 | try expect(struct_info.Struct.fields[2].default_value == null); |
| 324 | try expect(@ptrCast(*align(1) const u32, struct_info.Struct.fields[3].default_value.?).* == 4); | 323 | try expect(@ptrCast(*align(1) const u32, struct_info.Struct.fields[3].default_value.?).* == 4); |
| 325 | try expect(struct_info.Struct.fields[3].alignment == 0); | 324 | try expect(struct_info.Struct.fields[3].alignment == 0); |
| ... | @@ -365,7 +364,7 @@ fn testFunction() !void { | ... | @@ -365,7 +364,7 @@ fn testFunction() !void { |
| 365 | try expect(fn_info.Fn.alignment > 0); | 364 | try expect(fn_info.Fn.alignment > 0); |
| 366 | try expect(fn_info.Fn.calling_convention == .C); | 365 | try expect(fn_info.Fn.calling_convention == .C); |
| 367 | try expect(!fn_info.Fn.is_generic); | 366 | try expect(!fn_info.Fn.is_generic); |
| 368 | try expect(fn_info.Fn.args.len == 2); | 367 | try expect(fn_info.Fn.params.len == 2); |
| 369 | try expect(fn_info.Fn.is_var_args); | 368 | try expect(fn_info.Fn.is_var_args); |
| 370 | try expect(fn_info.Fn.return_type.? == usize); | 369 | try expect(fn_info.Fn.return_type.? == usize); |
| 371 | const fn_aligned_info = @typeInfo(@TypeOf(typeInfoFooAligned)); | 370 | const fn_aligned_info = @typeInfo(@TypeOf(typeInfoFooAligned)); |
| ... | @@ -377,31 +376,31 @@ extern fn typeInfoFooAligned(a: usize, b: bool, ...) align(4) callconv(.C) usize | ... | @@ -377,31 +376,31 @@ extern fn typeInfoFooAligned(a: usize, b: bool, ...) align(4) callconv(.C) usize |
| 377 | 376 | ||
| 378 | test "type info: generic function types" { | 377 | test "type info: generic function types" { |
| 379 | const G1 = @typeInfo(@TypeOf(generic1)); | 378 | const G1 = @typeInfo(@TypeOf(generic1)); |
| 380 | try expect(G1.Fn.args.len == 1); | 379 | try expect(G1.Fn.params.len == 1); |
| 381 | try expect(G1.Fn.args[0].is_generic == true); | 380 | try expect(G1.Fn.params[0].is_generic == true); |
| 382 | try expect(G1.Fn.args[0].arg_type == null); | 381 | try expect(G1.Fn.params[0].type == null); |
| 383 | try expect(G1.Fn.return_type == void); | 382 | try expect(G1.Fn.return_type == void); |
| 384 | 383 | ||
| 385 | const G2 = @typeInfo(@TypeOf(generic2)); | 384 | const G2 = @typeInfo(@TypeOf(generic2)); |
| 386 | try expect(G2.Fn.args.len == 3); | 385 | try expect(G2.Fn.params.len == 3); |
| 387 | try expect(G2.Fn.args[0].is_generic == false); | 386 | try expect(G2.Fn.params[0].is_generic == false); |
| 388 | try expect(G2.Fn.args[0].arg_type == type); | 387 | try expect(G2.Fn.params[0].type == type); |
| 389 | try expect(G2.Fn.args[1].is_generic == true); | 388 | try expect(G2.Fn.params[1].is_generic == true); |
| 390 | try expect(G2.Fn.args[1].arg_type == null); | 389 | try expect(G2.Fn.params[1].type == null); |
| 391 | try expect(G2.Fn.args[2].is_generic == false); | 390 | try expect(G2.Fn.params[2].is_generic == false); |
| 392 | try expect(G2.Fn.args[2].arg_type == u8); | 391 | try expect(G2.Fn.params[2].type == u8); |
| 393 | try expect(G2.Fn.return_type == void); | 392 | try expect(G2.Fn.return_type == void); |
| 394 | 393 | ||
| 395 | const G3 = @typeInfo(@TypeOf(generic3)); | 394 | const G3 = @typeInfo(@TypeOf(generic3)); |
| 396 | try expect(G3.Fn.args.len == 1); | 395 | try expect(G3.Fn.params.len == 1); |
| 397 | try expect(G3.Fn.args[0].is_generic == true); | 396 | try expect(G3.Fn.params[0].is_generic == true); |
| 398 | try expect(G3.Fn.args[0].arg_type == null); | 397 | try expect(G3.Fn.params[0].type == null); |
| 399 | try expect(G3.Fn.return_type == null); | 398 | try expect(G3.Fn.return_type == null); |
| 400 | 399 | ||
| 401 | const G4 = @typeInfo(@TypeOf(generic4)); | 400 | const G4 = @typeInfo(@TypeOf(generic4)); |
| 402 | try expect(G4.Fn.args.len == 1); | 401 | try expect(G4.Fn.params.len == 1); |
| 403 | try expect(G4.Fn.args[0].is_generic == true); | 402 | try expect(G4.Fn.params[0].is_generic == true); |
| 404 | try expect(G4.Fn.args[0].arg_type == null); | 403 | try expect(G4.Fn.params[0].type == null); |
| 405 | try expect(G4.Fn.return_type == null); | 404 | try expect(G4.Fn.return_type == null); |
| 406 | } | 405 | } |
| 407 | 406 |
test/behavior/union.zig+1-1| ... | @@ -454,7 +454,7 @@ test "global union with single field is correctly initialized" { | ... | @@ -454,7 +454,7 @@ test "global union with single field is correctly initialized" { |
| 454 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | 454 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 455 | 455 | ||
| 456 | glbl = Foo1{ | 456 | glbl = Foo1{ |
| 457 | .f = @typeInfo(Foo1).Union.fields[0].field_type{ .x = 123 }, | 457 | .f = @typeInfo(Foo1).Union.fields[0].type{ .x = 123 }, |
| 458 | }; | 458 | }; |
| 459 | try expect(glbl.f.x == 123); | 459 | try expect(glbl.f.x == 123); |
| 460 | } | 460 | } |
test/cases/compile_errors/comptime_store_in_comptime_switch_in_runtime_if.zig+1-1| ... | @@ -9,7 +9,7 @@ pub export fn entry() void { | ... | @@ -9,7 +9,7 @@ pub export fn entry() void { |
| 9 | const info = @typeInfo(Widget).Union; | 9 | const info = @typeInfo(Widget).Union; |
| 10 | inline for (info.fields) |field| { | 10 | inline for (info.fields) |field| { |
| 11 | if (foo()) { | 11 | if (foo()) { |
| 12 | switch (field.field_type) { | 12 | switch (field.type) { |
| 13 | u0 => a = 2, | 13 | u0 => a = 2, |
| 14 | else => unreachable, | 14 | else => unreachable, |
| 15 | } | 15 | } |
test/cases/compile_errors/dereference_anyopaque.zig+1-1| ... | @@ -16,7 +16,7 @@ fn parseFree(comptime T: type, value: T, allocator: std.mem.Allocator) void { | ... | @@ -16,7 +16,7 @@ fn parseFree(comptime T: type, value: T, allocator: std.mem.Allocator) void { |
| 16 | .Struct => |structInfo| { | 16 | .Struct => |structInfo| { |
| 17 | inline for (structInfo.fields) |field| { | 17 | inline for (structInfo.fields) |field| { |
| 18 | if (!field.is_comptime) | 18 | if (!field.is_comptime) |
| 19 | parseFree(field.field_type, undefined, allocator); | 19 | parseFree(field.type, undefined, allocator); |
| 20 | } | 20 | } |
| 21 | }, | 21 | }, |
| 22 | .Pointer => |ptrInfo| { | 22 | .Pointer => |ptrInfo| { |
test/cases/compile_errors/packed_struct_field_alignment_unavailable_for_reify_type.zig+1-1| ... | @@ -1,6 +1,6 @@ | ... | @@ -1,6 +1,6 @@ |
| 1 | export fn entry() void { | 1 | export fn entry() void { |
| 2 | _ = @Type(.{ .Struct = .{ .layout = .Packed, .fields = &.{ | 2 | _ = @Type(.{ .Struct = .{ .layout = .Packed, .fields = &.{ |
| 3 | .{ .name = "one", .field_type = u4, .default_value = null, .is_comptime = false, .alignment = 2 }, | 3 | .{ .name = "one", .type = u4, .default_value = null, .is_comptime = false, .alignment = 2 }, |
| 4 | }, .decls = &.{}, .is_tuple = false } }); | 4 | }, .decls = &.{}, .is_tuple = false } }); |
| 5 | } | 5 | } |
| 6 | 6 |
test/cases/compile_errors/reified_enum_field_value_overflow.zig-1| ... | @@ -1,6 +1,5 @@ | ... | @@ -1,6 +1,5 @@ |
| 1 | comptime { | 1 | comptime { |
| 2 | const E = @Type(.{ .Enum = .{ | 2 | const E = @Type(.{ .Enum = .{ |
| 3 | .layout = .Auto, | ||
| 4 | .tag_type = u1, | 3 | .tag_type = u1, |
| 5 | .fields = &.{ | 4 | .fields = &.{ |
| 6 | .{ .name = "f0", .value = 0 }, | 5 | .{ .name = "f0", .value = 0 }, |
test/cases/compile_errors/reify_enum_with_duplicate_field.zig-1| ... | @@ -1,7 +1,6 @@ | ... | @@ -1,7 +1,6 @@ |
| 1 | export fn entry() void { | 1 | export fn entry() void { |
| 2 | _ = @Type(.{ | 2 | _ = @Type(.{ |
| 3 | .Enum = .{ | 3 | .Enum = .{ |
| 4 | .layout = .Auto, | ||
| 5 | .tag_type = u32, | 4 | .tag_type = u32, |
| 6 | .fields = &.{ | 5 | .fields = &.{ |
| 7 | .{ .name = "A", .value = 0 }, | 6 | .{ .name = "A", .value = 0 }, |
test/cases/compile_errors/reify_enum_with_duplicate_tag_value.zig-1| ... | @@ -1,7 +1,6 @@ | ... | @@ -1,7 +1,6 @@ |
| 1 | export fn entry() void { | 1 | export fn entry() void { |
| 2 | _ = @Type(.{ | 2 | _ = @Type(.{ |
| 3 | .Enum = .{ | 3 | .Enum = .{ |
| 4 | .layout = .Auto, | ||
| 5 | .tag_type = u32, | 4 | .tag_type = u32, |
| 6 | .fields = &.{ | 5 | .fields = &.{ |
| 7 | .{ .name = "A", .value = 10 }, | 6 | .{ .name = "A", .value = 10 }, |
test/cases/compile_errors/reify_struct.zig+5-5| ... | @@ -3,7 +3,7 @@ comptime { | ... | @@ -3,7 +3,7 @@ comptime { |
| 3 | .layout = .Auto, | 3 | .layout = .Auto, |
| 4 | .fields = &.{.{ | 4 | .fields = &.{.{ |
| 5 | .name = "foo", | 5 | .name = "foo", |
| 6 | .field_type = u32, | 6 | .type = u32, |
| 7 | .default_value = null, | 7 | .default_value = null, |
| 8 | .is_comptime = false, | 8 | .is_comptime = false, |
| 9 | .alignment = 4, | 9 | .alignment = 4, |
| ... | @@ -17,7 +17,7 @@ comptime { | ... | @@ -17,7 +17,7 @@ comptime { |
| 17 | .layout = .Auto, | 17 | .layout = .Auto, |
| 18 | .fields = &.{.{ | 18 | .fields = &.{.{ |
| 19 | .name = "3", | 19 | .name = "3", |
| 20 | .field_type = u32, | 20 | .type = u32, |
| 21 | .default_value = null, | 21 | .default_value = null, |
| 22 | .is_comptime = false, | 22 | .is_comptime = false, |
| 23 | .alignment = 4, | 23 | .alignment = 4, |
| ... | @@ -31,7 +31,7 @@ comptime { | ... | @@ -31,7 +31,7 @@ comptime { |
| 31 | .layout = .Auto, | 31 | .layout = .Auto, |
| 32 | .fields = &.{.{ | 32 | .fields = &.{.{ |
| 33 | .name = "0", | 33 | .name = "0", |
| 34 | .field_type = u32, | 34 | .type = u32, |
| 35 | .default_value = null, | 35 | .default_value = null, |
| 36 | .is_comptime = true, | 36 | .is_comptime = true, |
| 37 | .alignment = 4, | 37 | .alignment = 4, |
| ... | @@ -45,7 +45,7 @@ comptime { | ... | @@ -45,7 +45,7 @@ comptime { |
| 45 | .layout = .Extern, | 45 | .layout = .Extern, |
| 46 | .fields = &.{.{ | 46 | .fields = &.{.{ |
| 47 | .name = "0", | 47 | .name = "0", |
| 48 | .field_type = u32, | 48 | .type = u32, |
| 49 | .default_value = null, | 49 | .default_value = null, |
| 50 | .is_comptime = true, | 50 | .is_comptime = true, |
| 51 | .alignment = 4, | 51 | .alignment = 4, |
| ... | @@ -59,7 +59,7 @@ comptime { | ... | @@ -59,7 +59,7 @@ comptime { |
| 59 | .layout = .Packed, | 59 | .layout = .Packed, |
| 60 | .fields = &.{.{ | 60 | .fields = &.{.{ |
| 61 | .name = "0", | 61 | .name = "0", |
| 62 | .field_type = u32, | 62 | .type = u32, |
| 63 | .default_value = null, | 63 | .default_value = null, |
| 64 | .is_comptime = true, | 64 | .is_comptime = true, |
| 65 | .alignment = 4, | 65 | .alignment = 4, |
test/cases/compile_errors/reify_type.Fn_with_is_generic_true.zig+1-1| ... | @@ -5,7 +5,7 @@ const Foo = @Type(.{ | ... | @@ -5,7 +5,7 @@ const Foo = @Type(.{ |
| 5 | .is_generic = true, | 5 | .is_generic = true, |
| 6 | .is_var_args = false, | 6 | .is_var_args = false, |
| 7 | .return_type = u0, | 7 | .return_type = u0, |
| 8 | .args = &.{}, | 8 | .params = &.{}, |
| 9 | }, | 9 | }, |
| 10 | }); | 10 | }); |
| 11 | comptime { _ = Foo; } | 11 | comptime { _ = Foo; } |
test/cases/compile_errors/reify_type.Fn_with_is_var_args_true_and_non-C_callconv.zig+1-1| ... | @@ -5,7 +5,7 @@ const Foo = @Type(.{ | ... | @@ -5,7 +5,7 @@ const Foo = @Type(.{ |
| 5 | .is_generic = false, | 5 | .is_generic = false, |
| 6 | .is_var_args = true, | 6 | .is_var_args = true, |
| 7 | .return_type = u0, | 7 | .return_type = u0, |
| 8 | .args = &.{}, | 8 | .params = &.{}, |
| 9 | }, | 9 | }, |
| 10 | }); | 10 | }); |
| 11 | comptime { _ = Foo; } | 11 | comptime { _ = Foo; } |
test/cases/compile_errors/reify_type.Fn_with_return_type_null.zig+1-1| ... | @@ -5,7 +5,7 @@ const Foo = @Type(.{ | ... | @@ -5,7 +5,7 @@ const Foo = @Type(.{ |
| 5 | .is_generic = false, | 5 | .is_generic = false, |
| 6 | .is_var_args = false, | 6 | .is_var_args = false, |
| 7 | .return_type = null, | 7 | .return_type = null, |
| 8 | .args = &.{}, | 8 | .params = &.{}, |
| 9 | }, | 9 | }, |
| 10 | }); | 10 | }); |
| 11 | comptime { _ = Foo; } | 11 | comptime { _ = Foo; } |
test/cases/compile_errors/reify_type_for_exhaustive_enum_with_non-integer_tag_type.zig-1| ... | @@ -1,6 +1,5 @@ | ... | @@ -1,6 +1,5 @@ |
| 1 | const Tag = @Type(.{ | 1 | const Tag = @Type(.{ |
| 2 | .Enum = .{ | 2 | .Enum = .{ |
| 3 | .layout = .Auto, | ||
| 4 | .tag_type = bool, | 3 | .tag_type = bool, |
| 5 | .fields = &.{}, | 4 | .fields = &.{}, |
| 6 | .decls = &.{}, | 5 | .decls = &.{}, |
test/cases/compile_errors/reify_type_for_exhaustive_enum_with_undefined_tag_type.zig-1| ... | @@ -1,6 +1,5 @@ | ... | @@ -1,6 +1,5 @@ |
| 1 | const Tag = @Type(.{ | 1 | const Tag = @Type(.{ |
| 2 | .Enum = .{ | 2 | .Enum = .{ |
| 3 | .layout = .Auto, | ||
| 4 | .tag_type = undefined, | 3 | .tag_type = undefined, |
| 5 | .fields = &.{}, | 4 | .fields = &.{}, |
| 6 | .decls = &.{}, | 5 | .decls = &.{}, |
test/cases/compile_errors/reify_type_for_tagged_union_with_extra_enum_field.zig+3-4| ... | @@ -1,6 +1,5 @@ | ... | @@ -1,6 +1,5 @@ |
| 1 | const Tag = @Type(.{ | 1 | const Tag = @Type(.{ |
| 2 | .Enum = .{ | 2 | .Enum = .{ |
| 3 | .layout = .Auto, | ||
| 4 | .tag_type = u2, | 3 | .tag_type = u2, |
| 5 | .fields = &.{ | 4 | .fields = &.{ |
| 6 | .{ .name = "signed", .value = 0 }, | 5 | .{ .name = "signed", .value = 0 }, |
| ... | @@ -16,8 +15,8 @@ const Tagged = @Type(.{ | ... | @@ -16,8 +15,8 @@ const Tagged = @Type(.{ |
| 16 | .layout = .Auto, | 15 | .layout = .Auto, |
| 17 | .tag_type = Tag, | 16 | .tag_type = Tag, |
| 18 | .fields = &.{ | 17 | .fields = &.{ |
| 19 | .{ .name = "signed", .field_type = i32, .alignment = @alignOf(i32) }, | 18 | .{ .name = "signed", .type = i32, .alignment = @alignOf(i32) }, |
| 20 | .{ .name = "unsigned", .field_type = u32, .alignment = @alignOf(u32) }, | 19 | .{ .name = "unsigned", .type = u32, .alignment = @alignOf(u32) }, |
| 21 | }, | 20 | }, |
| 22 | .decls = &.{}, | 21 | .decls = &.{}, |
| 23 | }, | 22 | }, |
| ... | @@ -31,6 +30,6 @@ export fn entry() void { | ... | @@ -31,6 +30,6 @@ export fn entry() void { |
| 31 | // backend=stage2 | 30 | // backend=stage2 |
| 32 | // target=native | 31 | // target=native |
| 33 | // | 32 | // |
| 34 | // :14:16: error: enum field(s) missing in union | 33 | // :13:16: error: enum field(s) missing in union |
| 35 | // :1:13: note: field 'arst' missing, declared here | 34 | // :1:13: note: field 'arst' missing, declared here |
| 36 | // :1:13: note: enum declared here | 35 | // :1:13: note: enum declared here |
test/cases/compile_errors/reify_type_for_tagged_union_with_extra_union_field.zig+4-5| ... | @@ -1,6 +1,5 @@ | ... | @@ -1,6 +1,5 @@ |
| 1 | const Tag = @Type(.{ | 1 | const Tag = @Type(.{ |
| 2 | .Enum = .{ | 2 | .Enum = .{ |
| 3 | .layout = .Auto, | ||
| 4 | .tag_type = u1, | 3 | .tag_type = u1, |
| 5 | .fields = &.{ | 4 | .fields = &.{ |
| 6 | .{ .name = "signed", .value = 0 }, | 5 | .{ .name = "signed", .value = 0 }, |
| ... | @@ -15,9 +14,9 @@ const Tagged = @Type(.{ | ... | @@ -15,9 +14,9 @@ const Tagged = @Type(.{ |
| 15 | .layout = .Auto, | 14 | .layout = .Auto, |
| 16 | .tag_type = Tag, | 15 | .tag_type = Tag, |
| 17 | .fields = &.{ | 16 | .fields = &.{ |
| 18 | .{ .name = "signed", .field_type = i32, .alignment = @alignOf(i32) }, | 17 | .{ .name = "signed", .type = i32, .alignment = @alignOf(i32) }, |
| 19 | .{ .name = "unsigned", .field_type = u32, .alignment = @alignOf(u32) }, | 18 | .{ .name = "unsigned", .type = u32, .alignment = @alignOf(u32) }, |
| 20 | .{ .name = "arst", .field_type = f32, .alignment = @alignOf(f32) }, | 19 | .{ .name = "arst", .type = f32, .alignment = @alignOf(f32) }, |
| 21 | }, | 20 | }, |
| 22 | .decls = &.{}, | 21 | .decls = &.{}, |
| 23 | }, | 22 | }, |
| ... | @@ -31,5 +30,5 @@ export fn entry() void { | ... | @@ -31,5 +30,5 @@ export fn entry() void { |
| 31 | // backend=stage2 | 30 | // backend=stage2 |
| 32 | // target=native | 31 | // target=native |
| 33 | // | 32 | // |
| 34 | // :13:16: error: no field named 'arst' in enum 'tmp.Tag' | 33 | // :12:16: error: no field named 'arst' in enum 'tmp.Tag' |
| 35 | // :1:13: note: enum declared here | 34 | // :1:13: note: enum declared here |
test/cases/compile_errors/reify_type_for_union_with_opaque_field.zig+2-2| ... | @@ -3,7 +3,7 @@ const Untagged = @Type(.{ | ... | @@ -3,7 +3,7 @@ const Untagged = @Type(.{ |
| 3 | .layout = .Auto, | 3 | .layout = .Auto, |
| 4 | .tag_type = null, | 4 | .tag_type = null, |
| 5 | .fields = &.{ | 5 | .fields = &.{ |
| 6 | .{ .name = "foo", .field_type = opaque {}, .alignment = 1 }, | 6 | .{ .name = "foo", .type = opaque {}, .alignment = 1 }, |
| 7 | }, | 7 | }, |
| 8 | .decls = &.{}, | 8 | .decls = &.{}, |
| 9 | }, | 9 | }, |
| ... | @@ -17,4 +17,4 @@ export fn entry() usize { | ... | @@ -17,4 +17,4 @@ export fn entry() usize { |
| 17 | // target=native | 17 | // target=native |
| 18 | // | 18 | // |
| 19 | // :1:18: error: opaque types have unknown size and therefore cannot be directly embedded in unions | 19 | // :1:18: error: opaque types have unknown size and therefore cannot be directly embedded in unions |
| 20 | // :6:45: note: opaque declared here | 20 | // :6:39: note: opaque declared here |
test/cases/fn_typeinfo_passed_to_comptime_fn.zig+1-1| ... | @@ -9,7 +9,7 @@ fn someFn(arg: ?*c_int) f64 { | ... | @@ -9,7 +9,7 @@ fn someFn(arg: ?*c_int) f64 { |
| 9 | return 8; | 9 | return 8; |
| 10 | } | 10 | } |
| 11 | fn foo(comptime info: std.builtin.Type) !void { | 11 | fn foo(comptime info: std.builtin.Type) !void { |
| 12 | try std.testing.expect(info.Fn.args[0].arg_type.? == ?*c_int); | 12 | try std.testing.expect(info.Fn.params[0].type.? == ?*c_int); |
| 13 | } | 13 | } |
| 14 | 14 | ||
| 15 | // run | 15 | // run |