authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-05-02 10:44:59+01:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-05-03 12:23:29+01:00
loge133f793ee42cae28d68eaab442bf243489993d6
tree8bec44c991eeb07a82ebb8b3a348f279d7cdc701
parent8df04e144483ff48e506522da8269af25d0bca85
signaturelock-open Commit is signed but in an unrecognized format.

compiler: depend on 'std.lang' instead of 'std.builtin'


25 files changed, 232 insertions(+), 232 deletions(-)

build.zig+1-1
......@@ -191,7 +191,7 @@ pub fn build(b: *std.Build) !void {
191191 const valgrind = b.option(bool, "valgrind", "Enable valgrind integration");
192192 const pie = b.option(bool, "pie", "Produce a Position Independent Executable");
193193 const io_mode = b.option(IoMode, "io-mode", "How the compiler performs IO") orelse .threaded;
194 const value_interpret_mode = b.option(ValueInterpretMode, "value-interpret-mode", "How the compiler translates between 'std.builtin' types and its internal datastructures") orelse .direct;
194 const value_interpret_mode = b.option(ValueInterpretMode, "value-interpret-mode", "How the compiler translates between 'std.lang' types and its internal datastructures") orelse .direct;
195195 const value_tracing = b.option(bool, "value-tracing", "Enable extra state tracking to help troubleshoot bugs in the compiler (using the std.debug.Trace API)") orelse false;
196196
197197 const mem_leak_frames: u32 = b.option(u32, "mem-leak-frames", "How many stack frames to print when a memory leak occurs. Tests get 2x this amount.") orelse blk: {
lib/std/zig.zig+2-2
......@@ -876,7 +876,7 @@ pub const SimpleComptimeReason = enum(u32) {
876876 casted_to_comptime_enum,
877877 casted_to_comptime_int,
878878 casted_to_comptime_float,
879 std_builtin_decl,
879 std_lang_decl,
880880
881881 pub fn message(r: SimpleComptimeReason) []const u8 {
882882 return switch (r) {
......@@ -959,7 +959,7 @@ pub const SimpleComptimeReason = enum(u32) {
959959 .casted_to_comptime_enum => "value casted to enum with 'comptime_int' tag type must be comptime-known",
960960 .casted_to_comptime_int => "value casted to 'comptime_int' must be comptime-known",
961961 .casted_to_comptime_float => "value casted to 'comptime_float' must be comptime-known",
962 .std_builtin_decl => "'std.builtin' declaration values must be comptime-known",
962 .std_lang_decl => "'std.lang' declaration values must be comptime-known",
963963 // zig fmt: on
964964 };
965965 }
lib/std/zig/AstGen.zig+29-29
......@@ -1398,12 +1398,12 @@ fn fnProtoExprInner(
13981398 try comptimeExpr(
13991399 &block_scope,
14001400 scope,
1401 .{ .rl = .{ .coerced_ty = try block_scope.addBuiltinValue(callconv_expr, .calling_convention) } },
1401 .{ .rl = .{ .coerced_ty = try block_scope.addStdLangValue(callconv_expr, .calling_convention) } },
14021402 callconv_expr,
14031403 .@"callconv",
14041404 )
14051405 else if (implicit_ccc)
1406 try block_scope.addBuiltinValue(node, .calling_convention_c)
1406 try block_scope.addStdLangValue(node, .calling_convention_c)
14071407 else
14081408 .none;
14091409
......@@ -3782,7 +3782,7 @@ fn ptrType(
37823782 gz.astgen.source_line = source_line;
37833783 gz.astgen.source_column = source_column;
37843784
3785 const addrspace_ty = try gz.addBuiltinValue(addrspace_node, .address_space);
3785 const addrspace_ty = try gz.addStdLangValue(addrspace_node, .address_space);
37863786 addrspace_ref = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = addrspace_ty } }, addrspace_node, .@"addrspace");
37873787 trailing_count += 1;
37883788 }
......@@ -4077,7 +4077,7 @@ fn fnDecl(
40774077
40784078 if (fn_proto.ast.addrspace_expr.unwrap()) |addrspace_expr| {
40794079 astgen.restoreSourceCursor(saved_cursor);
4080 const addrspace_ty = try addrspace_gz.addBuiltinValue(addrspace_expr, .address_space);
4080 const addrspace_ty = try addrspace_gz.addStdLangValue(addrspace_expr, .address_space);
40814081 const inst = try expr(&addrspace_gz, &addrspace_gz.base, .{ .rl = .{ .coerced_ty = addrspace_ty } }, addrspace_expr);
40824082 _ = try addrspace_gz.addBreakWithSrcNode(.break_inline, decl_inst, inst, decl_node);
40834083 }
......@@ -4285,7 +4285,7 @@ fn fnDeclInner(
42854285 const inst = try expr(
42864286 &cc_gz,
42874287 scope,
4288 .{ .rl = .{ .coerced_ty = try cc_gz.addBuiltinValue(callconv_expr, .calling_convention) } },
4288 .{ .rl = .{ .coerced_ty = try cc_gz.addStdLangValue(callconv_expr, .calling_convention) } },
42894289 callconv_expr,
42904290 );
42914291 if (cc_gz.instructionsSlice().len == 0) {
......@@ -4295,7 +4295,7 @@ fn fnDeclInner(
42954295 _ = try cc_gz.addBreak(.break_inline, @enumFromInt(0), inst);
42964296 break :blk inst;
42974297 } else if (has_inline_keyword) {
4298 const inst = try cc_gz.addBuiltinValue(decl_node, .calling_convention_inline);
4298 const inst = try cc_gz.addStdLangValue(decl_node, .calling_convention_inline);
42994299 _ = try cc_gz.addBreak(.break_inline, @enumFromInt(0), inst);
43004300 break :blk inst;
43014301 } else {
......@@ -4493,7 +4493,7 @@ fn globalVarDecl(
44934493 defer addrspace_gz.unstack();
44944494
44954495 if (var_decl.ast.addrspace_node.unwrap()) |addrspace_node| {
4496 const addrspace_ty = try addrspace_gz.addBuiltinValue(addrspace_node, .address_space);
4496 const addrspace_ty = try addrspace_gz.addStdLangValue(addrspace_node, .address_space);
44974497 const addrspace_inst = try expr(&addrspace_gz, &addrspace_gz.base, .{ .rl = .{ .coerced_ty = addrspace_ty } }, addrspace_node);
44984498 _ = try addrspace_gz.addBreakWithSrcNode(.break_inline, decl_inst, addrspace_inst, node);
44994499 }
......@@ -8650,7 +8650,7 @@ fn asmExpr(
86508650
86518651 const clobbers: Zir.Inst.Ref = if (full.ast.clobbers.unwrap()) |clobbers_node|
86528652 try comptimeExpr(gz, scope, .{ .rl = .{
8653 .coerced_ty = try gz.addBuiltinValue(clobbers_node, .clobbers),
8653 .coerced_ty = try gz.addStdLangValue(clobbers_node, .clobbers),
86548654 } }, clobbers_node, .clobber)
86558655 else
86568656 .none;
......@@ -8992,7 +8992,7 @@ fn builtinCall(
89928992 if (!allow_branch_hint) {
89938993 return astgen.failNode(node, "'@branchHint' must appear as the first statement in a function or conditional branch", .{});
89948994 }
8995 const hint_ty = try gz.addBuiltinValue(node, .branch_hint);
8995 const hint_ty = try gz.addStdLangValue(node, .branch_hint);
89968996 const hint_val = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = hint_ty } }, params[0], .operand_branchHint);
89978997 _ = try gz.addExtendedPayload(.branch_hint, Zir.Inst.UnNode{
89988998 .node = gz.nodeIndexToRelative(node),
......@@ -9090,7 +9090,7 @@ fn builtinCall(
90909090
90919091 .@"export" => {
90929092 const exported = try expr(gz, scope, .{ .rl = .none }, params[0]);
9093 const export_options_ty = try gz.addBuiltinValue(node, .export_options);
9093 const export_options_ty = try gz.addStdLangValue(node, .export_options);
90949094 const options = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = export_options_ty } }, params[1], .export_options);
90959095 _ = try gz.addPlNode(.@"export", node, Zir.Inst.Export{
90969096 .exported = exported,
......@@ -9100,7 +9100,7 @@ fn builtinCall(
91009100 },
91019101 .@"extern" => {
91029102 const type_inst = try typeExpr(gz, scope, params[0]);
9103 const extern_options_ty = try gz.addBuiltinValue(node, .extern_options);
9103 const extern_options_ty = try gz.addStdLangValue(node, .extern_options);
91049104 const options = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = extern_options_ty } }, params[1], .extern_options);
91059105 const result = try gz.addExtendedPayload(.builtin_extern, Zir.Inst.BinNode{
91069106 .node = gz.nodeIndexToRelative(node),
......@@ -9110,7 +9110,7 @@ fn builtinCall(
91109110 return rvalue(gz, ri, result, node);
91119111 },
91129112 .set_float_mode => {
9113 const float_mode_ty = try gz.addBuiltinValue(node, .float_mode);
9113 const float_mode_ty = try gz.addStdLangValue(node, .float_mode);
91149114 const order = try expr(gz, scope, .{ .rl = .{ .coerced_ty = float_mode_ty } }, params[0]);
91159115 _ = try gz.addExtendedPayload(.set_float_mode, Zir.Inst.UnNode{
91169116 .node = gz.nodeIndexToRelative(node),
......@@ -9196,7 +9196,7 @@ fn builtinCall(
91969196
91979197 .EnumLiteral => return rvalue(gz, ri, .enum_literal_type, node),
91989198 .Int => {
9199 const signedness_ty = try gz.addBuiltinValue(node, .signedness);
9199 const signedness_ty = try gz.addStdLangValue(node, .signedness);
92009200 const result = try gz.addPlNode(.reify_int, node, Zir.Inst.Bin{
92019201 .lhs = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = signedness_ty } }, params[0], .int_signedness),
92029202 .rhs = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = .u16_type } }, params[1], .int_bit_width),
......@@ -9211,8 +9211,8 @@ fn builtinCall(
92119211 return rvalue(gz, ri, result, node);
92129212 },
92139213 .Pointer => {
9214 const ptr_size_ty = try gz.addBuiltinValue(node, .pointer_size);
9215 const ptr_attrs_ty = try gz.addBuiltinValue(node, .pointer_attributes);
9214 const ptr_size_ty = try gz.addStdLangValue(node, .pointer_size);
9215 const ptr_attrs_ty = try gz.addStdLangValue(node, .pointer_attributes);
92169216 const size = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = ptr_size_ty } }, params[0], .pointer_size);
92179217 const attrs = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = ptr_attrs_ty } }, params[1], .pointer_attrs);
92189218 const elem_ty = try typeExpr(gz, scope, params[2]);
......@@ -9231,7 +9231,7 @@ fn builtinCall(
92319231 return rvalue(gz, ri, result, node);
92329232 },
92339233 .Fn => {
9234 const fn_attrs_ty = try gz.addBuiltinValue(node, .fn_attributes);
9234 const fn_attrs_ty = try gz.addStdLangValue(node, .fn_attributes);
92359235 const param_types = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = .slice_const_type_type } }, params[0], .fn_param_types);
92369236 const param_attrs_ty = try gz.addExtendedPayloadSmall(
92379237 .reify_slice_arg_ty,
......@@ -9251,7 +9251,7 @@ fn builtinCall(
92519251 return rvalue(gz, ri, result, node);
92529252 },
92539253 .Struct => {
9254 const container_layout_ty = try gz.addBuiltinValue(node, .container_layout);
9254 const container_layout_ty = try gz.addStdLangValue(node, .container_layout);
92559255 const layout = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = container_layout_ty } }, params[0], .struct_layout);
92569256 const backing_ty = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = .optional_type_type } }, params[1], .type);
92579257 const field_names = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = .slice_const_slice_const_u8_type } }, params[2], .struct_field_names);
......@@ -9279,7 +9279,7 @@ fn builtinCall(
92799279 return rvalue(gz, ri, result, node);
92809280 },
92819281 .Union => {
9282 const container_layout_ty = try gz.addBuiltinValue(node, .container_layout);
9282 const container_layout_ty = try gz.addStdLangValue(node, .container_layout);
92839283 const layout = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = container_layout_ty } }, params[0], .union_layout);
92849284 const arg_ty = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = .optional_type_type } }, params[1], .type);
92859285 const field_names = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = .slice_const_slice_const_u8_type } }, params[2], .union_field_names);
......@@ -9307,7 +9307,7 @@ fn builtinCall(
93079307 return rvalue(gz, ri, result, node);
93089308 },
93099309 .Enum => {
9310 const enum_mode_ty = try gz.addBuiltinValue(node, .enum_mode);
9310 const enum_mode_ty = try gz.addStdLangValue(node, .enum_mode);
93119311 const tag_ty = try typeExpr(gz, scope, params[0]);
93129312 const mode = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = enum_mode_ty } }, params[1], .type);
93139313 const field_names = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = .slice_const_slice_const_u8_type } }, params[2], .enum_field_names);
......@@ -9425,7 +9425,7 @@ fn builtinCall(
94259425 return rvalue(gz, ri, result, node);
94269426 },
94279427 .reduce => {
9428 const reduce_op_ty = try gz.addBuiltinValue(node, .reduce_op);
9428 const reduce_op_ty = try gz.addStdLangValue(node, .reduce_op);
94299429 const op = try expr(gz, scope, .{ .rl = .{ .coerced_ty = reduce_op_ty } }, params[0]);
94309430 const scalar = try expr(gz, scope, .{ .rl = .none }, params[1]);
94319431 const result = try gz.addPlNode(.reduce, node, Zir.Inst.Bin{
......@@ -9441,7 +9441,7 @@ fn builtinCall(
94419441 .shl_with_overflow => return overflowArithmetic(gz, scope, ri, node, params, .shl_with_overflow),
94429442
94439443 .atomic_load => {
9444 const atomic_order_type = try gz.addBuiltinValue(node, .atomic_order);
9444 const atomic_order_type = try gz.addStdLangValue(node, .atomic_order);
94459445 const result = try gz.addPlNode(.atomic_load, node, Zir.Inst.AtomicLoad{
94469446 // zig fmt: off
94479447 .elem_type = try typeExpr(gz, scope, params[0]),
......@@ -9452,8 +9452,8 @@ fn builtinCall(
94529452 return rvalue(gz, ri, result, node);
94539453 },
94549454 .atomic_rmw => {
9455 const atomic_order_type = try gz.addBuiltinValue(node, .atomic_order);
9456 const atomic_rmw_op_type = try gz.addBuiltinValue(node, .atomic_rmw_op);
9455 const atomic_order_type = try gz.addStdLangValue(node, .atomic_order);
9456 const atomic_rmw_op_type = try gz.addStdLangValue(node, .atomic_rmw_op);
94579457 const int_type = try typeExpr(gz, scope, params[0]);
94589458 const result = try gz.addPlNode(.atomic_rmw, node, Zir.Inst.AtomicRmw{
94599459 // zig fmt: off
......@@ -9466,7 +9466,7 @@ fn builtinCall(
94669466 return rvalue(gz, ri, result, node);
94679467 },
94689468 .atomic_store => {
9469 const atomic_order_type = try gz.addBuiltinValue(node, .atomic_order);
9469 const atomic_order_type = try gz.addStdLangValue(node, .atomic_order);
94709470 const int_type = try typeExpr(gz, scope, params[0]);
94719471 _ = try gz.addPlNode(.atomic_store, node, Zir.Inst.AtomicStore{
94729472 // zig fmt: off
......@@ -9490,7 +9490,7 @@ fn builtinCall(
94909490 return rvalue(gz, ri, result, node);
94919491 },
94929492 .call => {
9493 const call_modifier_ty = try gz.addBuiltinValue(node, .call_modifier);
9493 const call_modifier_ty = try gz.addStdLangValue(node, .call_modifier);
94949494 const modifier = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = call_modifier_ty } }, params[0], .call_modifier);
94959495 const callee = try expr(gz, scope, .{ .rl = .none }, params[1]);
94969496 const args = try expr(gz, scope, .{ .rl = .none }, params[2]);
......@@ -9567,7 +9567,7 @@ fn builtinCall(
95679567 return rvalue(gz, ri, result, node);
95689568 },
95699569 .prefetch => {
9570 const prefetch_options_ty = try gz.addBuiltinValue(node, .prefetch_options);
9570 const prefetch_options_ty = try gz.addStdLangValue(node, .prefetch_options);
95719571 const ptr = try expr(gz, scope, .{ .rl = .none }, params[0]);
95729572 const options = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = prefetch_options_ty } }, params[1], .prefetch_options);
95739573 _ = try gz.addExtendedPayload(.prefetch, Zir.Inst.BinNode{
......@@ -9800,7 +9800,7 @@ fn cmpxchg(
98009800 small: u16,
98019801) InnerError!Zir.Inst.Ref {
98029802 const int_type = try typeExpr(gz, scope, params[0]);
9803 const atomic_order_type = try gz.addBuiltinValue(node, .atomic_order);
9803 const atomic_order_type = try gz.addStdLangValue(node, .atomic_order);
98049804 const result = try gz.addExtendedPayloadSmall(.cmpxchg, small, Zir.Inst.Cmpxchg{
98059805 // zig fmt: off
98069806 .node = gz.nodeIndexToRelative(node),
......@@ -11801,8 +11801,8 @@ const GenZir = struct {
1180111801 return new_index;
1180211802 }
1180311803
11804 fn addBuiltinValue(gz: *GenZir, src_node: Ast.Node.Index, val: Zir.Inst.BuiltinValue) !Zir.Inst.Ref {
11805 return addExtendedNodeSmall(gz, .builtin_value, src_node, @intFromEnum(val));
11804 fn addStdLangValue(gz: *GenZir, src_node: Ast.Node.Index, val: Zir.Inst.StdLangValue) !Zir.Inst.Ref {
11805 return addExtendedNodeSmall(gz, .std_lang_value, src_node, @intFromEnum(val));
1180611806 }
1180711807
1180811808 fn addExtendedPayload(gz: *GenZir, opcode: Zir.Inst.Extended, extra: anytype) !Zir.Inst.Ref {
lib/std/zig/Zir.zig+5-5
......@@ -2119,10 +2119,10 @@ pub const Inst = struct {
21192119 /// Guaranteed to not have the `ptr_cast` flag.
21202120 /// Uses the `pl_node` union field with payload `FieldParentPtr`.
21212121 field_parent_ptr,
2122 /// Get a type or value from `std.builtin`.
2122 /// Get a type or value from `std.lang`.
21232123 /// `operand` is `src_node: Ast.Node.Offset`.
2124 /// `small` is an `Inst.BuiltinValue`.
2125 builtin_value,
2124 /// `small` is an `Inst.StdLangValue`.
2125 std_lang_value,
21262126 /// Provide a `@branchHint` for the current block.
21272127 /// `operand` is payload index to `UnNode`.
21282128 /// `small` is unused.
......@@ -3564,7 +3564,7 @@ pub const Inst = struct {
35643564 }
35653565 };
35663566
3567 pub const BuiltinValue = enum(u16) {
3567 pub const StdLangValue = enum(u16) {
35683568 // Types
35693569 atomic_order,
35703570 atomic_rmw_op,
......@@ -4368,7 +4368,7 @@ fn findTrackableInner(
43684368 .restore_err_ret_index,
43694369 .closure_get,
43704370 .field_parent_ptr,
4371 .builtin_value,
4371 .std_lang_value,
43724372 .branch_hint,
43734373 .inplace_arith_result_ty,
43744374 .tuple_decl,
src/Air.zig+1-1
......@@ -1481,7 +1481,7 @@ pub const Asm = struct {
14811481 /// Length of the assembly source in bytes.
14821482 source_len: u32,
14831483 inputs_len: u32,
1484 /// A comptime `std.builtin.assembly.Clobbers` value for the target architecture.
1484 /// A comptime `std.lang.assembly.Clobbers` value for the target architecture.
14851485 clobbers: InternPool.Index,
14861486 flags: Flags,
14871487
src/Air/Legalize.zig+1-1
......@@ -2644,7 +2644,7 @@ const Block = struct {
26442644 });
26452645 return;
26462646 }
2647 const panic_fn_val = zcu.builtin_decl_values.get(panic_id.toBuiltin());
2647 const panic_fn_val = zcu.std_lang_decl_values.get(panic_id.toStdLangDecl());
26482648 _ = b.add(l, .{
26492649 .tag = .call,
26502650 .data = .{ .pl_op = .{
src/Builtin.zig+8-8
......@@ -57,11 +57,11 @@ pub fn append(opts: @This(), buffer: *std.array_list.Managed(u8)) Allocator.Erro
5757 \\/// feature detection (i.e. with `@hasDecl` or `@hasField`) over version checks.
5858 \\pub const zig_version = std.SemanticVersion.parse(zig_version_string) catch unreachable;
5959 \\pub const zig_version_string = "{s}";
60 \\pub const zig_backend = std.builtin.CompilerBackend.{f};
60 \\pub const zig_backend = std.lang.CompilerBackend.{f};
6161 \\
62 \\pub const output_mode: std.builtin.OutputMode = .{f};
63 \\pub const link_mode: std.builtin.LinkMode = .{f};
64 \\pub const unwind_tables: std.builtin.UnwindTables = .{f};
62 \\pub const output_mode: std.lang.OutputMode = .{f};
63 \\pub const link_mode: std.lang.LinkMode = .{f};
64 \\pub const unwind_tables: std.lang.UnwindTables = .{f};
6565 \\pub const is_test = {};
6666 \\pub const single_threaded = {};
6767 \\pub const abi: std.Target.Abi = .{f};
......@@ -239,7 +239,7 @@ pub fn append(opts: @This(), buffer: *std.array_list.Managed(u8)) Allocator.Erro
239239
240240 try buffer.print(
241241 \\pub const object_format: std.Target.ObjectFormat = .{f};
242 \\pub const mode: std.builtin.OptimizeMode = .{f};
242 \\pub const mode: std.lang.OptimizeMode = .{f};
243243 \\pub const link_libc = {};
244244 \\pub const link_libcpp = {};
245245 \\pub const have_error_return_tracing = {};
......@@ -249,7 +249,7 @@ pub fn append(opts: @This(), buffer: *std.array_list.Managed(u8)) Allocator.Erro
249249 \\pub const position_independent_code = {};
250250 \\pub const position_independent_executable = {};
251251 \\pub const strip_debug_info = {};
252 \\pub const code_model: std.builtin.CodeModel = .{f};
252 \\pub const code_model: std.lang.CodeModel = .{f};
253253 \\pub const omit_frame_pointer = {};
254254 \\
255255 , .{
......@@ -270,14 +270,14 @@ pub fn append(opts: @This(), buffer: *std.array_list.Managed(u8)) Allocator.Erro
270270
271271 if (target.os.tag == .wasi) {
272272 try buffer.print(
273 \\pub const wasi_exec_model: std.builtin.WasiExecModel = .{f};
273 \\pub const wasi_exec_model: std.lang.WasiExecModel = .{f};
274274 \\
275275 , .{std.zig.fmtIdPU(@tagName(opts.wasi_exec_model))});
276276 }
277277
278278 if (opts.is_test) {
279279 try buffer.appendSlice(
280 \\pub var test_functions: []const std.builtin.TestFn = &.{}; // overwritten later
280 \\pub var test_functions: []const std.lang.TestFn = &.{}; // overwritten later
281281 \\
282282 );
283283 }
src/InternPool.zig+3-3
......@@ -486,12 +486,12 @@ pub const AnalUnit = packed struct(u64) {
486486pub const MemoizedStateStage = enum(u32) {
487487 /// Everything other than panics and `VaList`.
488488 main,
489 /// Everything within `std.builtin.Panic`.
489 /// Everything within `std.lang.Panic`.
490490 /// Since the panic handler is user-provided, this must be able to reference the other memoized state.
491491 panic,
492 /// Specifically `std.builtin.VaList`. See `Zcu.BuiltinDecl.stage`.
492 /// Specifically `std.lang.VaList`. See `Zcu.StdLangDecl.stage`.
493493 va_list,
494 /// Everything within `std.builtin.assembly`. See `Zcu.BuiltinDecl.stage`.
494 /// Everything within `std.lang.assembly`. See `Zcu.StdLangDecl.stage`.
495495 assembly,
496496};
497497
src/Sema.zig+136-136
......@@ -1473,7 +1473,7 @@ fn analyzeBodyInner(
14731473 },
14741474 .value_placeholder => unreachable, // never appears in a body
14751475 .field_parent_ptr => try sema.zirFieldParentPtr(block, extended),
1476 .builtin_value => try sema.zirBuiltinValue(block, extended),
1476 .std_lang_value => try sema.zirStdLangValue(block, extended),
14771477 .inplace_arith_result_ty => try sema.zirInplaceArithResultTy(extended),
14781478 .dbg_empty_stmt => {
14791479 try sema.zirDbgEmptyStmt(block, inst);
......@@ -2225,7 +2225,7 @@ pub fn setupErrorReturnTrace(sema: *Sema, block: *Block, last_arg_index: usize)
22252225 const addrs_ptr = try err_trace_block.addTy(.alloc, try pt.singleMutPtrType(addr_arr_ty));
22262226
22272227 // var st: StackTrace = undefined;
2228 const stack_trace_ty = try sema.getBuiltinType(block.nodeOffset(.zero), .StackTrace);
2228 const stack_trace_ty = try sema.getStdLangType(block.nodeOffset(.zero), .StackTrace);
22292229 const st_ptr = try err_trace_block.addTy(.alloc, try pt.singleMutPtrType(stack_trace_ty));
22302230
22312231 // st.instruction_addresses = &addrs;
......@@ -2805,10 +2805,10 @@ fn analyzeValueAsCallconv(
28052805 src: LazySrcLoc,
28062806 val: Value,
28072807) !std.builtin.CallingConvention {
2808 return interpretBuiltinType(sema, block, src, val, std.builtin.CallingConvention);
2808 return interpretStdLangType(sema, block, src, val, std.builtin.CallingConvention);
28092809}
28102810
2811fn interpretBuiltinType(
2811fn interpretStdLangType(
28122812 sema: *Sema,
28132813 block: *Block,
28142814 src: LazySrcLoc,
......@@ -2818,7 +2818,7 @@ fn interpretBuiltinType(
28182818 return val.interpret(T, sema.pt) catch |err| switch (err) {
28192819 error.OutOfMemory => |e| return e,
28202820 error.UndefinedValue => return sema.failWithUseOfUndef(block, src, null),
2821 error.TypeMismatch => @panic("std.builtin is corrupt"),
2821 error.TypeMismatch => @panic("std.lang is corrupt"),
28222822 };
28232823}
28242824
......@@ -5074,7 +5074,7 @@ fn zirPanic(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void
50745074 }
50755075
50765076 try sema.ensureMemoizedStateResolved(src, .panic);
5077 const panic_fn_index = zcu.builtin_decl_values.get(.@"panic.call");
5077 const panic_fn_index = zcu.std_lang_decl_values.get(.@"panic.call");
50785078 const opt_usize_ty = try pt.optionalType(.usize_type);
50795079 const null_ret_addr = Air.internedToRef((try pt.intern(.{ .opt = .{
50805080 .ty = opt_usize_ty.toIntern(),
......@@ -5692,7 +5692,7 @@ fn zirDisableIntrinsics(sema: *Sema) CompileError!void {
56925692fn zirSetFloatMode(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!void {
56935693 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;
56945694 const src = block.builtinCallArgSrc(extra.node, 0);
5695 block.float_mode = try sema.resolveBuiltinEnum(block, src, extra.operand, .FloatMode, .{ .simple = .operand_setFloatMode });
5695 block.float_mode = try sema.resolveStdLangEnum(block, src, extra.operand, .FloatMode, .{ .simple = .operand_setFloatMode });
56965696}
56975697
56985698fn zirSetRuntimeSafety(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
......@@ -6008,10 +6008,10 @@ pub fn analyzeSaveErrRetIndex(sema: *Sema, block: *Block) SemaError!Air.Inst.Ref
60086008
60096009 if (!block.ownerModule().error_tracing) return .none;
60106010
6011 const stack_trace_ty = try sema.getBuiltinType(block.nodeOffset(.zero), .StackTrace);
6011 const stack_trace_ty = try sema.getStdLangType(block.nodeOffset(.zero), .StackTrace);
60126012 const field_name = try zcu.intern_pool.getOrPutString(gpa, io, pt.tid, "index", .no_embedded_nulls);
60136013 const field_index = sema.structFieldIndex(block, stack_trace_ty, field_name, LazySrcLoc.unneeded) catch |err| switch (err) {
6014 error.AnalysisFail => @panic("std.builtin.StackTrace is corrupt"),
6014 error.AnalysisFail => @panic("std.lang.StackTrace is corrupt"),
60156015 error.ComptimeReturn, error.ComptimeBreak => unreachable,
60166016 error.OutOfMemory, error.Canceled => |e| return e,
60176017 };
......@@ -6051,7 +6051,7 @@ fn popErrorReturnTrace(
60516051 // AstGen determined this result does not go to an error-handling expr (try/catch/return etc.), or
60526052 // the result is comptime-known to be a non-error. Either way, pop unconditionally.
60536053
6054 const stack_trace_ty = try sema.getBuiltinType(src, .StackTrace);
6054 const stack_trace_ty = try sema.getStdLangType(src, .StackTrace);
60556055 const ptr_stack_trace_ty = try pt.singleMutPtrType(stack_trace_ty);
60566056 const err_return_trace = try block.addTy(.err_return_trace, ptr_stack_trace_ty);
60576057 const field_name = try zcu.intern_pool.getOrPutString(gpa, io, pt.tid, "index", .no_embedded_nulls);
......@@ -6076,7 +6076,7 @@ fn popErrorReturnTrace(
60766076 defer then_block.instructions.deinit(gpa);
60776077
60786078 // If non-error, then pop the error return trace by restoring the index.
6079 const stack_trace_ty = try sema.getBuiltinType(src, .StackTrace);
6079 const stack_trace_ty = try sema.getStdLangType(src, .StackTrace);
60806080 const ptr_stack_trace_ty = try pt.singleMutPtrType(stack_trace_ty);
60816081 const err_return_trace = try then_block.addTy(.err_return_trace, ptr_stack_trace_ty);
60826082 const field_name = try zcu.intern_pool.getOrPutString(gpa, io, pt.tid, "index", .no_embedded_nulls);
......@@ -6215,7 +6215,7 @@ fn zirCall(
62156215 // If any input is an error-type, we might need to pop any trace it generated. Otherwise, we only
62166216 // need to clean-up our own trace if we were passed to a non-error-handling expression.
62176217 if (input_is_error or (pop_error_return_trace and return_ty.isError(zcu))) {
6218 const stack_trace_ty = try sema.getBuiltinType(call_src, .StackTrace);
6218 const stack_trace_ty = try sema.getStdLangType(call_src, .StackTrace);
62196219 const field_name = try zcu.intern_pool.getOrPutString(gpa, io, pt.tid, "index", .no_embedded_nulls);
62206220 const field_index = try sema.structFieldIndex(block, stack_trace_ty, field_name, call_src);
62216221
......@@ -8377,10 +8377,10 @@ fn zirFunc(
83778377 if (fn_is_exported) {
83788378 break :cc target.cCallingConvention() orelse {
83798379 // This target has no default C calling convention. We sometimes trigger a similar
8380 // error by trying to evaluate `std.builtin.CallingConvention.c`, so for consistency,
8380 // error by trying to evaluate `std.lang.CallingConvention.c`, so for consistency,
83818381 // let's eval that now and just get the transitive error. (It's guaranteed to error
83828382 // because it does the exact `cCallingConvention` call we just did.)
8383 const cc_type = try sema.getBuiltinType(src, .CallingConvention);
8383 const cc_type = try sema.getStdLangType(src, .CallingConvention);
83848384 _ = try sema.namespaceLookupVal(
83858385 block,
83868386 LazySrcLoc.unneeded,
......@@ -8388,7 +8388,7 @@ fn zirFunc(
83888388 try ip.getOrPutString(gpa, io, pt.tid, "c", .no_embedded_nulls),
83898389 );
83908390 // The above should have errored.
8391 @panic("std.builtin is corrupt");
8391 @panic("std.lang is corrupt");
83928392 };
83938393 } else {
83948394 break :cc .auto;
......@@ -12711,7 +12711,7 @@ fn maybeErrorUnwrap(
1271112711 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
1271212712 const msg_inst = sema.resolveInst(inst_data.operand);
1271312713
12714 const panic_fn = try getBuiltin(sema, operand_src, .@"panic.call");
12714 const panic_fn = try getStdLangValue(sema, operand_src, .@"panic.call");
1271512715 const args: [2]Air.Inst.Ref = .{ msg_inst, .null_value };
1271612716 try sema.callBuiltin(block, operand_src, Air.internedToRef(panic_fn), .auto, &args, .@"safety check");
1271712717 return true;
......@@ -15319,7 +15319,7 @@ fn zirAsm(
1531915319 }
1532015320
1532115321 const clobbers_src = block.src(.{ .asm_clobbers = src.offset.node_offset.x });
15322 const clobbers_ty = try sema.getBuiltinType(src, .@"assembly.Clobbers");
15322 const clobbers_ty = try sema.getStdLangType(src, .@"assembly.Clobbers");
1532315323 const clobbers = if (extra.data.clobbers == .none) empty: {
1532415324 break :empty try sema.structInitEmpty(block, clobbers_ty, src, src);
1532515325 } else clobbers: {
......@@ -15930,7 +15930,7 @@ fn zirBuiltinSrc(
1593015930 } });
1593115931 };
1593215932
15933 const src_loc_ty = try sema.getBuiltinType(block.nodeOffset(.zero), .SourceLocation);
15933 const src_loc_ty = try sema.getStdLangType(block.nodeOffset(.zero), .SourceLocation);
1593415934 const fields = .{
1593515935 // module: [:0]const u8,
1593615936 module_name_val,
......@@ -15957,7 +15957,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1595715957 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
1595815958 const src = block.nodeOffset(inst_data.src_node);
1595915959 const ty = try sema.resolveType(block, src, inst_data.operand);
15960 const type_info_ty = try sema.getBuiltinType(src, .Type);
15960 const type_info_ty = try sema.getStdLangType(src, .Type);
1596115961 const type_info_tag_ty = type_info_ty.unionTagType(zcu).?;
1596215962
1596315963 try sema.ensureLayoutResolved(ty, src, .type_info);
......@@ -15979,15 +15979,15 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1597915979 => |type_info_tag| return .fromValue(try pt.unionValue(
1598015980 type_info_ty,
1598115981 Value.uninterpret(type_info_tag, type_info_tag_ty, pt) catch |err| switch (err) {
15982 error.TypeMismatch => @panic("std.builtin is corrupt"),
15982 error.TypeMismatch => @panic("std.lang is corrupt"),
1598315983 error.OutOfMemory => |e| return e,
1598415984 },
1598515985 .void,
1598615986 )),
1598715987
1598815988 .@"fn" => {
15989 const fn_info_ty = try sema.getBuiltinType(src, .@"Type.Fn");
15990 const param_info_ty = try sema.getBuiltinType(src, .@"Type.Fn.Param");
15989 const fn_info_ty = try sema.getStdLangType(src, .@"Type.Fn");
15990 const param_info_ty = try sema.getStdLangType(src, .@"Type.Fn.Param");
1599115991
1599215992 const func_ty_info = zcu.typeToFunc(ty).?;
1599315993 const param_vals = try sema.arena.alloc(InternPool.Index, func_ty_info.param_types.len);
......@@ -16068,9 +16068,9 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1606816068 .val = if (ret_ty_is_generic) .none else func_ty_info.return_type,
1606916069 } });
1607016070
16071 const callconv_ty = try sema.getBuiltinType(src, .CallingConvention);
16071 const callconv_ty = try sema.getStdLangType(src, .CallingConvention);
1607216072 const callconv_val = Value.uninterpret(func_ty_info.cc, callconv_ty, pt) catch |err| switch (err) {
16073 error.TypeMismatch => @panic("std.builtin is corrupt"),
16073 error.TypeMismatch => @panic("std.lang is corrupt"),
1607416074 error.OutOfMemory => |e| return e,
1607516075 };
1607616076
......@@ -16093,8 +16093,8 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1609316093 })));
1609416094 },
1609516095 .int => {
16096 const int_info_ty = try sema.getBuiltinType(src, .@"Type.Int");
16097 const signedness_ty = try sema.getBuiltinType(src, .Signedness);
16096 const int_info_ty = try sema.getStdLangType(src, .@"Type.Int");
16097 const signedness_ty = try sema.getStdLangType(src, .Signedness);
1609816098 const info = ty.intInfo(zcu);
1609916099 const field_values = .{
1610016100 // signedness: Signedness,
......@@ -16109,7 +16109,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1610916109 })));
1611016110 },
1611116111 .float => {
16112 const float_info_ty = try sema.getBuiltinType(src, .@"Type.Float");
16112 const float_info_ty = try sema.getStdLangType(src, .@"Type.Float");
1611316113
1611416114 const field_vals = .{
1611516115 // bits: u16,
......@@ -16135,9 +16135,9 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1613516135 } }));
1613616136 };
1613716137
16138 const addrspace_ty = try sema.getBuiltinType(src, .AddressSpace);
16139 const pointer_ty = try sema.getBuiltinType(src, .@"Type.Pointer");
16140 const ptr_size_ty = try sema.getBuiltinType(src, .@"Type.Pointer.Size");
16138 const addrspace_ty = try sema.getStdLangType(src, .AddressSpace);
16139 const pointer_ty = try sema.getStdLangType(src, .@"Type.Pointer");
16140 const ptr_size_ty = try sema.getStdLangType(src, .@"Type.Pointer.Size");
1614116141
1614216142 const field_values = .{
1614316143 // size: Size,
......@@ -16167,7 +16167,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1616716167 })));
1616816168 },
1616916169 .array => {
16170 const array_field_ty = try sema.getBuiltinType(src, .@"Type.Array");
16170 const array_field_ty = try sema.getStdLangType(src, .@"Type.Array");
1617116171
1617216172 const info = ty.arrayInfo(zcu);
1617316173 const field_values = .{
......@@ -16185,7 +16185,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1618516185 })));
1618616186 },
1618716187 .vector => {
16188 const vector_field_ty = try sema.getBuiltinType(src, .@"Type.Vector");
16188 const vector_field_ty = try sema.getStdLangType(src, .@"Type.Vector");
1618916189
1619016190 const info = ty.arrayInfo(zcu);
1619116191 const field_values = .{
......@@ -16201,7 +16201,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1620116201 })));
1620216202 },
1620316203 .optional => {
16204 const optional_field_ty = try sema.getBuiltinType(src, .@"Type.Optional");
16204 const optional_field_ty = try sema.getStdLangType(src, .@"Type.Optional");
1620516205
1620616206 const field_values = .{
1620716207 // child: type,
......@@ -16215,7 +16215,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1621516215 },
1621616216 .error_set => {
1621716217 // Get the Error type
16218 const error_field_ty = try sema.getBuiltinType(src, .@"Type.Error");
16218 const error_field_ty = try sema.getStdLangType(src, .@"Type.Error");
1621916219
1622016220 // Build our list of Error values
1622116221 // Optional value is only null if anyerror
......@@ -16305,7 +16305,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1630516305 })));
1630616306 },
1630716307 .error_union => {
16308 const error_union_field_ty = try sema.getBuiltinType(src, .@"Type.ErrorUnion");
16308 const error_union_field_ty = try sema.getStdLangType(src, .@"Type.ErrorUnion");
1630916309
1631016310 const field_values = .{
1631116311 // error_set: type,
......@@ -16323,7 +16323,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1632316323 const enum_obj = ip.loadEnumType(ty.toIntern());
1632416324 const is_exhaustive: Value = .makeBool(!enum_obj.nonexhaustive);
1632516325
16326 const enum_field_ty = try sema.getBuiltinType(src, .@"Type.EnumField");
16326 const enum_field_ty = try sema.getStdLangType(src, .@"Type.EnumField");
1632716327
1632816328 const enum_field_vals = try sema.arena.alloc(InternPool.Index, enum_obj.field_names.len);
1632916329 for (enum_field_vals, 0..) |*field_val, tag_index| {
......@@ -16404,7 +16404,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1640416404
1640516405 const decls_val = try sema.typeInfoDecls(src, ip.loadEnumType(ty.toIntern()).namespace.toOptional());
1640616406
16407 const type_enum_ty = try sema.getBuiltinType(src, .@"Type.Enum");
16407 const type_enum_ty = try sema.getStdLangType(src, .@"Type.Enum");
1640816408
1640916409 const field_values = .{
1641016410 // tag_type: type,
......@@ -16423,8 +16423,8 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1642316423 })));
1642416424 },
1642516425 .@"union" => {
16426 const type_union_ty = try sema.getBuiltinType(src, .@"Type.Union");
16427 const union_field_ty = try sema.getBuiltinType(src, .@"Type.UnionField");
16426 const type_union_ty = try sema.getStdLangType(src, .@"Type.Union");
16427 const union_field_ty = try sema.getStdLangType(src, .@"Type.UnionField");
1642816428
1642916429 const union_obj = ip.loadUnionType(ty.toIntern());
1643016430 const enum_obj = ip.loadEnumType(union_obj.enum_tag_type);
......@@ -16524,7 +16524,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1652416524 .val = if (ty.unionTagType(zcu)) |tag_ty| tag_ty.toIntern() else .none,
1652516525 } });
1652616526
16527 const container_layout_ty = try sema.getBuiltinType(src, .@"Type.ContainerLayout");
16527 const container_layout_ty = try sema.getStdLangType(src, .@"Type.ContainerLayout");
1652816528
1652916529 const field_values = .{
1653016530 // layout: ContainerLayout,
......@@ -16544,8 +16544,8 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1654416544 })));
1654516545 },
1654616546 .@"struct" => {
16547 const type_struct_ty = try sema.getBuiltinType(src, .@"Type.Struct");
16548 const struct_field_ty = try sema.getBuiltinType(src, .@"Type.StructField");
16547 const type_struct_ty = try sema.getStdLangType(src, .@"Type.Struct");
16548 const struct_field_ty = try sema.getStdLangType(src, .@"Type.StructField");
1654916549
1655016550 var struct_field_vals: []InternPool.Index = &.{};
1655116551 defer gpa.free(struct_field_vals);
......@@ -16713,7 +16713,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1671316713 } else .none,
1671416714 } });
1671516715
16716 const container_layout_ty = try sema.getBuiltinType(src, .@"Type.ContainerLayout");
16716 const container_layout_ty = try sema.getStdLangType(src, .@"Type.ContainerLayout");
1671716717
1671816718 const layout = ty.containerLayout(zcu);
1671916719
......@@ -16736,7 +16736,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1673616736 })));
1673716737 },
1673816738 .@"opaque" => {
16739 const type_opaque_ty = try sema.getBuiltinType(src, .@"Type.Opaque");
16739 const type_opaque_ty = try sema.getStdLangType(src, .@"Type.Opaque");
1674016740
1674116741 const decls_val = try sema.typeInfoDecls(src, ty.getNamespace(zcu));
1674216742
......@@ -16764,7 +16764,7 @@ fn typeInfoDecls(
1676416764 const zcu = pt.zcu;
1676516765 const gpa = sema.gpa;
1676616766
16767 const declaration_ty = try sema.getBuiltinType(src, .@"Type.Declaration");
16767 const declaration_ty = try sema.getStdLangType(src, .@"Type.Declaration");
1676816768
1676916769 var decl_vals = std.array_list.Managed(InternPool.Index).init(gpa);
1677016770 defer decl_vals.deinit();
......@@ -17714,7 +17714,7 @@ fn maybePushErrorTrace(
1771417714 assert(pt.zcu.intern_pool.funcAnalysisUnordered(sema.owner.unwrap().func).has_error_trace);
1771517715
1771617716 const gpa = sema.gpa;
17717 const return_err_fn = Air.internedToRef(try sema.getBuiltin(src, .returnError));
17717 const return_err_fn = Air.internedToRef(try sema.getStdLangValue(src, .returnError));
1771817718
1771917719 if (!need_check) {
1772017720 try sema.callBuiltin(parent_block, src, return_err_fn, .never_tail, &.{}, .@"error return");
......@@ -19179,7 +19179,7 @@ fn getErrorReturnTrace(sema: *Sema, block: *Block) CompileError!Air.Inst.Ref {
1917919179 const pt = sema.pt;
1918019180 const zcu = pt.zcu;
1918119181 const ip = &zcu.intern_pool;
19182 const stack_trace_ty = try sema.getBuiltinType(block.nodeOffset(.zero), .StackTrace);
19182 const stack_trace_ty = try sema.getStdLangType(block.nodeOffset(.zero), .StackTrace);
1918319183 const ptr_stack_trace_ty = try pt.singleMutPtrType(stack_trace_ty);
1918419184 const opt_ptr_stack_trace_ty = try pt.optionalType(ptr_stack_trace_ty.toIntern());
1918519185
......@@ -19446,7 +19446,7 @@ fn zirReifyInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1944619446 const signedness_src = block.builtinCallArgSrc(inst_data.src_node, 0);
1944719447 const bits_src = block.builtinCallArgSrc(inst_data.src_node, 1);
1944819448 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
19449 const signedness = try sema.resolveBuiltinEnum(block, signedness_src, extra.lhs, .Signedness, .{ .simple = .int_signedness });
19449 const signedness = try sema.resolveStdLangEnum(block, signedness_src, extra.lhs, .Signedness, .{ .simple = .int_signedness });
1945019450 const bits: u16 = @intCast(try sema.resolveInt(block, bits_src, extra.rhs, .u16, .{ .simple = .int_bit_width }));
1945119451 if (bits == 0 and signedness == .signed) {
1945219452 return sema.fail(block, bits_src, "signed integer cannot have bit width 0", .{});
......@@ -19469,11 +19469,11 @@ fn zirReifySliceArgTy(
1946919469
1947019470 const comptime_reason: std.zig.SimpleComptimeReason, const in_scalar_ty: Type, const out_scalar_ty: Type = switch (info) {
1947119471 // zig fmt: off
19472 .type_to_fn_param_attrs => .{ .fn_param_attrs, .type, try sema.getBuiltinType(src, .@"Type.Fn.Param.Attributes") },
19472 .type_to_fn_param_attrs => .{ .fn_param_attrs, .type, try sema.getStdLangType(src, .@"Type.Fn.Param.Attributes") },
1947319473 .string_to_struct_field_type => .{ .struct_field_types, .slice_const_u8, .type },
1947419474 .string_to_union_field_type => .{ .union_field_types, .slice_const_u8, .type },
19475 .string_to_struct_field_attrs => .{ .struct_field_attrs, .slice_const_u8, try sema.getBuiltinType(src, .@"Type.StructField.Attributes") },
19476 .string_to_union_field_attrs => .{ .union_field_attrs, .slice_const_u8, try sema.getBuiltinType(src, .@"Type.UnionField.Attributes") },
19475 .string_to_struct_field_attrs => .{ .struct_field_attrs, .slice_const_u8, try sema.getStdLangType(src, .@"Type.StructField.Attributes") },
19476 .string_to_union_field_attrs => .{ .union_field_attrs, .slice_const_u8, try sema.getStdLangType(src, .@"Type.UnionField.Attributes") },
1947719477 // zig fmt: on
1947819478 };
1947919479
......@@ -19599,18 +19599,18 @@ fn zirReifyPointer(
1959919599 const elem_ty_src = block.builtinCallArgSrc(extra.node, 2);
1960019600 const sentinel_src = block.builtinCallArgSrc(extra.node, 3);
1960119601
19602 const size_ty = try sema.getBuiltinType(size_src, .@"Type.Pointer.Size");
19603 const attrs_ty = try sema.getBuiltinType(attrs_src, .@"Type.Pointer.Attributes");
19602 const size_ty = try sema.getStdLangType(size_src, .@"Type.Pointer.Size");
19603 const attrs_ty = try sema.getStdLangType(attrs_src, .@"Type.Pointer.Attributes");
1960419604
1960519605 const size_uncoerced = sema.resolveInst(extra.size);
1960619606 const size_coerced = try sema.coerce(block, size_ty, size_uncoerced, size_src);
1960719607 const size_val = try sema.resolveConstDefinedValue(block, size_src, size_coerced, .{ .simple = .pointer_size });
19608 const size = try sema.interpretBuiltinType(block, size_src, size_val, std.builtin.Type.Pointer.Size);
19608 const size = try sema.interpretStdLangType(block, size_src, size_val, std.builtin.Type.Pointer.Size);
1960919609
1961019610 const attrs_uncoerced = sema.resolveInst(extra.attrs);
1961119611 const attrs_coerced = try sema.coerce(block, attrs_ty, attrs_uncoerced, attrs_src);
1961219612 const attrs_val = try sema.resolveConstDefinedValue(block, attrs_src, attrs_coerced, .{ .simple = .pointer_attrs });
19613 const attrs = try sema.interpretBuiltinType(block, attrs_src, attrs_val, std.builtin.Type.Pointer.Attributes);
19613 const attrs = try sema.interpretStdLangType(block, attrs_src, attrs_val, std.builtin.Type.Pointer.Attributes);
1961419614
1961519615 const @"align": Alignment = if (attrs.@"align") |bytes| a: {
1961619616 break :a try sema.validateAlign(block, attrs_src, bytes);
......@@ -19687,8 +19687,8 @@ fn zirReifyFn(
1968719687 const ret_ty_src = block.builtinCallArgSrc(extra.node, 2);
1968819688 const fn_attrs_src = block.builtinCallArgSrc(extra.node, 3);
1968919689
19690 const single_param_attrs_ty = try sema.getBuiltinType(param_attrs_src, .@"Type.Fn.Param.Attributes");
19691 const fn_attrs_ty = try sema.getBuiltinType(fn_attrs_src, .@"Type.Fn.Attributes");
19690 const single_param_attrs_ty = try sema.getStdLangType(param_attrs_src, .@"Type.Fn.Param.Attributes");
19691 const fn_attrs_ty = try sema.getStdLangType(fn_attrs_src, .@"Type.Fn.Attributes");
1969219692
1969319693 const param_types_uncoerced = sema.resolveInst(extra.param_types);
1969419694 const param_types_coerced = try sema.coerce(block, .slice_const_type, param_types_uncoerced, param_types_src);
......@@ -19711,13 +19711,13 @@ fn zirReifyFn(
1971119711 const fn_attrs_uncoerced = sema.resolveInst(extra.fn_attrs);
1971219712 const fn_attrs_coerced = try sema.coerce(block, fn_attrs_ty, fn_attrs_uncoerced, fn_attrs_src);
1971319713 const fn_attrs_val = try sema.resolveConstDefinedValue(block, fn_attrs_src, fn_attrs_coerced, .{ .simple = .fn_attrs });
19714 const fn_attrs = try sema.interpretBuiltinType(block, fn_attrs_src, fn_attrs_val, std.builtin.Type.Fn.Attributes);
19714 const fn_attrs = try sema.interpretStdLangType(block, fn_attrs_src, fn_attrs_val, std.builtin.Type.Fn.Attributes);
1971519715
1971619716 var noalias_bits: u32 = 0;
1971719717 const param_types_ip = try sema.arena.alloc(InternPool.Index, @intCast(params_len));
1971819718 for (param_types_ip, 0..@intCast(params_len)) |*param_ty_ip, param_idx| {
1971919719 const param_ty: Type = (try param_types_arr.elemValue(pt, param_idx)).toType();
19720 const param_attrs = try sema.interpretBuiltinType(
19720 const param_attrs = try sema.interpretStdLangType(
1972119721 block,
1972219722 param_attrs_src,
1972319723 try param_attrs_arr.elemValue(pt, param_idx),
......@@ -19825,13 +19825,13 @@ fn zirReifyStruct(
1982519825 } },
1982619826 };
1982719827
19828 const container_layout_ty = try sema.getBuiltinType(layout_src, .@"Type.ContainerLayout");
19829 const single_field_attrs_ty = try sema.getBuiltinType(field_attrs_src, .@"Type.StructField.Attributes");
19828 const container_layout_ty = try sema.getStdLangType(layout_src, .@"Type.ContainerLayout");
19829 const single_field_attrs_ty = try sema.getStdLangType(field_attrs_src, .@"Type.StructField.Attributes");
1983019830
1983119831 const layout_uncoerced = sema.resolveInst(extra.layout);
1983219832 const layout_coerced = try sema.coerce(block, container_layout_ty, layout_uncoerced, layout_src);
1983319833 const layout_val = try sema.resolveConstDefinedValue(block, layout_src, layout_coerced, .{ .simple = .struct_layout });
19834 const layout = try sema.interpretBuiltinType(block, layout_src, layout_val, std.builtin.Type.ContainerLayout);
19834 const layout = try sema.interpretStdLangType(block, layout_src, layout_val, std.builtin.Type.ContainerLayout);
1983519835
1983619836 const backing_int_ty_uncoerced = sema.resolveInst(extra.backing_ty);
1983719837 const backing_int_ty_coerced = try sema.coerce(block, .optional_type, backing_int_ty_uncoerced, backing_ty_src);
......@@ -20105,13 +20105,13 @@ fn zirReifyUnion(
2010520105 } },
2010620106 };
2010720107
20108 const container_layout_ty = try sema.getBuiltinType(layout_src, .@"Type.ContainerLayout");
20109 const single_field_attrs_ty = try sema.getBuiltinType(field_attrs_src, .@"Type.UnionField.Attributes");
20108 const container_layout_ty = try sema.getStdLangType(layout_src, .@"Type.ContainerLayout");
20109 const single_field_attrs_ty = try sema.getStdLangType(field_attrs_src, .@"Type.UnionField.Attributes");
2011020110
2011120111 const layout_uncoerced = sema.resolveInst(extra.layout);
2011220112 const layout_coerced = try sema.coerce(block, container_layout_ty, layout_uncoerced, layout_src);
2011320113 const layout_val = try sema.resolveConstDefinedValue(block, layout_src, layout_coerced, .{ .simple = .union_layout });
20114 const layout = try sema.interpretBuiltinType(block, layout_src, layout_val, std.builtin.Type.ContainerLayout);
20114 const layout = try sema.interpretStdLangType(block, layout_src, layout_val, std.builtin.Type.ContainerLayout);
2011520115
2011620116 const arg_ty_uncoerced = sema.resolveInst(extra.arg_ty);
2011720117 const arg_ty_coerced = try sema.coerce(block, .optional_type, arg_ty_uncoerced, arg_ty_src);
......@@ -20191,7 +20191,7 @@ fn zirReifyUnion(
2019120191 const field_name = try sema.sliceToIpString(block, field_names_src, field_name_val, .{ .simple = .union_field_names });
2019220192 std.hash.autoHash(&hasher, field_name);
2019320193
20194 const field_attrs = try sema.interpretBuiltinType(
20194 const field_attrs = try sema.interpretStdLangType(
2019520195 block,
2019620196 field_attrs_src,
2019720197 try field_attrs_arr.elemValue(pt, field_idx),
......@@ -20240,7 +20240,7 @@ fn zirReifyUnion(
2024020240 wip.field_types.get(ip)[field_idx] = field_ty.toIntern();
2024120241
2024220242 // No source location; first loop checked this is valid.
20243 const field_attrs = try sema.interpretBuiltinType(
20243 const field_attrs = try sema.interpretStdLangType(
2024420244 block,
2024520245 .unneeded,
2024620246 try field_attrs_arr.elemValue(pt, field_idx),
......@@ -20319,7 +20319,7 @@ fn zirReifyEnum(
2031920319 } },
2032020320 };
2032120321
20322 const enum_mode_ty = try sema.getBuiltinType(mode_src, .@"Type.Enum.Mode");
20322 const enum_mode_ty = try sema.getStdLangType(mode_src, .@"Type.Enum.Mode");
2032320323
2032420324 const tag_ty_uncoerced = sema.resolveInst(extra.tag_ty);
2032520325 const tag_ty_coerced = try sema.coerce(block, .type, tag_ty_uncoerced, tag_ty_src);
......@@ -20329,7 +20329,7 @@ fn zirReifyEnum(
2032920329 const mode_uncoerced = sema.resolveInst(extra.mode);
2033020330 const mode_coerced = try sema.coerce(block, enum_mode_ty, mode_uncoerced, mode_src);
2033120331 const mode_val = try sema.resolveConstDefinedValue(block, mode_src, mode_coerced, .{ .simple = .type });
20332 const nonexhaustive = switch (try sema.interpretBuiltinType(block, mode_src, mode_val, std.builtin.Type.Enum.Mode)) {
20332 const nonexhaustive = switch (try sema.interpretStdLangType(block, mode_src, mode_val, std.builtin.Type.Enum.Mode)) {
2033320333 .exhaustive => false,
2033420334 .nonexhaustive => true,
2033520335 };
......@@ -20423,7 +20423,7 @@ fn zirReifyEnum(
2042320423
2042420424fn resolveVaListRef(sema: *Sema, block: *Block, src: LazySrcLoc, zir_ref: Zir.Inst.Ref) CompileError!Air.Inst.Ref {
2042520425 const pt = sema.pt;
20426 const va_list_ty = try sema.getBuiltinType(src, .VaList);
20426 const va_list_ty = try sema.getStdLangType(src, .VaList);
2042720427 const va_list_ptr = try pt.singleMutPtrType(va_list_ty);
2042820428
2042920429 const inst = sema.resolveInst(zir_ref);
......@@ -20462,7 +20462,7 @@ fn zirCVaCopy(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData)
2046220462 const va_list_src = block.builtinCallArgSrc(extra.node, 0);
2046320463
2046420464 const va_list_ref = try sema.resolveVaListRef(block, va_list_src, extra.operand);
20465 const va_list_ty = try sema.getBuiltinType(src, .VaList);
20465 const va_list_ty = try sema.getStdLangType(src, .VaList);
2046620466
2046720467 try sema.requireRuntimeBlock(block, src, null);
2046820468 return block.addTyOp(.c_va_copy, va_list_ty, va_list_ref);
......@@ -20484,7 +20484,7 @@ fn zirCVaStart(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData)
2048420484 const src_node: std.zig.Ast.Node.Offset = @enumFromInt(@as(i32, @bitCast(extended.operand)));
2048520485 const src = block.nodeOffset(src_node);
2048620486
20487 const va_list_ty = try sema.getBuiltinType(src, .VaList);
20487 const va_list_ty = try sema.getStdLangType(src, .VaList);
2048820488 try sema.requireRuntimeBlock(block, src, null);
2048920489 return block.addInst(.{
2049020490 .tag = .c_va_start,
......@@ -22373,7 +22373,7 @@ fn resolveExportOptions(
2237322373 const io = comp.io;
2237422374 const ip = &zcu.intern_pool;
2237522375
22376 const export_options_ty = try sema.getBuiltinType(src, .ExportOptions);
22376 const export_options_ty = try sema.getStdLangType(src, .ExportOptions);
2237722377 const air_ref = sema.resolveInst(zir_ref);
2237822378 const options = try sema.coerce(block, export_options_ty, air_ref, src);
2237922379
......@@ -22387,7 +22387,7 @@ fn resolveExportOptions(
2238722387
2238822388 const linkage_operand = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, io, pt.tid, "linkage", .no_embedded_nulls), linkage_src);
2238922389 const linkage_val = try sema.resolveConstDefinedValue(block, linkage_src, linkage_operand, .{ .simple = .export_options });
22390 const linkage = try sema.interpretBuiltinType(block, linkage_src, linkage_val, std.builtin.GlobalLinkage);
22390 const linkage = try sema.interpretStdLangType(block, linkage_src, linkage_val, std.builtin.GlobalLinkage);
2239122391
2239222392 const section_operand = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, io, pt.tid, "section", .no_embedded_nulls), section_src);
2239322393 const section_opt_val = try sema.resolveConstDefinedValue(block, section_src, section_operand, .{ .simple = .export_options });
......@@ -22398,7 +22398,7 @@ fn resolveExportOptions(
2239822398
2239922399 const visibility_operand = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, io, pt.tid, "visibility", .no_embedded_nulls), visibility_src);
2240022400 const visibility_val = try sema.resolveConstDefinedValue(block, visibility_src, visibility_operand, .{ .simple = .export_options });
22401 const visibility = try sema.interpretBuiltinType(block, visibility_src, visibility_val, std.builtin.SymbolVisibility);
22401 const visibility = try sema.interpretStdLangType(block, visibility_src, visibility_val, std.builtin.SymbolVisibility);
2240222402
2240322403 if (name.len < 1) {
2240422404 return sema.fail(block, name_src, "exported symbol name cannot be empty", .{});
......@@ -22418,19 +22418,19 @@ fn resolveExportOptions(
2241822418 };
2241922419}
2242022420
22421fn resolveBuiltinEnum(
22421fn resolveStdLangEnum(
2242222422 sema: *Sema,
2242322423 block: *Block,
2242422424 src: LazySrcLoc,
2242522425 zir_ref: Zir.Inst.Ref,
22426 comptime name: Zcu.BuiltinDecl,
22426 comptime name: Zcu.StdLangDecl,
2242722427 reason: ComptimeReason,
2242822428) CompileError!@field(std.builtin, @tagName(name)) {
22429 const ty = try sema.getBuiltinType(src, name);
22429 const ty = try sema.getStdLangType(src, name);
2243022430 const air_ref = sema.resolveInst(zir_ref);
2243122431 const coerced = try sema.coerce(block, ty, air_ref, src);
2243222432 const val = try sema.resolveConstDefinedValue(block, src, coerced, reason);
22433 return sema.interpretBuiltinType(block, src, val, @field(std.builtin, @tagName(name)));
22433 return sema.interpretStdLangType(block, src, val, @field(std.builtin, @tagName(name)));
2243422434}
2243522435
2243622436fn resolveAtomicOrder(
......@@ -22440,7 +22440,7 @@ fn resolveAtomicOrder(
2244022440 zir_ref: Zir.Inst.Ref,
2244122441 reason: ComptimeReason,
2244222442) CompileError!std.builtin.AtomicOrder {
22443 return sema.resolveBuiltinEnum(block, src, zir_ref, .AtomicOrder, reason);
22443 return sema.resolveStdLangEnum(block, src, zir_ref, .AtomicOrder, reason);
2244422444}
2244522445
2244622446fn resolveAtomicRmwOp(
......@@ -22449,7 +22449,7 @@ fn resolveAtomicRmwOp(
2244922449 src: LazySrcLoc,
2245022450 zir_ref: Zir.Inst.Ref,
2245122451) CompileError!std.builtin.AtomicRmwOp {
22452 return sema.resolveBuiltinEnum(block, src, zir_ref, .AtomicRmwOp, .{ .simple = .operand_atomicRmw_operation });
22452 return sema.resolveStdLangEnum(block, src, zir_ref, .AtomicRmwOp, .{ .simple = .operand_atomicRmw_operation });
2245322453}
2245422454
2245522455fn zirCmpxchg(
......@@ -22609,7 +22609,7 @@ fn zirReduce(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
2260922609 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
2261022610 const op_src = block.builtinCallArgSrc(inst_data.src_node, 0);
2261122611 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 1);
22612 const operation = try sema.resolveBuiltinEnum(block, op_src, extra.lhs, .ReduceOp, .{ .simple = .operand_reduce_operation });
22612 const operation = try sema.resolveStdLangEnum(block, op_src, extra.lhs, .ReduceOp, .{ .simple = .operand_reduce_operation });
2261322613 const operand = sema.resolveInst(extra.rhs);
2261422614 const operand_ty = sema.typeOf(operand);
2261522615 const pt = sema.pt;
......@@ -23196,11 +23196,11 @@ fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
2319623196 const extra = sema.code.extraData(Zir.Inst.BuiltinCall, inst_data.payload_index).data;
2319723197 const func = sema.resolveInst(extra.callee);
2319823198
23199 const modifier_ty = try sema.getBuiltinType(call_src, .CallModifier);
23199 const modifier_ty = try sema.getStdLangType(call_src, .CallModifier);
2320023200 const air_ref = sema.resolveInst(extra.modifier);
2320123201 const modifier_ref = try sema.coerce(block, modifier_ty, air_ref, modifier_src);
2320223202 const modifier_val = try sema.resolveConstDefinedValue(block, modifier_src, modifier_ref, .{ .simple = .call_modifier });
23203 var modifier = try sema.interpretBuiltinType(block, modifier_src, modifier_val, std.builtin.CallModifier);
23203 var modifier = try sema.interpretStdLangType(block, modifier_src, modifier_val, std.builtin.CallModifier);
2320423204 switch (modifier) {
2320523205 // These can be upgraded to comptime or nosuspend calls.
2320623206 .auto, .never_tail, .no_suspend => {
......@@ -24256,13 +24256,13 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
2425624256 const body = sema.code.bodySlice(extra_index, body_len);
2425724257 extra_index += body.len;
2425824258
24259 const cc_ty = try sema.getBuiltinType(cc_src, .CallingConvention);
24259 const cc_ty = try sema.getStdLangType(cc_src, .CallingConvention);
2426024260 const val = try sema.resolveGenericBody(block, cc_src, body, inst, cc_ty, .{ .simple = .@"callconv" });
2426124261 break :blk try sema.analyzeValueAsCallconv(block, cc_src, val);
2426224262 } else if (extra.data.bits.has_cc_ref) blk: {
2426324263 const cc_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]);
2426424264 extra_index += 1;
24265 const cc_ty = try sema.getBuiltinType(cc_src, .CallingConvention);
24265 const cc_ty = try sema.getStdLangType(cc_src, .CallingConvention);
2426624266 const uncoerced_cc = sema.resolveInst(cc_ref);
2426724267 const coerced_cc = try sema.coerce(block, cc_ty, uncoerced_cc, cc_src);
2426824268 const cc_val = try sema.resolveConstDefinedValue(block, cc_src, coerced_cc, .{ .simple = .@"callconv" });
......@@ -24275,10 +24275,10 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
2427524275 if (zir_decl.linkage == .@"export") {
2427624276 break :cc target.cCallingConvention() orelse {
2427724277 // This target has no default C calling convention. We sometimes trigger a similar
24278 // error by trying to evaluate `std.builtin.CallingConvention.c`, so for consistency,
24278 // error by trying to evaluate `std.lang.CallingConvention.c`, so for consistency,
2427924279 // let's eval that now and just get the transitive error. (It's guaranteed to error
2428024280 // because it does the exact `cCallingConvention` call we just did.)
24281 const cc_type = try sema.getBuiltinType(cc_src, .CallingConvention);
24281 const cc_type = try sema.getStdLangType(cc_src, .CallingConvention);
2428224282 _ = try sema.namespaceLookupVal(
2428324283 block,
2428424284 LazySrcLoc.unneeded,
......@@ -24286,7 +24286,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
2428624286 try ip.getOrPutString(gpa, io, pt.tid, "c", .no_embedded_nulls),
2428724287 );
2428824288 // The above should have errored.
24289 @panic("std.builtin is corrupt");
24289 @panic("std.lang is corrupt");
2429024290 };
2429124291 }
2429224292 }
......@@ -24406,7 +24406,7 @@ fn resolvePrefetchOptions(
2440624406 const io = comp.io;
2440724407 const ip = &zcu.intern_pool;
2440824408
24409 const options_ty = try sema.getBuiltinType(src, .PrefetchOptions);
24409 const options_ty = try sema.getStdLangType(src, .PrefetchOptions);
2441024410 const options = try sema.coerce(block, options_ty, sema.resolveInst(zir_ref), src);
2441124411
2441224412 const rw_src = block.src(.{ .init_field_rw = src.offset.node_offset_builtin_call_arg.builtin_call_node });
......@@ -24423,9 +24423,9 @@ fn resolvePrefetchOptions(
2442324423 const cache_val = try sema.resolveConstDefinedValue(block, cache_src, cache, .{ .simple = .prefetch_options });
2442424424
2442524425 return std.builtin.PrefetchOptions{
24426 .rw = try sema.interpretBuiltinType(block, rw_src, rw_val, std.builtin.PrefetchOptions.Rw),
24426 .rw = try sema.interpretStdLangType(block, rw_src, rw_val, std.builtin.PrefetchOptions.Rw),
2442724427 .locality = @intCast(locality_val.toUnsignedInt(zcu)),
24428 .cache = try sema.interpretBuiltinType(block, cache_src, cache_val, std.builtin.PrefetchOptions.Cache),
24428 .cache = try sema.interpretStdLangType(block, cache_src, cache_val, std.builtin.PrefetchOptions.Cache),
2442924429 };
2443024430}
2443124431
......@@ -24480,7 +24480,7 @@ fn resolveExternOptions(
2448024480 const ip = &zcu.intern_pool;
2448124481
2448224482 const options_inst = sema.resolveInst(zir_ref);
24483 const extern_options_ty = try sema.getBuiltinType(src, .ExternOptions);
24483 const extern_options_ty = try sema.getStdLangType(src, .ExternOptions);
2448424484 const options = try sema.coerce(block, extern_options_ty, options_inst, src);
2448524485
2448624486 const name_src = block.src(.{ .init_field_name = src.offset.node_offset_builtin_call_arg.builtin_call_node });
......@@ -24500,11 +24500,11 @@ fn resolveExternOptions(
2450024500
2450124501 const linkage_ref = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, io, pt.tid, "linkage", .no_embedded_nulls), linkage_src);
2450224502 const linkage_val = try sema.resolveConstDefinedValue(block, linkage_src, linkage_ref, .{ .simple = .extern_options });
24503 const linkage = try sema.interpretBuiltinType(block, linkage_src, linkage_val, std.builtin.GlobalLinkage);
24503 const linkage = try sema.interpretStdLangType(block, linkage_src, linkage_val, std.builtin.GlobalLinkage);
2450424504
2450524505 const visibility_ref = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, io, pt.tid, "visibility", .no_embedded_nulls), visibility_src);
2450624506 const visibility_val = try sema.resolveConstDefinedValue(block, visibility_src, visibility_ref, .{ .simple = .extern_options });
24507 const visibility = try sema.interpretBuiltinType(block, visibility_src, visibility_val, std.builtin.SymbolVisibility);
24507 const visibility = try sema.interpretStdLangType(block, visibility_src, visibility_val, std.builtin.SymbolVisibility);
2450824508
2450924509 const is_thread_local = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, io, pt.tid, "is_thread_local", .no_embedded_nulls), thread_local_src);
2451024510 const is_thread_local_val = try sema.resolveConstDefinedValue(block, thread_local_src, is_thread_local, .{ .simple = .extern_options });
......@@ -24523,11 +24523,11 @@ fn resolveExternOptions(
2452324523
2452424524 const relocation_ref = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, io, pt.tid, "relocation", .no_embedded_nulls), relocation_src);
2452524525 const relocation_val = try sema.resolveConstDefinedValue(block, relocation_src, relocation_ref, .{ .simple = .extern_options });
24526 const relocation = try sema.interpretBuiltinType(block, relocation_src, relocation_val, std.builtin.ExternOptions.Relocation);
24526 const relocation = try sema.interpretStdLangType(block, relocation_src, relocation_val, std.builtin.ExternOptions.Relocation);
2452724527
2452824528 const decoration_ref = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, io, pt.tid, "decoration", .no_embedded_nulls), decoration_src);
2452924529 const decoration_val = try sema.resolveConstDefinedValue(block, decoration_src, decoration_ref, .{ .simple = .extern_options });
24530 const decoration = try sema.interpretBuiltinType(block, decoration_src, decoration_val, ?std.builtin.ExternOptions.Decoration);
24530 const decoration = try sema.interpretStdLangType(block, decoration_src, decoration_val, ?std.builtin.ExternOptions.Decoration);
2453124531
2453224532 if (name.len == 0) {
2453324533 return sema.fail(block, name_src, "extern symbol name cannot be empty", .{});
......@@ -24696,7 +24696,7 @@ fn zirInComptime(
2469624696 return if (block.isComptime()) .bool_true else .bool_false;
2469724697}
2469824698
24699fn zirBuiltinValue(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref {
24699fn zirStdLangValue(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref {
2470024700 const pt = sema.pt;
2470124701 const zcu = pt.zcu;
2470224702 const comp = zcu.comp;
......@@ -24706,9 +24706,9 @@ fn zirBuiltinValue(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstD
2470624706
2470724707 const src_node: std.zig.Ast.Node.Offset = @enumFromInt(@as(i32, @bitCast(extended.operand)));
2470824708 const src = block.nodeOffset(src_node);
24709 const value: Zir.Inst.BuiltinValue = @enumFromInt(extended.small);
24709 const value: Zir.Inst.StdLangValue = @enumFromInt(extended.small);
2471024710
24711 const builtin_type: Zcu.BuiltinDecl = switch (value) {
24711 const std_lang_type: Zcu.StdLangDecl = switch (value) {
2471224712 // zig fmt: off
2471324713 .atomic_order => .AtomicOrder,
2471424714 .atomic_rmw_op => .AtomicRmwOp,
......@@ -24732,28 +24732,28 @@ fn zirBuiltinValue(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstD
2473224732
2473324733 // Values are handled here.
2473424734 .calling_convention_c => {
24735 const callconv_ty = try sema.getBuiltinType(src, .CallingConvention);
24735 const callconv_ty = try sema.getStdLangType(src, .CallingConvention);
2473624736 // Cannot use `Value.uninterpret` because `c` is a *declaration* whose value depends on the target.
2473724737 return try sema.namespaceLookupVal(
2473824738 block,
2473924739 src,
2474024740 callconv_ty.getNamespaceIndex(zcu),
2474124741 try ip.getOrPutString(gpa, io, pt.tid, "c", .no_embedded_nulls),
24742 ) orelse @panic("std.builtin is corrupt");
24742 ) orelse @panic("std.lang is corrupt");
2474324743 },
2474424744 .calling_convention_inline => {
24745 const callconv_ty = try sema.getBuiltinType(src, .CallingConvention);
24745 const callconv_ty = try sema.getStdLangType(src, .CallingConvention);
2474624746 return .fromValue(Value.uninterpret(
2474724747 @as(std.builtin.CallingConvention, .@"inline"),
2474824748 callconv_ty,
2474924749 pt,
2475024750 ) catch |err| switch (err) {
24751 error.TypeMismatch => @panic("std.builtin is corrupt"),
24751 error.TypeMismatch => @panic("std.lang is corrupt"),
2475224752 error.OutOfMemory => |e| return e,
2475324753 });
2475424754 },
2475524755 };
24756 return .fromType(try sema.getBuiltinType(src, builtin_type));
24756 return .fromType(try sema.getStdLangType(src, std_lang_type));
2475724757}
2475824758
2475924759fn zirInplaceArithResultTy(sema: *Sema, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref {
......@@ -24788,14 +24788,14 @@ fn zirBranchHint(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstDat
2478824788 const uncoerced_hint = sema.resolveInst(extra.operand);
2478924789 const operand_src = block.builtinCallArgSrc(extra.node, 0);
2479024790
24791 const hint_ty = try sema.getBuiltinType(operand_src, .BranchHint);
24791 const hint_ty = try sema.getStdLangType(operand_src, .BranchHint);
2479224792 const coerced_hint = try sema.coerce(block, hint_ty, uncoerced_hint, operand_src);
2479324793 const hint_val = try sema.resolveConstDefinedValue(block, operand_src, coerced_hint, .{ .simple = .operand_branchHint });
2479424794
2479524795 // We only apply the first hint in a branch.
2479624796 // This allows user-provided hints to override implicit cold hints.
2479724797 if (sema.branch_hint == null) {
24798 sema.branch_hint = try sema.interpretBuiltinType(block, operand_src, hint_val, std.builtin.BranchHint);
24798 sema.branch_hint = try sema.interpretStdLangType(block, operand_src, hint_val, std.builtin.BranchHint);
2479924799 }
2480024800}
2480124801
......@@ -25148,7 +25148,7 @@ fn getPanicIdFunc(sema: *Sema, src: LazySrcLoc, panic_id: Zcu.SimplePanicId) !In
2514825148 const zcu = sema.pt.zcu;
2514925149 const io = zcu.comp.io;
2515025150 try sema.ensureMemoizedStateResolved(src, .panic);
25151 const panic_fn_index = zcu.builtin_decl_values.get(panic_id.toBuiltin());
25151 const panic_fn_index = zcu.std_lang_decl_values.get(panic_id.toStdLangDecl());
2515225152 switch (sema.owner.unwrap()) {
2515325153 .@"comptime",
2515425154 .nav_ty,
......@@ -25292,7 +25292,7 @@ fn safetyPanicUnwrapError(sema: *Sema, block: *Block, src: LazySrcLoc, err: Air.
2529225292 if (!zcu.backendSupportsFeature(.panic_fn)) {
2529325293 _ = try block.addNoOp(.trap);
2529425294 } else {
25295 const panic_fn = try getBuiltin(sema, src, .@"panic.unwrapError");
25295 const panic_fn = try getStdLangValue(sema, src, .@"panic.unwrapError");
2529625296 try sema.callBuiltin(block, src, Air.internedToRef(panic_fn), .auto, &.{err}, .@"safety check");
2529725297 }
2529825298}
......@@ -25382,7 +25382,7 @@ fn addSafetyCheckCall(
2538225382 parent_block: *Block,
2538325383 src: LazySrcLoc,
2538425384 ok: Air.Inst.Ref,
25385 comptime func_decl: Zcu.BuiltinDecl,
25385 comptime func_decl: Zcu.StdLangDecl,
2538625386 args: []const Air.Inst.Ref,
2538725387) !void {
2538825388 assert(!parent_block.isComptime());
......@@ -25406,7 +25406,7 @@ fn addSafetyCheckCall(
2540625406 if (!zcu.backendSupportsFeature(.panic_fn)) {
2540725407 _ = try fail_block.addNoOp(.trap);
2540825408 } else {
25409 const panic_fn = try getBuiltin(sema, src, func_decl);
25409 const panic_fn = try getStdLangValue(sema, src, func_decl);
2541025410 try sema.callBuiltin(&fail_block, src, Air.internedToRef(panic_fn), .auto, args, .@"safety check");
2541125411 }
2541225412
......@@ -33114,10 +33114,10 @@ pub fn analyzeAsAddressSpace(
3311433114 ctx: std.Target.AddressSpaceContext,
3311533115) !std.builtin.AddressSpace {
3311633116 const pt = sema.pt;
33117 const addrspace_ty = try sema.getBuiltinType(src, .AddressSpace);
33117 const addrspace_ty = try sema.getStdLangType(src, .AddressSpace);
3311833118 const coerced = try sema.coerce(block, addrspace_ty, air_ref, src);
3311933119 const addrspace_val = try sema.resolveConstDefinedValue(block, src, coerced, .{ .simple = .@"addrspace" });
33120 const address_space = try sema.interpretBuiltinType(block, src, addrspace_val, std.builtin.AddressSpace);
33120 const address_space = try sema.interpretStdLangType(block, src, addrspace_val, std.builtin.AddressSpace);
3312133121 const target = pt.zcu.getTarget();
3312233122
3312333123 if (!target.supportsAddressSpace(address_space, ctx)) {
......@@ -33819,15 +33819,15 @@ pub const type_resolution = @import("Sema/type_resolution.zig");
3381933819pub const ensureLayoutResolved = type_resolution.ensureLayoutResolved;
3382033820pub const ensureStructDefaultsResolved = type_resolution.ensureStructDefaultsResolved;
3382133821
33822pub fn getBuiltinType(sema: *Sema, src: LazySrcLoc, decl: Zcu.BuiltinDecl) SemaError!Type {
33822pub fn getStdLangType(sema: *Sema, src: LazySrcLoc, decl: Zcu.StdLangDecl) SemaError!Type {
3382333823 assert(decl.kind() == .type);
3382433824 try sema.ensureMemoizedStateResolved(src, decl.stage());
33825 return .fromInterned(sema.pt.zcu.builtin_decl_values.get(decl));
33825 return .fromInterned(sema.pt.zcu.std_lang_decl_values.get(decl));
3382633826}
33827pub fn getBuiltin(sema: *Sema, src: LazySrcLoc, decl: Zcu.BuiltinDecl) SemaError!InternPool.Index {
33827pub fn getStdLangValue(sema: *Sema, src: LazySrcLoc, decl: Zcu.StdLangDecl) SemaError!InternPool.Index {
3382833828 assert(decl.kind() != .type);
3382933829 try sema.ensureMemoizedStateResolved(src, decl.stage());
33830 return sema.pt.zcu.builtin_decl_values.get(decl);
33830 return sema.pt.zcu.std_lang_decl_values.get(decl);
3383133831}
3383233832
3383333833pub const NavPtrModifiers = struct {
......@@ -33928,30 +33928,30 @@ pub fn analyzeMemoizedState(sema: *Sema, stage: InternPool.MemoizedStateStage) C
3392833928 };
3392933929 defer block.instructions.deinit(gpa);
3393033930
33931 const std_builtin_ty: Type = ty: {
33931 const std_lang_ty: Type = ty: {
3393233932 const std_src = block.nodeOffset(.zero);
33933 const decl_name = try ip.getOrPutString(gpa, io, pt.tid, "builtin", .no_embedded_nulls);
33933 const decl_name = try ip.getOrPutString(gpa, io, pt.tid, "lang", .no_embedded_nulls);
3393433934 const nav = try sema.namespaceLookup(&block, std_src, block.namespace, decl_name) orelse {
33935 return sema.fail(&block, std_src, "'std' missing 'builtin'", .{});
33935 return sema.fail(&block, std_src, "'std' missing 'lang'", .{});
3393633936 };
3393733937 const uncoerced_val = try sema.analyzeNavVal(&block, std_src, nav);
3393833938 const decl_src: LazySrcLoc = .{
3393933939 .base_node_inst = ip.getNav(nav).srcInst(ip),
3394033940 .offset = .nodeOffset(.zero),
3394133941 };
33942 break :ty try sema.analyzeAsType(&block, decl_src, .std_builtin_decl, uncoerced_val);
33942 break :ty try sema.analyzeAsType(&block, decl_src, .std_lang_decl, uncoerced_val);
3394333943 };
3394433944
3394533945 var any_changed = false;
3394633946
33947 inline for (comptime std.enums.values(Zcu.BuiltinDecl)) |builtin_decl| {
33948 if (stage == comptime builtin_decl.stage()) {
33949 const parent_ns_ty: Type, const parent_name: []const u8, const name: []const u8 = switch (comptime builtin_decl.access()) {
33950 .direct => |name| .{ std_builtin_ty, "std.builtin", name },
33947 inline for (comptime std.enums.values(Zcu.StdLangDecl)) |std_lang_decl| {
33948 if (stage == comptime std_lang_decl.stage()) {
33949 const parent_ns_ty: Type, const parent_name: []const u8, const name: []const u8 = switch (comptime std_lang_decl.access()) {
33950 .direct => |name| .{ std_lang_ty, "std.lang", name },
3395133951 .nested => |nested| access: {
3395233952 const parent_decl, const name = nested;
33953 const parent_ty: Type = .fromInterned(zcu.builtin_decl_values.get(parent_decl));
33954 break :access .{ parent_ty, "std.builtin." ++ @tagName(parent_decl), name };
33953 const parent_ty: Type = .fromInterned(zcu.std_lang_decl_values.get(parent_decl));
33954 break :access .{ parent_ty, "std.lang." ++ @tagName(parent_decl), name };
3395533955 },
3395633956 };
3395733957
......@@ -33970,25 +33970,25 @@ pub fn analyzeMemoizedState(sema: *Sema, stage: InternPool.MemoizedStateStage) C
3397033970 .offset = .nodeOffset(.zero),
3397133971 };
3397233972
33973 const val: Value = switch (builtin_decl.kind()) {
33973 const val: Value = switch (std_lang_decl.kind()) {
3397433974 .type => val: {
33975 const ty = try sema.analyzeAsType(&block, decl_src, .std_builtin_decl, uncoerced_val);
33976 try sema.ensureLayoutResolved(ty, decl_src, .builtin_type);
33975 const ty = try sema.analyzeAsType(&block, decl_src, .std_lang_decl, uncoerced_val);
33976 try sema.ensureLayoutResolved(ty, decl_src, .std_lang_type);
3397733977 break :val ty.toValue();
3397833978 },
3397933979 .func => val: {
33980 const func_ty = try sema.getExpectedBuiltinFnType(builtin_decl);
33980 const func_ty = try sema.getExpectedBuiltinFnType(std_lang_decl);
3398133981 const coerced = try sema.coerce(&block, func_ty, uncoerced_val, decl_src);
33982 break :val try sema.resolveConstDefinedValue(&block, decl_src, coerced, .{ .simple = .std_builtin_decl });
33982 break :val try sema.resolveConstDefinedValue(&block, decl_src, coerced, .{ .simple = .std_lang_decl });
3398333983 },
3398433984 .string => val: {
3398533985 const coerced = try sema.coerce(&block, .slice_const_u8, uncoerced_val, decl_src);
33986 break :val try sema.resolveConstDefinedValue(&block, decl_src, coerced, .{ .simple = .std_builtin_decl });
33986 break :val try sema.resolveConstDefinedValue(&block, decl_src, coerced, .{ .simple = .std_lang_decl });
3398733987 },
3398833988 };
3398933989
33990 if (zcu.builtin_decl_values.get(builtin_decl) != val.toIntern()) {
33991 zcu.builtin_decl_values.set(builtin_decl, val.toIntern());
33990 if (zcu.std_lang_decl_values.get(std_lang_decl) != val.toIntern()) {
33991 zcu.std_lang_decl_values.set(std_lang_decl, val.toIntern());
3399233992 any_changed = true;
3399333993 }
3399433994 }
......@@ -33998,7 +33998,7 @@ pub fn analyzeMemoizedState(sema: *Sema, stage: InternPool.MemoizedStateStage) C
3399833998}
3399933999
3400034000/// Given that `decl.kind() == .func`, get the type expected of the function.
34001fn getExpectedBuiltinFnType(sema: *Sema, decl: Zcu.BuiltinDecl) CompileError!Type {
34001fn getExpectedBuiltinFnType(sema: *Sema, decl: Zcu.StdLangDecl) CompileError!Type {
3400234002 const pt = sema.pt;
3400334003 return switch (decl) {
3400434004 // `noinline fn () void`
src/Sema/type_resolution.zig+2-2
......@@ -35,7 +35,7 @@ pub const LayoutResolveReason = enum {
3535 @"export",
3636 @"extern",
3737 asm_out_type,
38 builtin_type,
38 std_lang_type,
3939
4040 /// Written after string: "while resolving type 'T' "
4141 /// e.g. "while resolving type 'MyStruct' for variable declared here"
......@@ -62,7 +62,7 @@ pub const LayoutResolveReason = enum {
6262 .@"export" => "for export here",
6363 .@"extern" => "for extern declaration here",
6464 .asm_out_type => "for inline assembly output type declared here",
65 .builtin_type => "from 'std.builtin'",
65 .std_lang_type => "from 'std.lang'",
6666 // zig fmt: on
6767 };
6868 }
src/Value.zig+5-5
......@@ -2199,19 +2199,19 @@ pub fn pointerDerivation(ptr_val: Value, arena: Allocator, pt: Zcu.PerThread, op
21992199const InterpretMode = enum {
22002200 /// In this mode, types are assumed to match what the compiler was built with in terms of field
22012201 /// order, field types, etc. This improves compiler performance. However, it means that certain
2202 /// modifications to `std.builtin` will result in compiler crashes.
2202 /// modifications to `std.lang` will result in compiler crashes.
22032203 direct,
22042204 /// In this mode, various details of the type are allowed to differ from what the compiler was built
22052205 /// with. Fields are matched by name rather than index; added struct fields are ignored, and removed
22062206 /// struct fields use their default value if one exists. This is slower than `.direct`, but permits
2207 /// making certain changes to `std.builtin` (in particular reordering/adding/removing fields), so it
2208 /// is useful when applying breaking changes.
2207 /// making certain changes to `std.lang` (in particular reordering/adding/removing fields), so it is
2208 /// useful when applying breaking changes.
22092209 by_name,
22102210};
22112211const interpret_mode: InterpretMode = @field(InterpretMode, @tagName(build_options.value_interpret_mode));
22122212
22132213/// Given a `Value` representing a comptime-known value of type `T`, unwrap it into an actual `T` known to the compiler.
2214/// This is useful for accessing `std.builtin` structures received from comptime logic.
2214/// This is useful for accessing `std.lang` structures received from comptime logic.
22152215pub fn interpret(val: Value, comptime T: type, pt: Zcu.PerThread) error{ OutOfMemory, UndefinedValue, TypeMismatch }!T {
22162216 const zcu = pt.zcu;
22172217 const io = zcu.comp.io;
......@@ -2313,7 +2313,7 @@ pub fn interpret(val: Value, comptime T: type, pt: Zcu.PerThread) error{ OutOfMe
23132313}
23142314
23152315/// Given any `val` and a `Type` corresponding `@TypeOf(val)`, construct a `Value` representing it which can be used
2316/// within the compilation. This is useful for passing `std.builtin` structures in the compiler back to the compilation.
2316/// within the compilation. This is useful for passing `std.lang` structures in the compiler back to the compilation.
23172317/// This is the inverse of `interpret`.
23182318pub fn uninterpret(val: anytype, ty: Type, pt: Zcu.PerThread) error{ OutOfMemory, TypeMismatch }!Value {
23192319 const T = @TypeOf(val);
src/Zcu.zig+17-17
......@@ -333,7 +333,7 @@ all_type_references: std.ArrayList(TypeReference) = .empty,
333333free_type_references: std.ArrayList(u32) = .empty,
334334
335335/// Populated by analysis of `AnalUnit.wrap(.{ .memoized_state = s })`, where `s` depends on the element.
336builtin_decl_values: BuiltinDecl.Memoized = .initFill(.none),
336std_lang_decl_values: StdLangDecl.Memoized = .initFill(.none),
337337
338338incremental_debug_state: if (build_options.enable_debug_extensions) IncrementalDebugState else void =
339339 if (build_options.enable_debug_extensions) .init else {},
......@@ -425,11 +425,11 @@ pub const EmbedTableAdapter = struct {
425425 }
426426};
427427
428/// Names of declarations in `std.builtin` whose values are memoized in a `BuiltinDecl.Memoized`.
428/// Names of declarations in `std.lang` whose values are memoized in a `StdLangDecl.Memoized`.
429429/// The name must exactly match the declaration name, as comptime logic is used to compute the namespace accesses.
430430/// Parent namespaces must be before their children in this enum. For instance, `.Type` must be before `.@"Type.Fn"`.
431/// Additionally, parent namespaces must be resolved in the same stage as their children; see `BuiltinDecl.stage`.
432pub const BuiltinDecl = enum {
431/// Additionally, parent namespaces must be resolved in the same stage as their children; see `StdLangDecl.stage`.
432pub const StdLangDecl = enum {
433433 Signedness,
434434 AddressSpace,
435435 CallingConvention,
......@@ -508,7 +508,7 @@ pub const BuiltinDecl = enum {
508508 @"assembly.Clobbers",
509509
510510 /// Determines what kind of validation will be done to the decl's value.
511 pub fn kind(decl: BuiltinDecl) enum { type, func, string } {
511 pub fn kind(decl: StdLangDecl) enum { type, func, string } {
512512 return switch (decl) {
513513 .returnError => .func,
514514
......@@ -593,7 +593,7 @@ pub const BuiltinDecl = enum {
593593 }
594594
595595 /// Resolution of these values is done in three distinct stages:
596 /// * Resolution of `std.builtin.Panic` and everything under it
596 /// * Resolution of `std.lang.Panic` and everything under it
597597 /// * Resolution of `VaList`
598598 /// * Resolution of `assembly`
599599 /// * Everything else
......@@ -606,12 +606,12 @@ pub const BuiltinDecl = enum {
606606 /// by itself.
607607 ///
608608 /// `assembly` is separate because its value depends on the target.
609 pub fn stage(decl: BuiltinDecl) InternPool.MemoizedStateStage {
609 pub fn stage(decl: StdLangDecl) InternPool.MemoizedStateStage {
610610 return switch (decl) {
611611 .VaList => .va_list,
612612 .assembly, .@"assembly.Clobbers" => .assembly,
613613 else => {
614 if (@intFromEnum(decl) <= @intFromEnum(BuiltinDecl.@"Type.Declaration")) {
614 if (@intFromEnum(decl) <= @intFromEnum(StdLangDecl.@"Type.Declaration")) {
615615 return .main;
616616 } else {
617617 return .panic;
......@@ -621,24 +621,24 @@ pub const BuiltinDecl = enum {
621621 }
622622
623623 /// Based on the tag name, determines how to access this decl; either as a direct child of the
624 /// `std.builtin` namespace, or as a child of some preceding `BuiltinDecl` value.
625 pub fn access(decl: BuiltinDecl) union(enum) {
624 /// `std.lang` namespace, or as a child of some preceding `StdLangDecl` value.
625 pub fn access(decl: StdLangDecl) union(enum) {
626626 direct: []const u8,
627 nested: struct { BuiltinDecl, []const u8 },
627 nested: struct { StdLangDecl, []const u8 },
628628 } {
629629 @setEvalBranchQuota(2000);
630630 return switch (decl) {
631631 inline else => |tag| {
632632 const name = @tagName(tag);
633633 const split = (comptime std.mem.lastIndexOfScalar(u8, name, '.')) orelse return .{ .direct = name };
634 const parent = @field(BuiltinDecl, name[0..split]);
634 const parent = @field(StdLangDecl, name[0..split]);
635635 comptime assert(@intFromEnum(parent) < @intFromEnum(tag)); // dependencies ordered correctly
636636 return .{ .nested = .{ parent, name[split + 1 ..] } };
637637 },
638638 };
639639 }
640640
641 const Memoized = std.enums.EnumArray(BuiltinDecl, InternPool.Index);
641 const Memoized = std.enums.EnumArray(StdLangDecl, InternPool.Index);
642642};
643643
644644pub const SimplePanicId = enum {
......@@ -662,7 +662,7 @@ pub const SimplePanicId = enum {
662662 memcpy_alias,
663663 noreturn_returned,
664664
665 pub fn toBuiltin(id: SimplePanicId) BuiltinDecl {
665 pub fn toStdLangDecl(id: SimplePanicId) StdLangDecl {
666666 return switch (id) {
667667 // zig fmt: off
668668 .reached_unreachable => .@"panic.reachedUnreachable",
......@@ -3941,7 +3941,7 @@ pub fn addGlobalAssembly(zcu: *Zcu, unit: AnalUnit, source: []const u8) !void {
39413941
39423942pub const Feature = enum {
39433943 /// When this feature is enabled, Sema will emit calls to
3944 /// `std.builtin.panic` functions for things like safety checks and
3944 /// `std.lang.panic` functions for things like safety checks and
39453945 /// unreachables. Otherwise traps will be emitted.
39463946 panic_fn,
39473947 /// When this feature is enabled, Sema will insert tracer functions for gathering a stack
......@@ -4995,7 +4995,7 @@ fn addDependencyLoopErrorLine(
49954995 }),
49964996 .memoized_state => |stage| switch (stage) {
49974997 .panic => try eb.printString("{f} requires panic handler for call here", .{fmt_source}),
4998 else => try eb.printString("{f} requires 'std.builtin' declarations here", .{fmt_source}),
4998 else => try eb.printString("{f} requires 'std.lang' declarations here", .{fmt_source}),
49994999 },
50005000 .func => |func| try eb.printString("{f} uses inferred error set of function '{f}' here", .{
50015001 fmt_source, ip.getNav(zcu.funcInfo(func).owner_nav).fqn.fmt(ip),
......@@ -5046,7 +5046,7 @@ fn formatDependencyLoopSourceUnit(data: FormatAnalUnit, w: *Io.Writer) Io.Writer
50465046 .nav_ty => |nav| try w.print("type of declaration '{f}'", .{ip.getNav(nav).fqn.fmt(ip)}),
50475047 .memoized_state => |stage| switch (stage) {
50485048 .panic => try w.writeAll("panic handler"),
5049 else => try w.writeAll("'std.builtin' declarations"),
5049 else => try w.writeAll("'std.lang' declarations"),
50505050 },
50515051 .type_layout => |ty| try w.print("type '{f}'", .{
50525052 Type.fromInterned(ty).containerTypeName(ip).fmt(ip),
src/Zcu/PerThread.zig+3-3
......@@ -1083,13 +1083,13 @@ pub fn ensureMemoizedStateUpToDate(
10831083 } else {
10841084 if (prev_failed) return error.AnalysisFail;
10851085 // We use an arbitrary element to check if the state has been resolved yet.
1086 const to_check: Zcu.BuiltinDecl = switch (stage) {
1086 const to_check: Zcu.StdLangDecl = switch (stage) {
10871087 .main => .Type,
10881088 .panic => .panic,
10891089 .va_list => .VaList,
10901090 .assembly => .assembly,
10911091 };
1092 if (zcu.builtin_decl_values.get(to_check) != .none) return;
1092 if (zcu.std_lang_decl_values.get(to_check) != .none) return;
10931093 }
10941094
10951095 if (zcu.comp.debugIncremental()) {
......@@ -3751,7 +3751,7 @@ pub fn populateTestFunctions(pt: Zcu.PerThread) Allocator.Error!void {
37513751
37523752 // Our job is to correctly set the value of the `test_functions` declaration if it has been
37533753 // analyzed and sent to codegen, It usually will have been, because the test runner will
3754 // reference it, and `std.builtin` shouldn't have type errors. However, if it hasn't been
3754 // reference it, and `std.lang` shouldn't have type errors. However, if it hasn't been
37553755 // analyzed, we will just terminate early, since clearly the test runner hasn't referenced
37563756 // `test_functions` so there's no point populating it. More to the the point, we potentially
37573757 // *can't* populate it without doing some type resolution, and... let's try to leave Sema in
src/codegen/aarch64/Select.zig+1-1
......@@ -7981,7 +7981,7 @@ fn emit(isel: *Select, instruction: codegen.aarch64.encoding.Instruction) !void
79817981fn emitPanic(isel: *Select, panic_id: Zcu.SimplePanicId) !void {
79827982 const zcu = isel.pt.zcu;
79837983 try isel.nav_relocs.append(zcu.gpa, .{
7984 .nav = switch (zcu.intern_pool.indexToKey(zcu.builtin_decl_values.get(panic_id.toBuiltin()))) {
7984 .nav = switch (zcu.intern_pool.indexToKey(zcu.std_lang_decl_values.get(panic_id.toStdLangDecl()))) {
79857985 else => unreachable,
79867986 inline .@"extern", .func => |func| func.owner_nav,
79877987 },
src/codegen/llvm.zig+2-2
......@@ -1755,7 +1755,7 @@ pub const Object = struct {
17551755 }
17561756
17571757 // If the first export specifies a linksection, set the exported variable's section to that
1758 // one. This is kind of a hack because `std.builtin.ExportOptions.section` doesn't actually
1758 // one. This is kind of a hack because `std.lang.ExportOptions.section` doesn't actually
17591759 // make much sense: the linksection should be associated with the declaration itself rather
17601760 // than some particular symbol it is exported as!
17611761 if (export_indices[0].ptr(zcu).opts.section.toSlice(ip)) |section_slice| {
......@@ -3378,7 +3378,7 @@ pub const Object = struct {
33783378 }
33793379
33803380 if (fn_info.cc == .auto and zcu.comp.config.any_error_tracing) {
3381 // First parameter is a pointer to `std.builtin.StackTrace`.
3381 // First parameter is a pointer to `std.lang.StackTrace`.
33823382 const llvm_ptr_ty = try o.builder.ptrType(toLlvmAddressSpace(.generic, target));
33833383 try llvm_params.append(o.gpa, llvm_ptr_ty);
33843384 }
src/codegen/llvm/FuncGen.zig+1-1
......@@ -891,7 +891,7 @@ fn buildSimplePanic(fg: *FuncGen, panic_id: Zcu.SimplePanicId) Allocator.Error!v
891891 const o = fg.object;
892892 const zcu = o.zcu;
893893 const target = zcu.getTarget();
894 const panic_func = zcu.funcInfo(zcu.builtin_decl_values.get(panic_id.toBuiltin()));
894 const panic_func = zcu.funcInfo(zcu.std_lang_decl_values.get(panic_id.toStdLangDecl()));
895895 const fn_info = zcu.typeToFunc(.fromInterned(panic_func.ty)).?;
896896 const llvm_panic_fn_ty = try o.lowerType(.fromInterned(panic_func.ty));
897897
src/codegen/spirv/CodeGen.zig+1-1
......@@ -2358,7 +2358,7 @@ fn buildWideMul(
23582358/// The SPIR-V backend is not yet advanced enough to support the std testing infrastructure.
23592359/// In order to be able to run tests, we "temporarily" lower test kernels into separate entry-
23602360/// points. The test executor will then be able to invoke these to run the tests.
2361/// Note that tests are lowered according to std.builtin.TestFn, which is `fn () anyerror!void`.
2361/// Note that tests are lowered according to std.lang.TestFn, which is `fn () anyerror!void`.
23622362/// (anyerror!void has the same layout as anyerror).
23632363/// Each test declaration generates a function like.
23642364/// %anyerror = OpTypeInt 0 16
src/codegen/wasm/CodeGen.zig+1-1
......@@ -586,7 +586,7 @@ fn addExtraAssumeCapacity(cg: *CodeGen, extra: anytype) error{OutOfMemory}!u32 {
586586 return result;
587587}
588588
589/// For `std.builtin.CallingConvention.auto`.
589/// For `std.lang.CallingConvention.auto`.
590590pub fn typeToValtype(ty: Type, zcu: *const Zcu, target: *const std.Target) std.wasm.Valtype {
591591 return switch (ty.zigTypeTag(zcu)) {
592592 .float => switch (ty.floatBits(target)) {
src/print_zir.zig+3-3
......@@ -693,7 +693,7 @@ const Writer = struct {
693693 .restore_err_ret_index => try self.writeRestoreErrRetIndex(stream, extended),
694694 .closure_get => try self.writeClosureGet(stream, extended),
695695 .field_parent_ptr => try self.writeFieldParentPtr(stream, extended),
696 .builtin_value => try self.writeBuiltinValue(stream, extended),
696 .std_lang_value => try self.writeStdLangValue(stream, extended),
697697 .inplace_arith_result_ty => try self.writeInplaceArithResultTy(stream, extended),
698698
699699 .dbg_empty_stmt => try stream.writeAll("))"),
......@@ -2232,8 +2232,8 @@ const Writer = struct {
22322232 try self.writeSrcNode(stream, src_node);
22332233 }
22342234
2235 fn writeBuiltinValue(self: *Writer, stream: *std.Io.Writer, extended: Zir.Inst.Extended.InstData) !void {
2236 const val: Zir.Inst.BuiltinValue = @enumFromInt(extended.small);
2235 fn writeStdLangValue(self: *Writer, stream: *std.Io.Writer, extended: Zir.Inst.Extended.InstData) !void {
2236 const val: Zir.Inst.StdLangValue = @enumFromInt(extended.small);
22372237 try stream.print("{s})) ", .{@tagName(val)});
22382238 const src_node: Ast.Node.Offset = @enumFromInt(@as(i32, @bitCast(extended.operand)));
22392239 try self.writeSrcNode(stream, src_node);
test/cases/compile_errors/invalid_member_of_builtin_enum.zig+3-3
......@@ -1,10 +1,10 @@
1const builtin = @import("std").builtin;
1const lang = @import("std").lang;
22export fn entry() void {
3 const foo = builtin.OptimizeMode.x86;
3 const foo = lang.OptimizeMode.x86;
44 _ = foo;
55}
66
77// error
88//
9// :3:38: error: enum 'builtin.OptimizeMode' has no member named 'x86'
9// :3:35: error: enum 'lang.OptimizeMode' has no member named 'x86'
1010// : note: enum declared here
test/cases/compile_errors/issue_15572_break_on_inline_while.zig+1-1
......@@ -16,4 +16,4 @@ pub fn main() void {
1616// error
1717// target=x86_64-linux
1818//
19// :9:28: error: incompatible types: 'builtin.Type.EnumField' and 'void'
19// :9:28: error: incompatible types: 'lang.Type.EnumField' and 'void'
test/cases/compile_errors/runtime_index_into_comptime_type_slice.zig+1-1
......@@ -12,6 +12,6 @@ export fn entry() void {
1212
1313// error
1414//
15// :9:54: error: values of type 'builtin.Type.StructField' must be comptime-known, but index value is runtime-known
15// :9:54: error: values of type 'lang.Type.StructField' must be comptime-known, but index value is runtime-known
1616// : note: struct requires comptime because of this field
1717// : note: types are not available at runtime
test/cases/compile_errors/wrong_type_for_reify_type.zig+3-3
......@@ -16,10 +16,10 @@ export fn entryU() void {
1616
1717// error
1818//
19// :2:14: error: expected type 'builtin.Signedness', found 'comptime_int'
19// :2:14: error: expected type 'lang.Signedness', found 'comptime_int'
2020// :?:?: note: enum declared here
2121// :6:15: error: expected type 'type', found 'comptime_int'
22// :10:17: error: expected type 'builtin.Type.ContainerLayout', found 'comptime_int'
22// :10:17: error: expected type 'lang.Type.ContainerLayout', found 'comptime_int'
2323// :?:?: enum declared here
24// :14:16: error: expected type 'builtin.Type.ContainerLayout', found 'comptime_int'
24// :14:16: error: expected type 'lang.Type.ContainerLayout', found 'comptime_int'
2525// :?:?: enum declared here
test/cases/compile_errors/wrong_types_given_to_atomic_order_args_in_cmpxchg.zig+1-1
......@@ -5,5 +5,5 @@ export fn entry() void {
55
66// error
77//
8// :3:47: error: expected type 'builtin.AtomicOrder', found 'u32'
8// :3:47: error: expected type 'lang.AtomicOrder', found 'u32'
99// :?:?: note: enum declared here
test/cases/compile_errors/wrong_types_given_to_export.zig+1-1
......@@ -5,5 +5,5 @@ comptime {
55
66// error
77//
8// :3:42: error: expected type 'builtin.GlobalLinkage', found 'u32'
8// :3:42: error: expected type 'lang.GlobalLinkage', found 'u32'
99// :?:?: note: enum declared here