authorgravatar for r00ster91@proton.meWooster <r00ster91@proton.me> 2022-12-13 21:36:08+01:00
committergravatar for r00ster91@proton.meWooster <r00ster91@proton.me> 2022-12-17 14:11:33+01:00
log20d3fd901eb6a7ddc1340107ae00e0f2014552e3
treeed161bf6a59c4eb4304f5a422e36de7fbd131042
parent90477e5c10c9c263a3c0038e1ae7b814d2c5397e

std.builtin: rename Type.Fn.Param's arg_type to type

It's the type of a parameter, not an argument, but the prefix is redundant either way.

12 files changed, 28 insertions(+), 28 deletions(-)

doc/langref.html.in+1-1
...@@ -5242,7 +5242,7 @@ const math = std.math;...@@ -5242,7 +5242,7 @@ const math = std.math;
5242const testing = std.testing;5242const testing = std.testing;
52435243
5244test "fn reflection" {5244test "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.args[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);
52475247
5248 try testing.expect(@typeInfo(@TypeOf(math.Log2Int)).Fn.is_generic);5248 try testing.expect(@typeInfo(@TypeOf(math.Log2Int)).Fn.is_generic);
lib/std/builtin.zig+1-1
...@@ -374,7 +374,7 @@ pub const Type = union(enum) {...@@ -374,7 +374,7 @@ pub const Type = union(enum) {
374 pub const Param = struct {374 pub const Param = struct {
375 is_generic: bool,375 is_generic: bool,
376 is_noalias: bool,376 is_noalias: bool,
377 arg_type: ?type,377 type: ?type,
378 };378 };
379 };379 };
380380
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///
1726pub fn Formatter(comptime format_fn: anytype) type {1726pub 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.args[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_map.zig+8-8
...@@ -190,7 +190,7 @@ pub fn verifyContext(...@@ -190,7 +190,7 @@ pub fn verifyContext(
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.args[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.args[1].type != null and func.args[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.args[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) {
...@@ -267,7 +267,7 @@ pub fn verifyContext(...@@ -267,7 +267,7 @@ pub fn verifyContext(
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.args[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.args[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.args[1].type.?);
317 }317 }
318 if (func.args[2].arg_type.? != Key) {318 if (func.args[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.args[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/meta.zig+1-1
...@@ -1086,7 +1086,7 @@ pub fn ArgsTuple(comptime Function: type) type {...@@ -1086,7 +1086,7 @@ pub fn ArgsTuple(comptime Function: type) type {
10861086
1087 var argument_field_list: [function_info.args.len]type = undefined;1087 var argument_field_list: [function_info.args.len]type = undefined;
1088 inline for (function_info.args) |arg, i| {1088 inline for (function_info.args) |arg, i| {
1089 const T = arg.arg_type.?;1089 const T = arg.type.?;
1090 argument_field_list[i] = T;1090 argument_field_list[i] = T;
1091 }1091 }
10921092
lib/std/start.zig+1-1
...@@ -634,7 +634,7 @@ pub fn callMain() u8 {...@@ -634,7 +634,7 @@ pub fn callMain() u8 {
634}634}
635635
636pub fn call_wWinMain() std.os.windows.INT {636pub 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.args[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();
640640
src/Sema.zig+2-2
...@@ -15316,7 +15316,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -15316,7 +15316,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
15316 Value.makeBool(is_generic),15316 Value.makeBool(is_generic),
15317 // is_noalias: bool,15317 // is_noalias: bool,
15318 Value.makeBool(is_noalias),15318 Value.makeBool(is_noalias),
15319 // arg_type: ?type,15319 // type: ?type,
15320 param_ty_val,15320 param_ty_val,
15321 };15321 };
15322 param_val.* = try Value.Tag.aggregate.create(params_anon_decl.arena(), param_fields);15322 param_val.* = try Value.Tag.aggregate.create(params_anon_decl.arena(), param_fields);
...@@ -18730,7 +18730,7 @@ fn zirReify(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData, in...@@ -18730,7 +18730,7 @@ fn zirReify(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData, in
18730 const arg_is_generic = arg_val[0].toBool();18730 const arg_is_generic = arg_val[0].toBool();
18731 // is_noalias: bool,18731 // is_noalias: bool,
18732 const arg_is_noalias = arg_val[1].toBool();18732 const arg_is_noalias = arg_val[1].toBool();
18733 // arg_type: ?type,18733 // type: ?type,
18734 const param_type_opt_val = arg_val[2];18734 const param_type_opt_val = arg_val[2];
1873518735
18736 if (arg_is_generic) {18736 if (arg_is_generic) {
test/behavior/bugs/12885.zig+1-1
...@@ -16,7 +16,7 @@ test "ErrorSet comptime_field_ptr" {...@@ -16,7 +16,7 @@ test "ErrorSet comptime_field_ptr" {
1616
17const fn_info = .{17const fn_info = .{
18 .args = [_]builtin.Type.Fn.Param{18 .args = [_]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};
22const Bar = @Type(.{22const Bar = @Type(.{
test/behavior/reflection.zig+3-3
...@@ -10,9 +10,9 @@ test "reflection: function return type, var args, and param types" {...@@ -10,9 +10,9 @@ test "reflection: function return type, var args, and param types" {
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.args.len == 3);
13 try expect(info.args[0].arg_type.? == bool);13 try expect(info.args[0].type.? == bool);
14 try expect(info.args[1].arg_type.? == i32);14 try expect(info.args[1].type.? == i32);
15 try expect(info.args[2].arg_type.? == f32);15 try expect(info.args[2].type.? == f32);
16 }16 }
17}17}
1818
test/behavior/type.zig+2-2
...@@ -513,8 +513,8 @@ test "Type.Fn" {...@@ -513,8 +513,8 @@ test "Type.Fn" {
513 .is_var_args = false,513 .is_var_args = false,
514 .return_type = void,514 .return_type = void,
515 .args = &.{515 .args = &.{
516 .{ .is_generic = false, .is_noalias = false, .arg_type = c_int },516 .{ .is_generic = false, .is_noalias = false, .type = c_int },
517 .{ .is_generic = false, .is_noalias = false, .arg_type = some_ptr },517 .{ .is_generic = false, .is_noalias = false, .type = some_ptr },
518 },518 },
519 } };519 } };
520520
test/behavior/type_info.zig+6-6
...@@ -379,29 +379,29 @@ test "type info: generic function types" {...@@ -379,29 +379,29 @@ test "type info: generic function types" {
379 const G1 = @typeInfo(@TypeOf(generic1));379 const G1 = @typeInfo(@TypeOf(generic1));
380 try expect(G1.Fn.args.len == 1);380 try expect(G1.Fn.args.len == 1);
381 try expect(G1.Fn.args[0].is_generic == true);381 try expect(G1.Fn.args[0].is_generic == true);
382 try expect(G1.Fn.args[0].arg_type == null);382 try expect(G1.Fn.args[0].type == null);
383 try expect(G1.Fn.return_type == void);383 try expect(G1.Fn.return_type == void);
384384
385 const G2 = @typeInfo(@TypeOf(generic2));385 const G2 = @typeInfo(@TypeOf(generic2));
386 try expect(G2.Fn.args.len == 3);386 try expect(G2.Fn.args.len == 3);
387 try expect(G2.Fn.args[0].is_generic == false);387 try expect(G2.Fn.args[0].is_generic == false);
388 try expect(G2.Fn.args[0].arg_type == type);388 try expect(G2.Fn.args[0].type == type);
389 try expect(G2.Fn.args[1].is_generic == true);389 try expect(G2.Fn.args[1].is_generic == true);
390 try expect(G2.Fn.args[1].arg_type == null);390 try expect(G2.Fn.args[1].type == null);
391 try expect(G2.Fn.args[2].is_generic == false);391 try expect(G2.Fn.args[2].is_generic == false);
392 try expect(G2.Fn.args[2].arg_type == u8);392 try expect(G2.Fn.args[2].type == u8);
393 try expect(G2.Fn.return_type == void);393 try expect(G2.Fn.return_type == void);
394394
395 const G3 = @typeInfo(@TypeOf(generic3));395 const G3 = @typeInfo(@TypeOf(generic3));
396 try expect(G3.Fn.args.len == 1);396 try expect(G3.Fn.args.len == 1);
397 try expect(G3.Fn.args[0].is_generic == true);397 try expect(G3.Fn.args[0].is_generic == true);
398 try expect(G3.Fn.args[0].arg_type == null);398 try expect(G3.Fn.args[0].type == null);
399 try expect(G3.Fn.return_type == null);399 try expect(G3.Fn.return_type == null);
400400
401 const G4 = @typeInfo(@TypeOf(generic4));401 const G4 = @typeInfo(@TypeOf(generic4));
402 try expect(G4.Fn.args.len == 1);402 try expect(G4.Fn.args.len == 1);
403 try expect(G4.Fn.args[0].is_generic == true);403 try expect(G4.Fn.args[0].is_generic == true);
404 try expect(G4.Fn.args[0].arg_type == null);404 try expect(G4.Fn.args[0].type == null);
405 try expect(G4.Fn.return_type == null);405 try expect(G4.Fn.return_type == null);
406}406}
407407
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}
11fn foo(comptime info: std.builtin.Type) !void {11fn 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.args[0].type.? == ?*c_int);
13}13}
1414
15// run15// run