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;
52425242const testing = std.testing;
52435243
52445244test "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);
52465246 try testing.expect(@typeInfo(@TypeOf(testing.tmpDir)).Fn.return_type.? == testing.TmpDir);
52475247
52485248 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) {
374374 pub const Param = struct {
375375 is_generic: bool,
376376 is_noalias: bool,
377 arg_type: ?type,
377 type: ?type,
378378 };
379379 };
380380
lib/std/fmt.zig+1-1
......@@ -1724,7 +1724,7 @@ pub const ParseIntError = error{
17241724/// ) !void;
17251725///
17261726pub 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.?;
17281728 return struct {
17291729 data: Data,
17301730 pub fn format(
lib/std/hash_map.zig+8-8
......@@ -190,7 +190,7 @@ pub fn verifyContext(
190190 errors = errors ++ lazy.err_invalid_hash_signature;
191191 } else {
192192 var emitted_signature = false;
193 if (func.args[0].arg_type) |Self| {
193 if (func.args[0].type) |Self| {
194194 if (Self == Context) {
195195 // pass, this is always fine.
196196 } else if (Self == *const Context) {
......@@ -231,12 +231,12 @@ pub fn verifyContext(
231231 errors = errors ++ ", but is " ++ @typeName(Self);
232232 }
233233 }
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) {
235235 if (!emitted_signature) {
236236 errors = errors ++ lazy.err_invalid_hash_signature;
237237 emitted_signature = true;
238238 }
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.?);
240240 }
241241 if (func.return_type != null and func.return_type.? != Hash) {
242242 if (!emitted_signature) {
......@@ -267,7 +267,7 @@ pub fn verifyContext(
267267 errors = errors ++ lazy.err_invalid_eql_signature;
268268 } else {
269269 var emitted_signature = false;
270 if (func.args[0].arg_type) |Self| {
270 if (func.args[0].type) |Self| {
271271 if (Self == Context) {
272272 // pass, this is always fine.
273273 } else if (Self == *const Context) {
......@@ -308,19 +308,19 @@ pub fn verifyContext(
308308 errors = errors ++ ", but is " ++ @typeName(Self);
309309 }
310310 }
311 if (func.args[1].arg_type.? != PseudoKey) {
311 if (func.args[1].type.? != PseudoKey) {
312312 if (!emitted_signature) {
313313 errors = errors ++ lazy.err_invalid_eql_signature;
314314 emitted_signature = true;
315315 }
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.?);
317317 }
318 if (func.args[2].arg_type.? != Key) {
318 if (func.args[2].type.? != Key) {
319319 if (!emitted_signature) {
320320 errors = errors ++ lazy.err_invalid_eql_signature;
321321 emitted_signature = true;
322322 }
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.?);
324324 }
325325 if (func.return_type.? != bool) {
326326 if (!emitted_signature) {
lib/std/meta.zig+1-1
......@@ -1086,7 +1086,7 @@ pub fn ArgsTuple(comptime Function: type) type {
10861086
10871087 var argument_field_list: [function_info.args.len]type = undefined;
10881088 inline for (function_info.args) |arg, i| {
1089 const T = arg.arg_type.?;
1089 const T = arg.type.?;
10901090 argument_field_list[i] = T;
10911091 }
10921092
lib/std/start.zig+1-1
......@@ -634,7 +634,7 @@ pub fn callMain() u8 {
634634}
635635
636636pub 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.?;
638638 const hInstance = @ptrCast(MAIN_HINSTANCE, std.os.windows.kernel32.GetModuleHandleW(null).?);
639639 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
1531615316 Value.makeBool(is_generic),
1531715317 // is_noalias: bool,
1531815318 Value.makeBool(is_noalias),
15319 // arg_type: ?type,
15319 // type: ?type,
1532015320 param_ty_val,
1532115321 };
1532215322 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
1873018730 const arg_is_generic = arg_val[0].toBool();
1873118731 // is_noalias: bool,
1873218732 const arg_is_noalias = arg_val[1].toBool();
18733 // arg_type: ?type,
18733 // type: ?type,
1873418734 const param_type_opt_val = arg_val[2];
1873518735
1873618736 if (arg_is_generic) {
test/behavior/bugs/12885.zig+1-1
......@@ -16,7 +16,7 @@ test "ErrorSet comptime_field_ptr" {
1616
1717const fn_info = .{
1818 .args = [_]builtin.Type.Fn.Param{
19 .{ .is_generic = false, .is_noalias = false, .arg_type = u8 },
19 .{ .is_generic = false, .is_noalias = false, .type = u8 },
2020 },
2121};
2222const Bar = @Type(.{
test/behavior/reflection.zig+3-3
......@@ -10,9 +10,9 @@ test "reflection: function return type, var args, and param types" {
1010 try expect(info.return_type.? == i32);
1111 try expect(!info.is_var_args);
1212 try expect(info.args.len == 3);
13 try expect(info.args[0].arg_type.? == bool);
14 try expect(info.args[1].arg_type.? == i32);
15 try expect(info.args[2].arg_type.? == f32);
13 try expect(info.args[0].type.? == bool);
14 try expect(info.args[1].type.? == i32);
15 try expect(info.args[2].type.? == f32);
1616 }
1717}
1818
test/behavior/type.zig+2-2
......@@ -513,8 +513,8 @@ test "Type.Fn" {
513513 .is_var_args = false,
514514 .return_type = void,
515515 .args = &.{
516 .{ .is_generic = false, .is_noalias = false, .arg_type = c_int },
517 .{ .is_generic = false, .is_noalias = false, .arg_type = some_ptr },
516 .{ .is_generic = false, .is_noalias = false, .type = c_int },
517 .{ .is_generic = false, .is_noalias = false, .type = some_ptr },
518518 },
519519 } };
520520
test/behavior/type_info.zig+6-6
......@@ -379,29 +379,29 @@ test "type info: generic function types" {
379379 const G1 = @typeInfo(@TypeOf(generic1));
380380 try expect(G1.Fn.args.len == 1);
381381 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);
383383 try expect(G1.Fn.return_type == void);
384384
385385 const G2 = @typeInfo(@TypeOf(generic2));
386386 try expect(G2.Fn.args.len == 3);
387387 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);
389389 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);
391391 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);
393393 try expect(G2.Fn.return_type == void);
394394
395395 const G3 = @typeInfo(@TypeOf(generic3));
396396 try expect(G3.Fn.args.len == 1);
397397 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);
399399 try expect(G3.Fn.return_type == null);
400400
401401 const G4 = @typeInfo(@TypeOf(generic4));
402402 try expect(G4.Fn.args.len == 1);
403403 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);
405405 try expect(G4.Fn.return_type == null);
406406}
407407
test/cases/fn_typeinfo_passed_to_comptime_fn.zig+1-1
......@@ -9,7 +9,7 @@ fn someFn(arg: ?*c_int) f64 {
99 return 8;
1010}
1111fn 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);
1313}
1414
1515// run