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 {...@@ -191,7 +191,7 @@ pub fn build(b: *std.Build) !void {
191 const valgrind = b.option(bool, "valgrind", "Enable valgrind integration");191 const valgrind = b.option(bool, "valgrind", "Enable valgrind integration");
192 const pie = b.option(bool, "pie", "Produce a Position Independent Executable");192 const pie = b.option(bool, "pie", "Produce a Position Independent Executable");
193 const io_mode = b.option(IoMode, "io-mode", "How the compiler performs IO") orelse .threaded;193 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;
195 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;195 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
197 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: {197 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) {...@@ -876,7 +876,7 @@ pub const SimpleComptimeReason = enum(u32) {
876 casted_to_comptime_enum,876 casted_to_comptime_enum,
877 casted_to_comptime_int,877 casted_to_comptime_int,
878 casted_to_comptime_float,878 casted_to_comptime_float,
879 std_builtin_decl,879 std_lang_decl,
880880
881 pub fn message(r: SimpleComptimeReason) []const u8 {881 pub fn message(r: SimpleComptimeReason) []const u8 {
882 return switch (r) {882 return switch (r) {
...@@ -959,7 +959,7 @@ pub const SimpleComptimeReason = enum(u32) {...@@ -959,7 +959,7 @@ pub const SimpleComptimeReason = enum(u32) {
959 .casted_to_comptime_enum => "value casted to enum with 'comptime_int' tag type must be comptime-known",959 .casted_to_comptime_enum => "value casted to enum with 'comptime_int' tag type must be comptime-known",
960 .casted_to_comptime_int => "value casted to 'comptime_int' must be comptime-known",960 .casted_to_comptime_int => "value casted to 'comptime_int' must be comptime-known",
961 .casted_to_comptime_float => "value casted to 'comptime_float' must be comptime-known",961 .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",
963 // zig fmt: on963 // zig fmt: on
964 };964 };
965 }965 }
lib/std/zig/AstGen.zig+29-29
...@@ -1398,12 +1398,12 @@ fn fnProtoExprInner(...@@ -1398,12 +1398,12 @@ fn fnProtoExprInner(
1398 try comptimeExpr(1398 try comptimeExpr(
1399 &block_scope,1399 &block_scope,
1400 scope,1400 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) } },
1402 callconv_expr,1402 callconv_expr,
1403 .@"callconv",1403 .@"callconv",
1404 )1404 )
1405 else if (implicit_ccc)1405 else if (implicit_ccc)
1406 try block_scope.addBuiltinValue(node, .calling_convention_c)1406 try block_scope.addStdLangValue(node, .calling_convention_c)
1407 else1407 else
1408 .none;1408 .none;
14091409
...@@ -3782,7 +3782,7 @@ fn ptrType(...@@ -3782,7 +3782,7 @@ fn ptrType(
3782 gz.astgen.source_line = source_line;3782 gz.astgen.source_line = source_line;
3783 gz.astgen.source_column = source_column;3783 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);
3786 addrspace_ref = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = addrspace_ty } }, addrspace_node, .@"addrspace");3786 addrspace_ref = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = addrspace_ty } }, addrspace_node, .@"addrspace");
3787 trailing_count += 1;3787 trailing_count += 1;
3788 }3788 }
...@@ -4077,7 +4077,7 @@ fn fnDecl(...@@ -4077,7 +4077,7 @@ fn fnDecl(
40774077
4078 if (fn_proto.ast.addrspace_expr.unwrap()) |addrspace_expr| {4078 if (fn_proto.ast.addrspace_expr.unwrap()) |addrspace_expr| {
4079 astgen.restoreSourceCursor(saved_cursor);4079 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);
4081 const inst = try expr(&addrspace_gz, &addrspace_gz.base, .{ .rl = .{ .coerced_ty = addrspace_ty } }, addrspace_expr);4081 const inst = try expr(&addrspace_gz, &addrspace_gz.base, .{ .rl = .{ .coerced_ty = addrspace_ty } }, addrspace_expr);
4082 _ = try addrspace_gz.addBreakWithSrcNode(.break_inline, decl_inst, inst, decl_node);4082 _ = try addrspace_gz.addBreakWithSrcNode(.break_inline, decl_inst, inst, decl_node);
4083 }4083 }
...@@ -4285,7 +4285,7 @@ fn fnDeclInner(...@@ -4285,7 +4285,7 @@ fn fnDeclInner(
4285 const inst = try expr(4285 const inst = try expr(
4286 &cc_gz,4286 &cc_gz,
4287 scope,4287 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) } },
4289 callconv_expr,4289 callconv_expr,
4290 );4290 );
4291 if (cc_gz.instructionsSlice().len == 0) {4291 if (cc_gz.instructionsSlice().len == 0) {
...@@ -4295,7 +4295,7 @@ fn fnDeclInner(...@@ -4295,7 +4295,7 @@ fn fnDeclInner(
4295 _ = try cc_gz.addBreak(.break_inline, @enumFromInt(0), inst);4295 _ = try cc_gz.addBreak(.break_inline, @enumFromInt(0), inst);
4296 break :blk inst;4296 break :blk inst;
4297 } else if (has_inline_keyword) {4297 } 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);
4299 _ = try cc_gz.addBreak(.break_inline, @enumFromInt(0), inst);4299 _ = try cc_gz.addBreak(.break_inline, @enumFromInt(0), inst);
4300 break :blk inst;4300 break :blk inst;
4301 } else {4301 } else {
...@@ -4493,7 +4493,7 @@ fn globalVarDecl(...@@ -4493,7 +4493,7 @@ fn globalVarDecl(
4493 defer addrspace_gz.unstack();4493 defer addrspace_gz.unstack();
44944494
4495 if (var_decl.ast.addrspace_node.unwrap()) |addrspace_node| {4495 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);
4497 const addrspace_inst = try expr(&addrspace_gz, &addrspace_gz.base, .{ .rl = .{ .coerced_ty = addrspace_ty } }, addrspace_node);4497 const addrspace_inst = try expr(&addrspace_gz, &addrspace_gz.base, .{ .rl = .{ .coerced_ty = addrspace_ty } }, addrspace_node);
4498 _ = try addrspace_gz.addBreakWithSrcNode(.break_inline, decl_inst, addrspace_inst, node);4498 _ = try addrspace_gz.addBreakWithSrcNode(.break_inline, decl_inst, addrspace_inst, node);
4499 }4499 }
...@@ -8650,7 +8650,7 @@ fn asmExpr(...@@ -8650,7 +8650,7 @@ fn asmExpr(
86508650
8651 const clobbers: Zir.Inst.Ref = if (full.ast.clobbers.unwrap()) |clobbers_node|8651 const clobbers: Zir.Inst.Ref = if (full.ast.clobbers.unwrap()) |clobbers_node|
8652 try comptimeExpr(gz, scope, .{ .rl = .{8652 try comptimeExpr(gz, scope, .{ .rl = .{
8653 .coerced_ty = try gz.addBuiltinValue(clobbers_node, .clobbers),8653 .coerced_ty = try gz.addStdLangValue(clobbers_node, .clobbers),
8654 } }, clobbers_node, .clobber)8654 } }, clobbers_node, .clobber)
8655 else8655 else
8656 .none;8656 .none;
...@@ -8992,7 +8992,7 @@ fn builtinCall(...@@ -8992,7 +8992,7 @@ fn builtinCall(
8992 if (!allow_branch_hint) {8992 if (!allow_branch_hint) {
8993 return astgen.failNode(node, "'@branchHint' must appear as the first statement in a function or conditional branch", .{});8993 return astgen.failNode(node, "'@branchHint' must appear as the first statement in a function or conditional branch", .{});
8994 }8994 }
8995 const hint_ty = try gz.addBuiltinValue(node, .branch_hint);8995 const hint_ty = try gz.addStdLangValue(node, .branch_hint);
8996 const hint_val = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = hint_ty } }, params[0], .operand_branchHint);8996 const hint_val = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = hint_ty } }, params[0], .operand_branchHint);
8997 _ = try gz.addExtendedPayload(.branch_hint, Zir.Inst.UnNode{8997 _ = try gz.addExtendedPayload(.branch_hint, Zir.Inst.UnNode{
8998 .node = gz.nodeIndexToRelative(node),8998 .node = gz.nodeIndexToRelative(node),
...@@ -9090,7 +9090,7 @@ fn builtinCall(...@@ -9090,7 +9090,7 @@ fn builtinCall(
90909090
9091 .@"export" => {9091 .@"export" => {
9092 const exported = try expr(gz, scope, .{ .rl = .none }, params[0]);9092 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);
9094 const options = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = export_options_ty } }, params[1], .export_options);9094 const options = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = export_options_ty } }, params[1], .export_options);
9095 _ = try gz.addPlNode(.@"export", node, Zir.Inst.Export{9095 _ = try gz.addPlNode(.@"export", node, Zir.Inst.Export{
9096 .exported = exported,9096 .exported = exported,
...@@ -9100,7 +9100,7 @@ fn builtinCall(...@@ -9100,7 +9100,7 @@ fn builtinCall(
9100 },9100 },
9101 .@"extern" => {9101 .@"extern" => {
9102 const type_inst = try typeExpr(gz, scope, params[0]);9102 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);
9104 const options = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = extern_options_ty } }, params[1], .extern_options);9104 const options = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = extern_options_ty } }, params[1], .extern_options);
9105 const result = try gz.addExtendedPayload(.builtin_extern, Zir.Inst.BinNode{9105 const result = try gz.addExtendedPayload(.builtin_extern, Zir.Inst.BinNode{
9106 .node = gz.nodeIndexToRelative(node),9106 .node = gz.nodeIndexToRelative(node),
...@@ -9110,7 +9110,7 @@ fn builtinCall(...@@ -9110,7 +9110,7 @@ fn builtinCall(
9110 return rvalue(gz, ri, result, node);9110 return rvalue(gz, ri, result, node);
9111 },9111 },
9112 .set_float_mode => {9112 .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);
9114 const order = try expr(gz, scope, .{ .rl = .{ .coerced_ty = float_mode_ty } }, params[0]);9114 const order = try expr(gz, scope, .{ .rl = .{ .coerced_ty = float_mode_ty } }, params[0]);
9115 _ = try gz.addExtendedPayload(.set_float_mode, Zir.Inst.UnNode{9115 _ = try gz.addExtendedPayload(.set_float_mode, Zir.Inst.UnNode{
9116 .node = gz.nodeIndexToRelative(node),9116 .node = gz.nodeIndexToRelative(node),
...@@ -9196,7 +9196,7 @@ fn builtinCall(...@@ -9196,7 +9196,7 @@ fn builtinCall(
91969196
9197 .EnumLiteral => return rvalue(gz, ri, .enum_literal_type, node),9197 .EnumLiteral => return rvalue(gz, ri, .enum_literal_type, node),
9198 .Int => {9198 .Int => {
9199 const signedness_ty = try gz.addBuiltinValue(node, .signedness);9199 const signedness_ty = try gz.addStdLangValue(node, .signedness);
9200 const result = try gz.addPlNode(.reify_int, node, Zir.Inst.Bin{9200 const result = try gz.addPlNode(.reify_int, node, Zir.Inst.Bin{
9201 .lhs = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = signedness_ty } }, params[0], .int_signedness),9201 .lhs = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = signedness_ty } }, params[0], .int_signedness),
9202 .rhs = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = .u16_type } }, params[1], .int_bit_width),9202 .rhs = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = .u16_type } }, params[1], .int_bit_width),
...@@ -9211,8 +9211,8 @@ fn builtinCall(...@@ -9211,8 +9211,8 @@ fn builtinCall(
9211 return rvalue(gz, ri, result, node);9211 return rvalue(gz, ri, result, node);
9212 },9212 },
9213 .Pointer => {9213 .Pointer => {
9214 const ptr_size_ty = try gz.addBuiltinValue(node, .pointer_size);9214 const ptr_size_ty = try gz.addStdLangValue(node, .pointer_size);
9215 const ptr_attrs_ty = try gz.addBuiltinValue(node, .pointer_attributes);9215 const ptr_attrs_ty = try gz.addStdLangValue(node, .pointer_attributes);
9216 const size = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = ptr_size_ty } }, params[0], .pointer_size);9216 const size = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = ptr_size_ty } }, params[0], .pointer_size);
9217 const attrs = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = ptr_attrs_ty } }, params[1], .pointer_attrs);9217 const attrs = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = ptr_attrs_ty } }, params[1], .pointer_attrs);
9218 const elem_ty = try typeExpr(gz, scope, params[2]);9218 const elem_ty = try typeExpr(gz, scope, params[2]);
...@@ -9231,7 +9231,7 @@ fn builtinCall(...@@ -9231,7 +9231,7 @@ fn builtinCall(
9231 return rvalue(gz, ri, result, node);9231 return rvalue(gz, ri, result, node);
9232 },9232 },
9233 .Fn => {9233 .Fn => {
9234 const fn_attrs_ty = try gz.addBuiltinValue(node, .fn_attributes);9234 const fn_attrs_ty = try gz.addStdLangValue(node, .fn_attributes);
9235 const param_types = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = .slice_const_type_type } }, params[0], .fn_param_types);9235 const param_types = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = .slice_const_type_type } }, params[0], .fn_param_types);
9236 const param_attrs_ty = try gz.addExtendedPayloadSmall(9236 const param_attrs_ty = try gz.addExtendedPayloadSmall(
9237 .reify_slice_arg_ty,9237 .reify_slice_arg_ty,
...@@ -9251,7 +9251,7 @@ fn builtinCall(...@@ -9251,7 +9251,7 @@ fn builtinCall(
9251 return rvalue(gz, ri, result, node);9251 return rvalue(gz, ri, result, node);
9252 },9252 },
9253 .Struct => {9253 .Struct => {
9254 const container_layout_ty = try gz.addBuiltinValue(node, .container_layout);9254 const container_layout_ty = try gz.addStdLangValue(node, .container_layout);
9255 const layout = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = container_layout_ty } }, params[0], .struct_layout);9255 const layout = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = container_layout_ty } }, params[0], .struct_layout);
9256 const backing_ty = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = .optional_type_type } }, params[1], .type);9256 const backing_ty = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = .optional_type_type } }, params[1], .type);
9257 const field_names = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = .slice_const_slice_const_u8_type } }, params[2], .struct_field_names);9257 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(...@@ -9279,7 +9279,7 @@ fn builtinCall(
9279 return rvalue(gz, ri, result, node);9279 return rvalue(gz, ri, result, node);
9280 },9280 },
9281 .Union => {9281 .Union => {
9282 const container_layout_ty = try gz.addBuiltinValue(node, .container_layout);9282 const container_layout_ty = try gz.addStdLangValue(node, .container_layout);
9283 const layout = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = container_layout_ty } }, params[0], .union_layout);9283 const layout = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = container_layout_ty } }, params[0], .union_layout);
9284 const arg_ty = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = .optional_type_type } }, params[1], .type);9284 const arg_ty = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = .optional_type_type } }, params[1], .type);
9285 const field_names = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = .slice_const_slice_const_u8_type } }, params[2], .union_field_names);9285 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(...@@ -9307,7 +9307,7 @@ fn builtinCall(
9307 return rvalue(gz, ri, result, node);9307 return rvalue(gz, ri, result, node);
9308 },9308 },
9309 .Enum => {9309 .Enum => {
9310 const enum_mode_ty = try gz.addBuiltinValue(node, .enum_mode);9310 const enum_mode_ty = try gz.addStdLangValue(node, .enum_mode);
9311 const tag_ty = try typeExpr(gz, scope, params[0]);9311 const tag_ty = try typeExpr(gz, scope, params[0]);
9312 const mode = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = enum_mode_ty } }, params[1], .type);9312 const mode = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = enum_mode_ty } }, params[1], .type);
9313 const field_names = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = .slice_const_slice_const_u8_type } }, params[2], .enum_field_names);9313 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(...@@ -9425,7 +9425,7 @@ fn builtinCall(
9425 return rvalue(gz, ri, result, node);9425 return rvalue(gz, ri, result, node);
9426 },9426 },
9427 .reduce => {9427 .reduce => {
9428 const reduce_op_ty = try gz.addBuiltinValue(node, .reduce_op);9428 const reduce_op_ty = try gz.addStdLangValue(node, .reduce_op);
9429 const op = try expr(gz, scope, .{ .rl = .{ .coerced_ty = reduce_op_ty } }, params[0]);9429 const op = try expr(gz, scope, .{ .rl = .{ .coerced_ty = reduce_op_ty } }, params[0]);
9430 const scalar = try expr(gz, scope, .{ .rl = .none }, params[1]);9430 const scalar = try expr(gz, scope, .{ .rl = .none }, params[1]);
9431 const result = try gz.addPlNode(.reduce, node, Zir.Inst.Bin{9431 const result = try gz.addPlNode(.reduce, node, Zir.Inst.Bin{
...@@ -9441,7 +9441,7 @@ fn builtinCall(...@@ -9441,7 +9441,7 @@ fn builtinCall(
9441 .shl_with_overflow => return overflowArithmetic(gz, scope, ri, node, params, .shl_with_overflow),9441 .shl_with_overflow => return overflowArithmetic(gz, scope, ri, node, params, .shl_with_overflow),
94429442
9443 .atomic_load => {9443 .atomic_load => {
9444 const atomic_order_type = try gz.addBuiltinValue(node, .atomic_order);9444 const atomic_order_type = try gz.addStdLangValue(node, .atomic_order);
9445 const result = try gz.addPlNode(.atomic_load, node, Zir.Inst.AtomicLoad{9445 const result = try gz.addPlNode(.atomic_load, node, Zir.Inst.AtomicLoad{
9446 // zig fmt: off9446 // zig fmt: off
9447 .elem_type = try typeExpr(gz, scope, params[0]),9447 .elem_type = try typeExpr(gz, scope, params[0]),
...@@ -9452,8 +9452,8 @@ fn builtinCall(...@@ -9452,8 +9452,8 @@ fn builtinCall(
9452 return rvalue(gz, ri, result, node);9452 return rvalue(gz, ri, result, node);
9453 },9453 },
9454 .atomic_rmw => {9454 .atomic_rmw => {
9455 const atomic_order_type = try gz.addBuiltinValue(node, .atomic_order);9455 const atomic_order_type = try gz.addStdLangValue(node, .atomic_order);
9456 const atomic_rmw_op_type = try gz.addBuiltinValue(node, .atomic_rmw_op);9456 const atomic_rmw_op_type = try gz.addStdLangValue(node, .atomic_rmw_op);
9457 const int_type = try typeExpr(gz, scope, params[0]);9457 const int_type = try typeExpr(gz, scope, params[0]);
9458 const result = try gz.addPlNode(.atomic_rmw, node, Zir.Inst.AtomicRmw{9458 const result = try gz.addPlNode(.atomic_rmw, node, Zir.Inst.AtomicRmw{
9459 // zig fmt: off9459 // zig fmt: off
...@@ -9466,7 +9466,7 @@ fn builtinCall(...@@ -9466,7 +9466,7 @@ fn builtinCall(
9466 return rvalue(gz, ri, result, node);9466 return rvalue(gz, ri, result, node);
9467 },9467 },
9468 .atomic_store => {9468 .atomic_store => {
9469 const atomic_order_type = try gz.addBuiltinValue(node, .atomic_order);9469 const atomic_order_type = try gz.addStdLangValue(node, .atomic_order);
9470 const int_type = try typeExpr(gz, scope, params[0]);9470 const int_type = try typeExpr(gz, scope, params[0]);
9471 _ = try gz.addPlNode(.atomic_store, node, Zir.Inst.AtomicStore{9471 _ = try gz.addPlNode(.atomic_store, node, Zir.Inst.AtomicStore{
9472 // zig fmt: off9472 // zig fmt: off
...@@ -9490,7 +9490,7 @@ fn builtinCall(...@@ -9490,7 +9490,7 @@ fn builtinCall(
9490 return rvalue(gz, ri, result, node);9490 return rvalue(gz, ri, result, node);
9491 },9491 },
9492 .call => {9492 .call => {
9493 const call_modifier_ty = try gz.addBuiltinValue(node, .call_modifier);9493 const call_modifier_ty = try gz.addStdLangValue(node, .call_modifier);
9494 const modifier = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = call_modifier_ty } }, params[0], .call_modifier);9494 const modifier = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = call_modifier_ty } }, params[0], .call_modifier);
9495 const callee = try expr(gz, scope, .{ .rl = .none }, params[1]);9495 const callee = try expr(gz, scope, .{ .rl = .none }, params[1]);
9496 const args = try expr(gz, scope, .{ .rl = .none }, params[2]);9496 const args = try expr(gz, scope, .{ .rl = .none }, params[2]);
...@@ -9567,7 +9567,7 @@ fn builtinCall(...@@ -9567,7 +9567,7 @@ fn builtinCall(
9567 return rvalue(gz, ri, result, node);9567 return rvalue(gz, ri, result, node);
9568 },9568 },
9569 .prefetch => {9569 .prefetch => {
9570 const prefetch_options_ty = try gz.addBuiltinValue(node, .prefetch_options);9570 const prefetch_options_ty = try gz.addStdLangValue(node, .prefetch_options);
9571 const ptr = try expr(gz, scope, .{ .rl = .none }, params[0]);9571 const ptr = try expr(gz, scope, .{ .rl = .none }, params[0]);
9572 const options = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = prefetch_options_ty } }, params[1], .prefetch_options);9572 const options = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = prefetch_options_ty } }, params[1], .prefetch_options);
9573 _ = try gz.addExtendedPayload(.prefetch, Zir.Inst.BinNode{9573 _ = try gz.addExtendedPayload(.prefetch, Zir.Inst.BinNode{
...@@ -9800,7 +9800,7 @@ fn cmpxchg(...@@ -9800,7 +9800,7 @@ fn cmpxchg(
9800 small: u16,9800 small: u16,
9801) InnerError!Zir.Inst.Ref {9801) InnerError!Zir.Inst.Ref {
9802 const int_type = try typeExpr(gz, scope, params[0]);9802 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);
9804 const result = try gz.addExtendedPayloadSmall(.cmpxchg, small, Zir.Inst.Cmpxchg{9804 const result = try gz.addExtendedPayloadSmall(.cmpxchg, small, Zir.Inst.Cmpxchg{
9805 // zig fmt: off9805 // zig fmt: off
9806 .node = gz.nodeIndexToRelative(node),9806 .node = gz.nodeIndexToRelative(node),
...@@ -11801,8 +11801,8 @@ const GenZir = struct {...@@ -11801,8 +11801,8 @@ const GenZir = struct {
11801 return new_index;11801 return new_index;
11802 }11802 }
1180311803
11804 fn addBuiltinValue(gz: *GenZir, src_node: Ast.Node.Index, val: Zir.Inst.BuiltinValue) !Zir.Inst.Ref {11804 fn addStdLangValue(gz: *GenZir, src_node: Ast.Node.Index, val: Zir.Inst.StdLangValue) !Zir.Inst.Ref {
11805 return addExtendedNodeSmall(gz, .builtin_value, src_node, @intFromEnum(val));11805 return addExtendedNodeSmall(gz, .std_lang_value, src_node, @intFromEnum(val));
11806 }11806 }
1180711807
11808 fn addExtendedPayload(gz: *GenZir, opcode: Zir.Inst.Extended, extra: anytype) !Zir.Inst.Ref {11808 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 {...@@ -2119,10 +2119,10 @@ pub const Inst = struct {
2119 /// Guaranteed to not have the `ptr_cast` flag.2119 /// Guaranteed to not have the `ptr_cast` flag.
2120 /// Uses the `pl_node` union field with payload `FieldParentPtr`.2120 /// Uses the `pl_node` union field with payload `FieldParentPtr`.
2121 field_parent_ptr,2121 field_parent_ptr,
2122 /// Get a type or value from `std.builtin`.2122 /// Get a type or value from `std.lang`.
2123 /// `operand` is `src_node: Ast.Node.Offset`.2123 /// `operand` is `src_node: Ast.Node.Offset`.
2124 /// `small` is an `Inst.BuiltinValue`.2124 /// `small` is an `Inst.StdLangValue`.
2125 builtin_value,2125 std_lang_value,
2126 /// Provide a `@branchHint` for the current block.2126 /// Provide a `@branchHint` for the current block.
2127 /// `operand` is payload index to `UnNode`.2127 /// `operand` is payload index to `UnNode`.
2128 /// `small` is unused.2128 /// `small` is unused.
...@@ -3564,7 +3564,7 @@ pub const Inst = struct {...@@ -3564,7 +3564,7 @@ pub const Inst = struct {
3564 }3564 }
3565 };3565 };
35663566
3567 pub const BuiltinValue = enum(u16) {3567 pub const StdLangValue = enum(u16) {
3568 // Types3568 // Types
3569 atomic_order,3569 atomic_order,
3570 atomic_rmw_op,3570 atomic_rmw_op,
...@@ -4368,7 +4368,7 @@ fn findTrackableInner(...@@ -4368,7 +4368,7 @@ fn findTrackableInner(
4368 .restore_err_ret_index,4368 .restore_err_ret_index,
4369 .closure_get,4369 .closure_get,
4370 .field_parent_ptr,4370 .field_parent_ptr,
4371 .builtin_value,4371 .std_lang_value,
4372 .branch_hint,4372 .branch_hint,
4373 .inplace_arith_result_ty,4373 .inplace_arith_result_ty,
4374 .tuple_decl,4374 .tuple_decl,
src/Air.zig+1-1
...@@ -1481,7 +1481,7 @@ pub const Asm = struct {...@@ -1481,7 +1481,7 @@ pub const Asm = struct {
1481 /// Length of the assembly source in bytes.1481 /// Length of the assembly source in bytes.
1482 source_len: u32,1482 source_len: u32,
1483 inputs_len: u32,1483 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.
1485 clobbers: InternPool.Index,1485 clobbers: InternPool.Index,
1486 flags: Flags,1486 flags: Flags,
14871487
src/Air/Legalize.zig+1-1
...@@ -2644,7 +2644,7 @@ const Block = struct {...@@ -2644,7 +2644,7 @@ const Block = struct {
2644 });2644 });
2645 return;2645 return;
2646 }2646 }
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());
2648 _ = b.add(l, .{2648 _ = b.add(l, .{
2649 .tag = .call,2649 .tag = .call,
2650 .data = .{ .pl_op = .{2650 .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...@@ -57,11 +57,11 @@ pub fn append(opts: @This(), buffer: *std.array_list.Managed(u8)) Allocator.Erro
57 \\/// feature detection (i.e. with `@hasDecl` or `@hasField`) over version checks.57 \\/// feature detection (i.e. with `@hasDecl` or `@hasField`) over version checks.
58 \\pub const zig_version = std.SemanticVersion.parse(zig_version_string) catch unreachable;58 \\pub const zig_version = std.SemanticVersion.parse(zig_version_string) catch unreachable;
59 \\pub const zig_version_string = "{s}";59 \\pub const zig_version_string = "{s}";
60 \\pub const zig_backend = std.builtin.CompilerBackend.{f};60 \\pub const zig_backend = std.lang.CompilerBackend.{f};
61 \\61 \\
62 \\pub const output_mode: std.builtin.OutputMode = .{f};62 \\pub const output_mode: std.lang.OutputMode = .{f};
63 \\pub const link_mode: std.builtin.LinkMode = .{f};63 \\pub const link_mode: std.lang.LinkMode = .{f};
64 \\pub const unwind_tables: std.builtin.UnwindTables = .{f};64 \\pub const unwind_tables: std.lang.UnwindTables = .{f};
65 \\pub const is_test = {};65 \\pub const is_test = {};
66 \\pub const single_threaded = {};66 \\pub const single_threaded = {};
67 \\pub const abi: std.Target.Abi = .{f};67 \\pub const abi: std.Target.Abi = .{f};
...@@ -239,7 +239,7 @@ pub fn append(opts: @This(), buffer: *std.array_list.Managed(u8)) Allocator.Erro...@@ -239,7 +239,7 @@ pub fn append(opts: @This(), buffer: *std.array_list.Managed(u8)) Allocator.Erro
239239
240 try buffer.print(240 try buffer.print(
241 \\pub const object_format: std.Target.ObjectFormat = .{f};241 \\pub const object_format: std.Target.ObjectFormat = .{f};
242 \\pub const mode: std.builtin.OptimizeMode = .{f};242 \\pub const mode: std.lang.OptimizeMode = .{f};
243 \\pub const link_libc = {};243 \\pub const link_libc = {};
244 \\pub const link_libcpp = {};244 \\pub const link_libcpp = {};
245 \\pub const have_error_return_tracing = {};245 \\pub const have_error_return_tracing = {};
...@@ -249,7 +249,7 @@ pub fn append(opts: @This(), buffer: *std.array_list.Managed(u8)) Allocator.Erro...@@ -249,7 +249,7 @@ pub fn append(opts: @This(), buffer: *std.array_list.Managed(u8)) Allocator.Erro
249 \\pub const position_independent_code = {};249 \\pub const position_independent_code = {};
250 \\pub const position_independent_executable = {};250 \\pub const position_independent_executable = {};
251 \\pub const strip_debug_info = {};251 \\pub const strip_debug_info = {};
252 \\pub const code_model: std.builtin.CodeModel = .{f};252 \\pub const code_model: std.lang.CodeModel = .{f};
253 \\pub const omit_frame_pointer = {};253 \\pub const omit_frame_pointer = {};
254 \\254 \\
255 , .{255 , .{
...@@ -270,14 +270,14 @@ pub fn append(opts: @This(), buffer: *std.array_list.Managed(u8)) Allocator.Erro...@@ -270,14 +270,14 @@ pub fn append(opts: @This(), buffer: *std.array_list.Managed(u8)) Allocator.Erro
270270
271 if (target.os.tag == .wasi) {271 if (target.os.tag == .wasi) {
272 try buffer.print(272 try buffer.print(
273 \\pub const wasi_exec_model: std.builtin.WasiExecModel = .{f};273 \\pub const wasi_exec_model: std.lang.WasiExecModel = .{f};
274 \\274 \\
275 , .{std.zig.fmtIdPU(@tagName(opts.wasi_exec_model))});275 , .{std.zig.fmtIdPU(@tagName(opts.wasi_exec_model))});
276 }276 }
277277
278 if (opts.is_test) {278 if (opts.is_test) {
279 try buffer.appendSlice(279 try buffer.appendSlice(
280 \\pub var test_functions: []const std.builtin.TestFn = &.{}; // overwritten later280 \\pub var test_functions: []const std.lang.TestFn = &.{}; // overwritten later
281 \\281 \\
282 );282 );
283 }283 }
src/InternPool.zig+3-3
...@@ -486,12 +486,12 @@ pub const AnalUnit = packed struct(u64) {...@@ -486,12 +486,12 @@ pub const AnalUnit = packed struct(u64) {
486pub const MemoizedStateStage = enum(u32) {486pub const MemoizedStateStage = enum(u32) {
487 /// Everything other than panics and `VaList`.487 /// Everything other than panics and `VaList`.
488 main,488 main,
489 /// Everything within `std.builtin.Panic`.489 /// Everything within `std.lang.Panic`.
490 /// Since the panic handler is user-provided, this must be able to reference the other memoized state.490 /// Since the panic handler is user-provided, this must be able to reference the other memoized state.
491 panic,491 panic,
492 /// Specifically `std.builtin.VaList`. See `Zcu.BuiltinDecl.stage`.492 /// Specifically `std.lang.VaList`. See `Zcu.StdLangDecl.stage`.
493 va_list,493 va_list,
494 /// Everything within `std.builtin.assembly`. See `Zcu.BuiltinDecl.stage`.494 /// Everything within `std.lang.assembly`. See `Zcu.StdLangDecl.stage`.
495 assembly,495 assembly,
496};496};
497497
src/Sema.zig+136-136
...@@ -1473,7 +1473,7 @@ fn analyzeBodyInner(...@@ -1473,7 +1473,7 @@ fn analyzeBodyInner(
1473 },1473 },
1474 .value_placeholder => unreachable, // never appears in a body1474 .value_placeholder => unreachable, // never appears in a body
1475 .field_parent_ptr => try sema.zirFieldParentPtr(block, extended),1475 .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),
1477 .inplace_arith_result_ty => try sema.zirInplaceArithResultTy(extended),1477 .inplace_arith_result_ty => try sema.zirInplaceArithResultTy(extended),
1478 .dbg_empty_stmt => {1478 .dbg_empty_stmt => {
1479 try sema.zirDbgEmptyStmt(block, inst);1479 try sema.zirDbgEmptyStmt(block, inst);
...@@ -2225,7 +2225,7 @@ pub fn setupErrorReturnTrace(sema: *Sema, block: *Block, last_arg_index: usize)...@@ -2225,7 +2225,7 @@ pub fn setupErrorReturnTrace(sema: *Sema, block: *Block, last_arg_index: usize)
2225 const addrs_ptr = try err_trace_block.addTy(.alloc, try pt.singleMutPtrType(addr_arr_ty));2225 const addrs_ptr = try err_trace_block.addTy(.alloc, try pt.singleMutPtrType(addr_arr_ty));
22262226
2227 // var st: StackTrace = undefined;2227 // 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);
2229 const st_ptr = try err_trace_block.addTy(.alloc, try pt.singleMutPtrType(stack_trace_ty));2229 const st_ptr = try err_trace_block.addTy(.alloc, try pt.singleMutPtrType(stack_trace_ty));
22302230
2231 // st.instruction_addresses = &addrs;2231 // st.instruction_addresses = &addrs;
...@@ -2805,10 +2805,10 @@ fn analyzeValueAsCallconv(...@@ -2805,10 +2805,10 @@ fn analyzeValueAsCallconv(
2805 src: LazySrcLoc,2805 src: LazySrcLoc,
2806 val: Value,2806 val: Value,
2807) !std.builtin.CallingConvention {2807) !std.builtin.CallingConvention {
2808 return interpretBuiltinType(sema, block, src, val, std.builtin.CallingConvention);2808 return interpretStdLangType(sema, block, src, val, std.builtin.CallingConvention);
2809}2809}
28102810
2811fn interpretBuiltinType(2811fn interpretStdLangType(
2812 sema: *Sema,2812 sema: *Sema,
2813 block: *Block,2813 block: *Block,
2814 src: LazySrcLoc,2814 src: LazySrcLoc,
...@@ -2818,7 +2818,7 @@ fn interpretBuiltinType(...@@ -2818,7 +2818,7 @@ fn interpretBuiltinType(
2818 return val.interpret(T, sema.pt) catch |err| switch (err) {2818 return val.interpret(T, sema.pt) catch |err| switch (err) {
2819 error.OutOfMemory => |e| return e,2819 error.OutOfMemory => |e| return e,
2820 error.UndefinedValue => return sema.failWithUseOfUndef(block, src, null),2820 error.UndefinedValue => return sema.failWithUseOfUndef(block, src, null),
2821 error.TypeMismatch => @panic("std.builtin is corrupt"),2821 error.TypeMismatch => @panic("std.lang is corrupt"),
2822 };2822 };
2823}2823}
28242824
...@@ -5074,7 +5074,7 @@ fn zirPanic(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void...@@ -5074,7 +5074,7 @@ fn zirPanic(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void
5074 }5074 }
50755075
5076 try sema.ensureMemoizedStateResolved(src, .panic);5076 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");
5078 const opt_usize_ty = try pt.optionalType(.usize_type);5078 const opt_usize_ty = try pt.optionalType(.usize_type);
5079 const null_ret_addr = Air.internedToRef((try pt.intern(.{ .opt = .{5079 const null_ret_addr = Air.internedToRef((try pt.intern(.{ .opt = .{
5080 .ty = opt_usize_ty.toIntern(),5080 .ty = opt_usize_ty.toIntern(),
...@@ -5692,7 +5692,7 @@ fn zirDisableIntrinsics(sema: *Sema) CompileError!void {...@@ -5692,7 +5692,7 @@ fn zirDisableIntrinsics(sema: *Sema) CompileError!void {
5692fn zirSetFloatMode(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!void {5692fn zirSetFloatMode(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!void {
5693 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;5693 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;
5694 const src = block.builtinCallArgSrc(extra.node, 0);5694 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 });
5696}5696}
56975697
5698fn zirSetRuntimeSafety(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {5698fn 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...@@ -6008,10 +6008,10 @@ pub fn analyzeSaveErrRetIndex(sema: *Sema, block: *Block) SemaError!Air.Inst.Ref
60086008
6009 if (!block.ownerModule().error_tracing) return .none;6009 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);
6012 const field_name = try zcu.intern_pool.getOrPutString(gpa, io, pt.tid, "index", .no_embedded_nulls);6012 const field_name = try zcu.intern_pool.getOrPutString(gpa, io, pt.tid, "index", .no_embedded_nulls);
6013 const field_index = sema.structFieldIndex(block, stack_trace_ty, field_name, LazySrcLoc.unneeded) catch |err| switch (err) {6013 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"),
6015 error.ComptimeReturn, error.ComptimeBreak => unreachable,6015 error.ComptimeReturn, error.ComptimeBreak => unreachable,
6016 error.OutOfMemory, error.Canceled => |e| return e,6016 error.OutOfMemory, error.Canceled => |e| return e,
6017 };6017 };
...@@ -6051,7 +6051,7 @@ fn popErrorReturnTrace(...@@ -6051,7 +6051,7 @@ fn popErrorReturnTrace(
6051 // AstGen determined this result does not go to an error-handling expr (try/catch/return etc.), or6051 // AstGen determined this result does not go to an error-handling expr (try/catch/return etc.), or
6052 // the result is comptime-known to be a non-error. Either way, pop unconditionally.6052 // 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);
6055 const ptr_stack_trace_ty = try pt.singleMutPtrType(stack_trace_ty);6055 const ptr_stack_trace_ty = try pt.singleMutPtrType(stack_trace_ty);
6056 const err_return_trace = try block.addTy(.err_return_trace, ptr_stack_trace_ty);6056 const err_return_trace = try block.addTy(.err_return_trace, ptr_stack_trace_ty);
6057 const field_name = try zcu.intern_pool.getOrPutString(gpa, io, pt.tid, "index", .no_embedded_nulls);6057 const field_name = try zcu.intern_pool.getOrPutString(gpa, io, pt.tid, "index", .no_embedded_nulls);
...@@ -6076,7 +6076,7 @@ fn popErrorReturnTrace(...@@ -6076,7 +6076,7 @@ fn popErrorReturnTrace(
6076 defer then_block.instructions.deinit(gpa);6076 defer then_block.instructions.deinit(gpa);
60776077
6078 // If non-error, then pop the error return trace by restoring the index.6078 // 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);
6080 const ptr_stack_trace_ty = try pt.singleMutPtrType(stack_trace_ty);6080 const ptr_stack_trace_ty = try pt.singleMutPtrType(stack_trace_ty);
6081 const err_return_trace = try then_block.addTy(.err_return_trace, ptr_stack_trace_ty);6081 const err_return_trace = try then_block.addTy(.err_return_trace, ptr_stack_trace_ty);
6082 const field_name = try zcu.intern_pool.getOrPutString(gpa, io, pt.tid, "index", .no_embedded_nulls);6082 const field_name = try zcu.intern_pool.getOrPutString(gpa, io, pt.tid, "index", .no_embedded_nulls);
...@@ -6215,7 +6215,7 @@ fn zirCall(...@@ -6215,7 +6215,7 @@ fn zirCall(
6215 // If any input is an error-type, we might need to pop any trace it generated. Otherwise, we only6215 // If any input is an error-type, we might need to pop any trace it generated. Otherwise, we only
6216 // need to clean-up our own trace if we were passed to a non-error-handling expression.6216 // need to clean-up our own trace if we were passed to a non-error-handling expression.
6217 if (input_is_error or (pop_error_return_trace and return_ty.isError(zcu))) {6217 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);
6219 const field_name = try zcu.intern_pool.getOrPutString(gpa, io, pt.tid, "index", .no_embedded_nulls);6219 const field_name = try zcu.intern_pool.getOrPutString(gpa, io, pt.tid, "index", .no_embedded_nulls);
6220 const field_index = try sema.structFieldIndex(block, stack_trace_ty, field_name, call_src);6220 const field_index = try sema.structFieldIndex(block, stack_trace_ty, field_name, call_src);
62216221
...@@ -8377,10 +8377,10 @@ fn zirFunc(...@@ -8377,10 +8377,10 @@ fn zirFunc(
8377 if (fn_is_exported) {8377 if (fn_is_exported) {
8378 break :cc target.cCallingConvention() orelse {8378 break :cc target.cCallingConvention() orelse {
8379 // This target has no default C calling convention. We sometimes trigger a similar8379 // 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,
8381 // let's eval that now and just get the transitive error. (It's guaranteed to error8381 // let's eval that now and just get the transitive error. (It's guaranteed to error
8382 // because it does the exact `cCallingConvention` call we just did.)8382 // 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);
8384 _ = try sema.namespaceLookupVal(8384 _ = try sema.namespaceLookupVal(
8385 block,8385 block,
8386 LazySrcLoc.unneeded,8386 LazySrcLoc.unneeded,
...@@ -8388,7 +8388,7 @@ fn zirFunc(...@@ -8388,7 +8388,7 @@ fn zirFunc(
8388 try ip.getOrPutString(gpa, io, pt.tid, "c", .no_embedded_nulls),8388 try ip.getOrPutString(gpa, io, pt.tid, "c", .no_embedded_nulls),
8389 );8389 );
8390 // The above should have errored.8390 // The above should have errored.
8391 @panic("std.builtin is corrupt");8391 @panic("std.lang is corrupt");
8392 };8392 };
8393 } else {8393 } else {
8394 break :cc .auto;8394 break :cc .auto;
...@@ -12711,7 +12711,7 @@ fn maybeErrorUnwrap(...@@ -12711,7 +12711,7 @@ fn maybeErrorUnwrap(
12711 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;12711 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
12712 const msg_inst = sema.resolveInst(inst_data.operand);12712 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");
12715 const args: [2]Air.Inst.Ref = .{ msg_inst, .null_value };12715 const args: [2]Air.Inst.Ref = .{ msg_inst, .null_value };
12716 try sema.callBuiltin(block, operand_src, Air.internedToRef(panic_fn), .auto, &args, .@"safety check");12716 try sema.callBuiltin(block, operand_src, Air.internedToRef(panic_fn), .auto, &args, .@"safety check");
12717 return true;12717 return true;
...@@ -15319,7 +15319,7 @@ fn zirAsm(...@@ -15319,7 +15319,7 @@ fn zirAsm(
15319 }15319 }
1532015320
15321 const clobbers_src = block.src(.{ .asm_clobbers = src.offset.node_offset.x });15321 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");
15323 const clobbers = if (extra.data.clobbers == .none) empty: {15323 const clobbers = if (extra.data.clobbers == .none) empty: {
15324 break :empty try sema.structInitEmpty(block, clobbers_ty, src, src);15324 break :empty try sema.structInitEmpty(block, clobbers_ty, src, src);
15325 } else clobbers: {15325 } else clobbers: {
...@@ -15930,7 +15930,7 @@ fn zirBuiltinSrc(...@@ -15930,7 +15930,7 @@ fn zirBuiltinSrc(
15930 } });15930 } });
15931 };15931 };
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);
15934 const fields = .{15934 const fields = .{
15935 // module: [:0]const u8,15935 // module: [:0]const u8,
15936 module_name_val,15936 module_name_val,
...@@ -15957,7 +15957,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -15957,7 +15957,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
15957 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;15957 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
15958 const src = block.nodeOffset(inst_data.src_node);15958 const src = block.nodeOffset(inst_data.src_node);
15959 const ty = try sema.resolveType(block, src, inst_data.operand);15959 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);
15961 const type_info_tag_ty = type_info_ty.unionTagType(zcu).?;15961 const type_info_tag_ty = type_info_ty.unionTagType(zcu).?;
1596215962
15963 try sema.ensureLayoutResolved(ty, src, .type_info);15963 try sema.ensureLayoutResolved(ty, src, .type_info);
...@@ -15979,15 +15979,15 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -15979,15 +15979,15 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
15979 => |type_info_tag| return .fromValue(try pt.unionValue(15979 => |type_info_tag| return .fromValue(try pt.unionValue(
15980 type_info_ty,15980 type_info_ty,
15981 Value.uninterpret(type_info_tag, type_info_tag_ty, pt) catch |err| switch (err) {15981 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"),
15983 error.OutOfMemory => |e| return e,15983 error.OutOfMemory => |e| return e,
15984 },15984 },
15985 .void,15985 .void,
15986 )),15986 )),
1598715987
15988 .@"fn" => {15988 .@"fn" => {
15989 const fn_info_ty = try sema.getBuiltinType(src, .@"Type.Fn");15989 const fn_info_ty = try sema.getStdLangType(src, .@"Type.Fn");
15990 const param_info_ty = try sema.getBuiltinType(src, .@"Type.Fn.Param");15990 const param_info_ty = try sema.getStdLangType(src, .@"Type.Fn.Param");
1599115991
15992 const func_ty_info = zcu.typeToFunc(ty).?;15992 const func_ty_info = zcu.typeToFunc(ty).?;
15993 const param_vals = try sema.arena.alloc(InternPool.Index, func_ty_info.param_types.len);15993 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...@@ -16068,9 +16068,9 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
16068 .val = if (ret_ty_is_generic) .none else func_ty_info.return_type,16068 .val = if (ret_ty_is_generic) .none else func_ty_info.return_type,
16069 } });16069 } });
1607016070
16071 const callconv_ty = try sema.getBuiltinType(src, .CallingConvention);16071 const callconv_ty = try sema.getStdLangType(src, .CallingConvention);
16072 const callconv_val = Value.uninterpret(func_ty_info.cc, callconv_ty, pt) catch |err| switch (err) {16072 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"),
16074 error.OutOfMemory => |e| return e,16074 error.OutOfMemory => |e| return e,
16075 };16075 };
1607616076
...@@ -16093,8 +16093,8 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -16093,8 +16093,8 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
16093 })));16093 })));
16094 },16094 },
16095 .int => {16095 .int => {
16096 const int_info_ty = try sema.getBuiltinType(src, .@"Type.Int");16096 const int_info_ty = try sema.getStdLangType(src, .@"Type.Int");
16097 const signedness_ty = try sema.getBuiltinType(src, .Signedness);16097 const signedness_ty = try sema.getStdLangType(src, .Signedness);
16098 const info = ty.intInfo(zcu);16098 const info = ty.intInfo(zcu);
16099 const field_values = .{16099 const field_values = .{
16100 // signedness: Signedness,16100 // signedness: Signedness,
...@@ -16109,7 +16109,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -16109,7 +16109,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
16109 })));16109 })));
16110 },16110 },
16111 .float => {16111 .float => {
16112 const float_info_ty = try sema.getBuiltinType(src, .@"Type.Float");16112 const float_info_ty = try sema.getStdLangType(src, .@"Type.Float");
1611316113
16114 const field_vals = .{16114 const field_vals = .{
16115 // bits: u16,16115 // bits: u16,
...@@ -16135,9 +16135,9 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -16135,9 +16135,9 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
16135 } }));16135 } }));
16136 };16136 };
1613716137
16138 const addrspace_ty = try sema.getBuiltinType(src, .AddressSpace);16138 const addrspace_ty = try sema.getStdLangType(src, .AddressSpace);
16139 const pointer_ty = try sema.getBuiltinType(src, .@"Type.Pointer");16139 const pointer_ty = try sema.getStdLangType(src, .@"Type.Pointer");
16140 const ptr_size_ty = try sema.getBuiltinType(src, .@"Type.Pointer.Size");16140 const ptr_size_ty = try sema.getStdLangType(src, .@"Type.Pointer.Size");
1614116141
16142 const field_values = .{16142 const field_values = .{
16143 // size: Size,16143 // size: Size,
...@@ -16167,7 +16167,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -16167,7 +16167,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
16167 })));16167 })));
16168 },16168 },
16169 .array => {16169 .array => {
16170 const array_field_ty = try sema.getBuiltinType(src, .@"Type.Array");16170 const array_field_ty = try sema.getStdLangType(src, .@"Type.Array");
1617116171
16172 const info = ty.arrayInfo(zcu);16172 const info = ty.arrayInfo(zcu);
16173 const field_values = .{16173 const field_values = .{
...@@ -16185,7 +16185,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -16185,7 +16185,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
16185 })));16185 })));
16186 },16186 },
16187 .vector => {16187 .vector => {
16188 const vector_field_ty = try sema.getBuiltinType(src, .@"Type.Vector");16188 const vector_field_ty = try sema.getStdLangType(src, .@"Type.Vector");
1618916189
16190 const info = ty.arrayInfo(zcu);16190 const info = ty.arrayInfo(zcu);
16191 const field_values = .{16191 const field_values = .{
...@@ -16201,7 +16201,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -16201,7 +16201,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
16201 })));16201 })));
16202 },16202 },
16203 .optional => {16203 .optional => {
16204 const optional_field_ty = try sema.getBuiltinType(src, .@"Type.Optional");16204 const optional_field_ty = try sema.getStdLangType(src, .@"Type.Optional");
1620516205
16206 const field_values = .{16206 const field_values = .{
16207 // child: type,16207 // child: type,
...@@ -16215,7 +16215,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -16215,7 +16215,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
16215 },16215 },
16216 .error_set => {16216 .error_set => {
16217 // Get the Error type16217 // 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
16220 // Build our list of Error values16220 // Build our list of Error values
16221 // Optional value is only null if anyerror16221 // Optional value is only null if anyerror
...@@ -16305,7 +16305,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -16305,7 +16305,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
16305 })));16305 })));
16306 },16306 },
16307 .error_union => {16307 .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
16310 const field_values = .{16310 const field_values = .{
16311 // error_set: type,16311 // error_set: type,
...@@ -16323,7 +16323,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -16323,7 +16323,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
16323 const enum_obj = ip.loadEnumType(ty.toIntern());16323 const enum_obj = ip.loadEnumType(ty.toIntern());
16324 const is_exhaustive: Value = .makeBool(!enum_obj.nonexhaustive);16324 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
16328 const enum_field_vals = try sema.arena.alloc(InternPool.Index, enum_obj.field_names.len);16328 const enum_field_vals = try sema.arena.alloc(InternPool.Index, enum_obj.field_names.len);
16329 for (enum_field_vals, 0..) |*field_val, tag_index| {16329 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...@@ -16404,7 +16404,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1640416404
16405 const decls_val = try sema.typeInfoDecls(src, ip.loadEnumType(ty.toIntern()).namespace.toOptional());16405 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
16409 const field_values = .{16409 const field_values = .{
16410 // tag_type: type,16410 // tag_type: type,
...@@ -16423,8 +16423,8 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -16423,8 +16423,8 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
16423 })));16423 })));
16424 },16424 },
16425 .@"union" => {16425 .@"union" => {
16426 const type_union_ty = try sema.getBuiltinType(src, .@"Type.Union");16426 const type_union_ty = try sema.getStdLangType(src, .@"Type.Union");
16427 const union_field_ty = try sema.getBuiltinType(src, .@"Type.UnionField");16427 const union_field_ty = try sema.getStdLangType(src, .@"Type.UnionField");
1642816428
16429 const union_obj = ip.loadUnionType(ty.toIntern());16429 const union_obj = ip.loadUnionType(ty.toIntern());
16430 const enum_obj = ip.loadEnumType(union_obj.enum_tag_type);16430 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...@@ -16524,7 +16524,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
16524 .val = if (ty.unionTagType(zcu)) |tag_ty| tag_ty.toIntern() else .none,16524 .val = if (ty.unionTagType(zcu)) |tag_ty| tag_ty.toIntern() else .none,
16525 } });16525 } });
1652616526
16527 const container_layout_ty = try sema.getBuiltinType(src, .@"Type.ContainerLayout");16527 const container_layout_ty = try sema.getStdLangType(src, .@"Type.ContainerLayout");
1652816528
16529 const field_values = .{16529 const field_values = .{
16530 // layout: ContainerLayout,16530 // layout: ContainerLayout,
...@@ -16544,8 +16544,8 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -16544,8 +16544,8 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
16544 })));16544 })));
16545 },16545 },
16546 .@"struct" => {16546 .@"struct" => {
16547 const type_struct_ty = try sema.getBuiltinType(src, .@"Type.Struct");16547 const type_struct_ty = try sema.getStdLangType(src, .@"Type.Struct");
16548 const struct_field_ty = try sema.getBuiltinType(src, .@"Type.StructField");16548 const struct_field_ty = try sema.getStdLangType(src, .@"Type.StructField");
1654916549
16550 var struct_field_vals: []InternPool.Index = &.{};16550 var struct_field_vals: []InternPool.Index = &.{};
16551 defer gpa.free(struct_field_vals);16551 defer gpa.free(struct_field_vals);
...@@ -16713,7 +16713,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -16713,7 +16713,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
16713 } else .none,16713 } else .none,
16714 } });16714 } });
1671516715
16716 const container_layout_ty = try sema.getBuiltinType(src, .@"Type.ContainerLayout");16716 const container_layout_ty = try sema.getStdLangType(src, .@"Type.ContainerLayout");
1671716717
16718 const layout = ty.containerLayout(zcu);16718 const layout = ty.containerLayout(zcu);
1671916719
...@@ -16736,7 +16736,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -16736,7 +16736,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
16736 })));16736 })));
16737 },16737 },
16738 .@"opaque" => {16738 .@"opaque" => {
16739 const type_opaque_ty = try sema.getBuiltinType(src, .@"Type.Opaque");16739 const type_opaque_ty = try sema.getStdLangType(src, .@"Type.Opaque");
1674016740
16741 const decls_val = try sema.typeInfoDecls(src, ty.getNamespace(zcu));16741 const decls_val = try sema.typeInfoDecls(src, ty.getNamespace(zcu));
1674216742
...@@ -16764,7 +16764,7 @@ fn typeInfoDecls(...@@ -16764,7 +16764,7 @@ fn typeInfoDecls(
16764 const zcu = pt.zcu;16764 const zcu = pt.zcu;
16765 const gpa = sema.gpa;16765 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
16769 var decl_vals = std.array_list.Managed(InternPool.Index).init(gpa);16769 var decl_vals = std.array_list.Managed(InternPool.Index).init(gpa);
16770 defer decl_vals.deinit();16770 defer decl_vals.deinit();
...@@ -17714,7 +17714,7 @@ fn maybePushErrorTrace(...@@ -17714,7 +17714,7 @@ fn maybePushErrorTrace(
17714 assert(pt.zcu.intern_pool.funcAnalysisUnordered(sema.owner.unwrap().func).has_error_trace);17714 assert(pt.zcu.intern_pool.funcAnalysisUnordered(sema.owner.unwrap().func).has_error_trace);
1771517715
17716 const gpa = sema.gpa;17716 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
17719 if (!need_check) {17719 if (!need_check) {
17720 try sema.callBuiltin(parent_block, src, return_err_fn, .never_tail, &.{}, .@"error return");17720 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 {...@@ -19179,7 +19179,7 @@ fn getErrorReturnTrace(sema: *Sema, block: *Block) CompileError!Air.Inst.Ref {
19179 const pt = sema.pt;19179 const pt = sema.pt;
19180 const zcu = pt.zcu;19180 const zcu = pt.zcu;
19181 const ip = &zcu.intern_pool;19181 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);
19183 const ptr_stack_trace_ty = try pt.singleMutPtrType(stack_trace_ty);19183 const ptr_stack_trace_ty = try pt.singleMutPtrType(stack_trace_ty);
19184 const opt_ptr_stack_trace_ty = try pt.optionalType(ptr_stack_trace_ty.toIntern());19184 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...@@ -19446,7 +19446,7 @@ fn zirReifyInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
19446 const signedness_src = block.builtinCallArgSrc(inst_data.src_node, 0);19446 const signedness_src = block.builtinCallArgSrc(inst_data.src_node, 0);
19447 const bits_src = block.builtinCallArgSrc(inst_data.src_node, 1);19447 const bits_src = block.builtinCallArgSrc(inst_data.src_node, 1);
19448 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;19448 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 });
19450 const bits: u16 = @intCast(try sema.resolveInt(block, bits_src, extra.rhs, .u16, .{ .simple = .int_bit_width }));19450 const bits: u16 = @intCast(try sema.resolveInt(block, bits_src, extra.rhs, .u16, .{ .simple = .int_bit_width }));
19451 if (bits == 0 and signedness == .signed) {19451 if (bits == 0 and signedness == .signed) {
19452 return sema.fail(block, bits_src, "signed integer cannot have bit width 0", .{});19452 return sema.fail(block, bits_src, "signed integer cannot have bit width 0", .{});
...@@ -19469,11 +19469,11 @@ fn zirReifySliceArgTy(...@@ -19469,11 +19469,11 @@ fn zirReifySliceArgTy(
1946919469
19470 const comptime_reason: std.zig.SimpleComptimeReason, const in_scalar_ty: Type, const out_scalar_ty: Type = switch (info) {19470 const comptime_reason: std.zig.SimpleComptimeReason, const in_scalar_ty: Type, const out_scalar_ty: Type = switch (info) {
19471 // zig fmt: off19471 // 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") },
19473 .string_to_struct_field_type => .{ .struct_field_types, .slice_const_u8, .type },19473 .string_to_struct_field_type => .{ .struct_field_types, .slice_const_u8, .type },
19474 .string_to_union_field_type => .{ .union_field_types, .slice_const_u8, .type },19474 .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") },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.getBuiltinType(src, .@"Type.UnionField.Attributes") },19476 .string_to_union_field_attrs => .{ .union_field_attrs, .slice_const_u8, try sema.getStdLangType(src, .@"Type.UnionField.Attributes") },
19477 // zig fmt: on19477 // zig fmt: on
19478 };19478 };
1947919479
...@@ -19599,18 +19599,18 @@ fn zirReifyPointer(...@@ -19599,18 +19599,18 @@ fn zirReifyPointer(
19599 const elem_ty_src = block.builtinCallArgSrc(extra.node, 2);19599 const elem_ty_src = block.builtinCallArgSrc(extra.node, 2);
19600 const sentinel_src = block.builtinCallArgSrc(extra.node, 3);19600 const sentinel_src = block.builtinCallArgSrc(extra.node, 3);
1960119601
19602 const size_ty = try sema.getBuiltinType(size_src, .@"Type.Pointer.Size");19602 const size_ty = try sema.getStdLangType(size_src, .@"Type.Pointer.Size");
19603 const attrs_ty = try sema.getBuiltinType(attrs_src, .@"Type.Pointer.Attributes");19603 const attrs_ty = try sema.getStdLangType(attrs_src, .@"Type.Pointer.Attributes");
1960419604
19605 const size_uncoerced = sema.resolveInst(extra.size);19605 const size_uncoerced = sema.resolveInst(extra.size);
19606 const size_coerced = try sema.coerce(block, size_ty, size_uncoerced, size_src);19606 const size_coerced = try sema.coerce(block, size_ty, size_uncoerced, size_src);
19607 const size_val = try sema.resolveConstDefinedValue(block, size_src, size_coerced, .{ .simple = .pointer_size });19607 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
19610 const attrs_uncoerced = sema.resolveInst(extra.attrs);19610 const attrs_uncoerced = sema.resolveInst(extra.attrs);
19611 const attrs_coerced = try sema.coerce(block, attrs_ty, attrs_uncoerced, attrs_src);19611 const attrs_coerced = try sema.coerce(block, attrs_ty, attrs_uncoerced, attrs_src);
19612 const attrs_val = try sema.resolveConstDefinedValue(block, attrs_src, attrs_coerced, .{ .simple = .pointer_attrs });19612 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
19615 const @"align": Alignment = if (attrs.@"align") |bytes| a: {19615 const @"align": Alignment = if (attrs.@"align") |bytes| a: {
19616 break :a try sema.validateAlign(block, attrs_src, bytes);19616 break :a try sema.validateAlign(block, attrs_src, bytes);
...@@ -19687,8 +19687,8 @@ fn zirReifyFn(...@@ -19687,8 +19687,8 @@ fn zirReifyFn(
19687 const ret_ty_src = block.builtinCallArgSrc(extra.node, 2);19687 const ret_ty_src = block.builtinCallArgSrc(extra.node, 2);
19688 const fn_attrs_src = block.builtinCallArgSrc(extra.node, 3);19688 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");19690 const single_param_attrs_ty = try sema.getStdLangType(param_attrs_src, .@"Type.Fn.Param.Attributes");
19691 const fn_attrs_ty = try sema.getBuiltinType(fn_attrs_src, .@"Type.Fn.Attributes");19691 const fn_attrs_ty = try sema.getStdLangType(fn_attrs_src, .@"Type.Fn.Attributes");
1969219692
19693 const param_types_uncoerced = sema.resolveInst(extra.param_types);19693 const param_types_uncoerced = sema.resolveInst(extra.param_types);
19694 const param_types_coerced = try sema.coerce(block, .slice_const_type, param_types_uncoerced, param_types_src);19694 const param_types_coerced = try sema.coerce(block, .slice_const_type, param_types_uncoerced, param_types_src);
...@@ -19711,13 +19711,13 @@ fn zirReifyFn(...@@ -19711,13 +19711,13 @@ fn zirReifyFn(
19711 const fn_attrs_uncoerced = sema.resolveInst(extra.fn_attrs);19711 const fn_attrs_uncoerced = sema.resolveInst(extra.fn_attrs);
19712 const fn_attrs_coerced = try sema.coerce(block, fn_attrs_ty, fn_attrs_uncoerced, fn_attrs_src);19712 const fn_attrs_coerced = try sema.coerce(block, fn_attrs_ty, fn_attrs_uncoerced, fn_attrs_src);
19713 const fn_attrs_val = try sema.resolveConstDefinedValue(block, fn_attrs_src, fn_attrs_coerced, .{ .simple = .fn_attrs });19713 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
19716 var noalias_bits: u32 = 0;19716 var noalias_bits: u32 = 0;
19717 const param_types_ip = try sema.arena.alloc(InternPool.Index, @intCast(params_len));19717 const param_types_ip = try sema.arena.alloc(InternPool.Index, @intCast(params_len));
19718 for (param_types_ip, 0..@intCast(params_len)) |*param_ty_ip, param_idx| {19718 for (param_types_ip, 0..@intCast(params_len)) |*param_ty_ip, param_idx| {
19719 const param_ty: Type = (try param_types_arr.elemValue(pt, param_idx)).toType();19719 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(
19721 block,19721 block,
19722 param_attrs_src,19722 param_attrs_src,
19723 try param_attrs_arr.elemValue(pt, param_idx),19723 try param_attrs_arr.elemValue(pt, param_idx),
...@@ -19825,13 +19825,13 @@ fn zirReifyStruct(...@@ -19825,13 +19825,13 @@ fn zirReifyStruct(
19825 } },19825 } },
19826 };19826 };
1982719827
19828 const container_layout_ty = try sema.getBuiltinType(layout_src, .@"Type.ContainerLayout");19828 const container_layout_ty = try sema.getStdLangType(layout_src, .@"Type.ContainerLayout");
19829 const single_field_attrs_ty = try sema.getBuiltinType(field_attrs_src, .@"Type.StructField.Attributes");19829 const single_field_attrs_ty = try sema.getStdLangType(field_attrs_src, .@"Type.StructField.Attributes");
1983019830
19831 const layout_uncoerced = sema.resolveInst(extra.layout);19831 const layout_uncoerced = sema.resolveInst(extra.layout);
19832 const layout_coerced = try sema.coerce(block, container_layout_ty, layout_uncoerced, layout_src);19832 const layout_coerced = try sema.coerce(block, container_layout_ty, layout_uncoerced, layout_src);
19833 const layout_val = try sema.resolveConstDefinedValue(block, layout_src, layout_coerced, .{ .simple = .struct_layout });19833 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
19836 const backing_int_ty_uncoerced = sema.resolveInst(extra.backing_ty);19836 const backing_int_ty_uncoerced = sema.resolveInst(extra.backing_ty);
19837 const backing_int_ty_coerced = try sema.coerce(block, .optional_type, backing_int_ty_uncoerced, backing_ty_src);19837 const backing_int_ty_coerced = try sema.coerce(block, .optional_type, backing_int_ty_uncoerced, backing_ty_src);
...@@ -20105,13 +20105,13 @@ fn zirReifyUnion(...@@ -20105,13 +20105,13 @@ fn zirReifyUnion(
20105 } },20105 } },
20106 };20106 };
2010720107
20108 const container_layout_ty = try sema.getBuiltinType(layout_src, .@"Type.ContainerLayout");20108 const container_layout_ty = try sema.getStdLangType(layout_src, .@"Type.ContainerLayout");
20109 const single_field_attrs_ty = try sema.getBuiltinType(field_attrs_src, .@"Type.UnionField.Attributes");20109 const single_field_attrs_ty = try sema.getStdLangType(field_attrs_src, .@"Type.UnionField.Attributes");
2011020110
20111 const layout_uncoerced = sema.resolveInst(extra.layout);20111 const layout_uncoerced = sema.resolveInst(extra.layout);
20112 const layout_coerced = try sema.coerce(block, container_layout_ty, layout_uncoerced, layout_src);20112 const layout_coerced = try sema.coerce(block, container_layout_ty, layout_uncoerced, layout_src);
20113 const layout_val = try sema.resolveConstDefinedValue(block, layout_src, layout_coerced, .{ .simple = .union_layout });20113 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
20116 const arg_ty_uncoerced = sema.resolveInst(extra.arg_ty);20116 const arg_ty_uncoerced = sema.resolveInst(extra.arg_ty);
20117 const arg_ty_coerced = try sema.coerce(block, .optional_type, arg_ty_uncoerced, arg_ty_src);20117 const arg_ty_coerced = try sema.coerce(block, .optional_type, arg_ty_uncoerced, arg_ty_src);
...@@ -20191,7 +20191,7 @@ fn zirReifyUnion(...@@ -20191,7 +20191,7 @@ fn zirReifyUnion(
20191 const field_name = try sema.sliceToIpString(block, field_names_src, field_name_val, .{ .simple = .union_field_names });20191 const field_name = try sema.sliceToIpString(block, field_names_src, field_name_val, .{ .simple = .union_field_names });
20192 std.hash.autoHash(&hasher, field_name);20192 std.hash.autoHash(&hasher, field_name);
2019320193
20194 const field_attrs = try sema.interpretBuiltinType(20194 const field_attrs = try sema.interpretStdLangType(
20195 block,20195 block,
20196 field_attrs_src,20196 field_attrs_src,
20197 try field_attrs_arr.elemValue(pt, field_idx),20197 try field_attrs_arr.elemValue(pt, field_idx),
...@@ -20240,7 +20240,7 @@ fn zirReifyUnion(...@@ -20240,7 +20240,7 @@ fn zirReifyUnion(
20240 wip.field_types.get(ip)[field_idx] = field_ty.toIntern();20240 wip.field_types.get(ip)[field_idx] = field_ty.toIntern();
2024120241
20242 // No source location; first loop checked this is valid.20242 // No source location; first loop checked this is valid.
20243 const field_attrs = try sema.interpretBuiltinType(20243 const field_attrs = try sema.interpretStdLangType(
20244 block,20244 block,
20245 .unneeded,20245 .unneeded,
20246 try field_attrs_arr.elemValue(pt, field_idx),20246 try field_attrs_arr.elemValue(pt, field_idx),
...@@ -20319,7 +20319,7 @@ fn zirReifyEnum(...@@ -20319,7 +20319,7 @@ fn zirReifyEnum(
20319 } },20319 } },
20320 };20320 };
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
20324 const tag_ty_uncoerced = sema.resolveInst(extra.tag_ty);20324 const tag_ty_uncoerced = sema.resolveInst(extra.tag_ty);
20325 const tag_ty_coerced = try sema.coerce(block, .type, tag_ty_uncoerced, tag_ty_src);20325 const tag_ty_coerced = try sema.coerce(block, .type, tag_ty_uncoerced, tag_ty_src);
...@@ -20329,7 +20329,7 @@ fn zirReifyEnum(...@@ -20329,7 +20329,7 @@ fn zirReifyEnum(
20329 const mode_uncoerced = sema.resolveInst(extra.mode);20329 const mode_uncoerced = sema.resolveInst(extra.mode);
20330 const mode_coerced = try sema.coerce(block, enum_mode_ty, mode_uncoerced, mode_src);20330 const mode_coerced = try sema.coerce(block, enum_mode_ty, mode_uncoerced, mode_src);
20331 const mode_val = try sema.resolveConstDefinedValue(block, mode_src, mode_coerced, .{ .simple = .type });20331 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)) {
20333 .exhaustive => false,20333 .exhaustive => false,
20334 .nonexhaustive => true,20334 .nonexhaustive => true,
20335 };20335 };
...@@ -20423,7 +20423,7 @@ fn zirReifyEnum(...@@ -20423,7 +20423,7 @@ fn zirReifyEnum(
2042320423
20424fn resolveVaListRef(sema: *Sema, block: *Block, src: LazySrcLoc, zir_ref: Zir.Inst.Ref) CompileError!Air.Inst.Ref {20424fn resolveVaListRef(sema: *Sema, block: *Block, src: LazySrcLoc, zir_ref: Zir.Inst.Ref) CompileError!Air.Inst.Ref {
20425 const pt = sema.pt;20425 const pt = sema.pt;
20426 const va_list_ty = try sema.getBuiltinType(src, .VaList);20426 const va_list_ty = try sema.getStdLangType(src, .VaList);
20427 const va_list_ptr = try pt.singleMutPtrType(va_list_ty);20427 const va_list_ptr = try pt.singleMutPtrType(va_list_ty);
2042820428
20429 const inst = sema.resolveInst(zir_ref);20429 const inst = sema.resolveInst(zir_ref);
...@@ -20462,7 +20462,7 @@ fn zirCVaCopy(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData)...@@ -20462,7 +20462,7 @@ fn zirCVaCopy(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData)
20462 const va_list_src = block.builtinCallArgSrc(extra.node, 0);20462 const va_list_src = block.builtinCallArgSrc(extra.node, 0);
2046320463
20464 const va_list_ref = try sema.resolveVaListRef(block, va_list_src, extra.operand);20464 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
20467 try sema.requireRuntimeBlock(block, src, null);20467 try sema.requireRuntimeBlock(block, src, null);
20468 return block.addTyOp(.c_va_copy, va_list_ty, va_list_ref);20468 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)...@@ -20484,7 +20484,7 @@ fn zirCVaStart(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData)
20484 const src_node: std.zig.Ast.Node.Offset = @enumFromInt(@as(i32, @bitCast(extended.operand)));20484 const src_node: std.zig.Ast.Node.Offset = @enumFromInt(@as(i32, @bitCast(extended.operand)));
20485 const src = block.nodeOffset(src_node);20485 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);
20488 try sema.requireRuntimeBlock(block, src, null);20488 try sema.requireRuntimeBlock(block, src, null);
20489 return block.addInst(.{20489 return block.addInst(.{
20490 .tag = .c_va_start,20490 .tag = .c_va_start,
...@@ -22373,7 +22373,7 @@ fn resolveExportOptions(...@@ -22373,7 +22373,7 @@ fn resolveExportOptions(
22373 const io = comp.io;22373 const io = comp.io;
22374 const ip = &zcu.intern_pool;22374 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);
22377 const air_ref = sema.resolveInst(zir_ref);22377 const air_ref = sema.resolveInst(zir_ref);
22378 const options = try sema.coerce(block, export_options_ty, air_ref, src);22378 const options = try sema.coerce(block, export_options_ty, air_ref, src);
2237922379
...@@ -22387,7 +22387,7 @@ fn resolveExportOptions(...@@ -22387,7 +22387,7 @@ fn resolveExportOptions(
2238722387
22388 const linkage_operand = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, io, pt.tid, "linkage", .no_embedded_nulls), linkage_src);22388 const linkage_operand = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, io, pt.tid, "linkage", .no_embedded_nulls), linkage_src);
22389 const linkage_val = try sema.resolveConstDefinedValue(block, linkage_src, linkage_operand, .{ .simple = .export_options });22389 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
22392 const section_operand = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, io, pt.tid, "section", .no_embedded_nulls), section_src);22392 const section_operand = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, io, pt.tid, "section", .no_embedded_nulls), section_src);
22393 const section_opt_val = try sema.resolveConstDefinedValue(block, section_src, section_operand, .{ .simple = .export_options });22393 const section_opt_val = try sema.resolveConstDefinedValue(block, section_src, section_operand, .{ .simple = .export_options });
...@@ -22398,7 +22398,7 @@ fn resolveExportOptions(...@@ -22398,7 +22398,7 @@ fn resolveExportOptions(
2239822398
22399 const visibility_operand = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, io, pt.tid, "visibility", .no_embedded_nulls), visibility_src);22399 const visibility_operand = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, io, pt.tid, "visibility", .no_embedded_nulls), visibility_src);
22400 const visibility_val = try sema.resolveConstDefinedValue(block, visibility_src, visibility_operand, .{ .simple = .export_options });22400 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
22403 if (name.len < 1) {22403 if (name.len < 1) {
22404 return sema.fail(block, name_src, "exported symbol name cannot be empty", .{});22404 return sema.fail(block, name_src, "exported symbol name cannot be empty", .{});
...@@ -22418,19 +22418,19 @@ fn resolveExportOptions(...@@ -22418,19 +22418,19 @@ fn resolveExportOptions(
22418 };22418 };
22419}22419}
2242022420
22421fn resolveBuiltinEnum(22421fn resolveStdLangEnum(
22422 sema: *Sema,22422 sema: *Sema,
22423 block: *Block,22423 block: *Block,
22424 src: LazySrcLoc,22424 src: LazySrcLoc,
22425 zir_ref: Zir.Inst.Ref,22425 zir_ref: Zir.Inst.Ref,
22426 comptime name: Zcu.BuiltinDecl,22426 comptime name: Zcu.StdLangDecl,
22427 reason: ComptimeReason,22427 reason: ComptimeReason,
22428) CompileError!@field(std.builtin, @tagName(name)) {22428) CompileError!@field(std.builtin, @tagName(name)) {
22429 const ty = try sema.getBuiltinType(src, name);22429 const ty = try sema.getStdLangType(src, name);
22430 const air_ref = sema.resolveInst(zir_ref);22430 const air_ref = sema.resolveInst(zir_ref);
22431 const coerced = try sema.coerce(block, ty, air_ref, src);22431 const coerced = try sema.coerce(block, ty, air_ref, src);
22432 const val = try sema.resolveConstDefinedValue(block, src, coerced, reason);22432 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)));
22434}22434}
2243522435
22436fn resolveAtomicOrder(22436fn resolveAtomicOrder(
...@@ -22440,7 +22440,7 @@ fn resolveAtomicOrder(...@@ -22440,7 +22440,7 @@ fn resolveAtomicOrder(
22440 zir_ref: Zir.Inst.Ref,22440 zir_ref: Zir.Inst.Ref,
22441 reason: ComptimeReason,22441 reason: ComptimeReason,
22442) CompileError!std.builtin.AtomicOrder {22442) CompileError!std.builtin.AtomicOrder {
22443 return sema.resolveBuiltinEnum(block, src, zir_ref, .AtomicOrder, reason);22443 return sema.resolveStdLangEnum(block, src, zir_ref, .AtomicOrder, reason);
22444}22444}
2244522445
22446fn resolveAtomicRmwOp(22446fn resolveAtomicRmwOp(
...@@ -22449,7 +22449,7 @@ fn resolveAtomicRmwOp(...@@ -22449,7 +22449,7 @@ fn resolveAtomicRmwOp(
22449 src: LazySrcLoc,22449 src: LazySrcLoc,
22450 zir_ref: Zir.Inst.Ref,22450 zir_ref: Zir.Inst.Ref,
22451) CompileError!std.builtin.AtomicRmwOp {22451) 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 });
22453}22453}
2245422454
22455fn zirCmpxchg(22455fn zirCmpxchg(
...@@ -22609,7 +22609,7 @@ fn zirReduce(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air....@@ -22609,7 +22609,7 @@ fn zirReduce(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
22609 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;22609 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
22610 const op_src = block.builtinCallArgSrc(inst_data.src_node, 0);22610 const op_src = block.builtinCallArgSrc(inst_data.src_node, 0);
22611 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 1);22611 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 });
22613 const operand = sema.resolveInst(extra.rhs);22613 const operand = sema.resolveInst(extra.rhs);
22614 const operand_ty = sema.typeOf(operand);22614 const operand_ty = sema.typeOf(operand);
22615 const pt = sema.pt;22615 const pt = sema.pt;
...@@ -23196,11 +23196,11 @@ fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -23196,11 +23196,11 @@ fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
23196 const extra = sema.code.extraData(Zir.Inst.BuiltinCall, inst_data.payload_index).data;23196 const extra = sema.code.extraData(Zir.Inst.BuiltinCall, inst_data.payload_index).data;
23197 const func = sema.resolveInst(extra.callee);23197 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);
23200 const air_ref = sema.resolveInst(extra.modifier);23200 const air_ref = sema.resolveInst(extra.modifier);
23201 const modifier_ref = try sema.coerce(block, modifier_ty, air_ref, modifier_src);23201 const modifier_ref = try sema.coerce(block, modifier_ty, air_ref, modifier_src);
23202 const modifier_val = try sema.resolveConstDefinedValue(block, modifier_src, modifier_ref, .{ .simple = .call_modifier });23202 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);
23204 switch (modifier) {23204 switch (modifier) {
23205 // These can be upgraded to comptime or nosuspend calls.23205 // These can be upgraded to comptime or nosuspend calls.
23206 .auto, .never_tail, .no_suspend => {23206 .auto, .never_tail, .no_suspend => {
...@@ -24256,13 +24256,13 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A...@@ -24256,13 +24256,13 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
24256 const body = sema.code.bodySlice(extra_index, body_len);24256 const body = sema.code.bodySlice(extra_index, body_len);
24257 extra_index += body.len;24257 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);
24260 const val = try sema.resolveGenericBody(block, cc_src, body, inst, cc_ty, .{ .simple = .@"callconv" });24260 const val = try sema.resolveGenericBody(block, cc_src, body, inst, cc_ty, .{ .simple = .@"callconv" });
24261 break :blk try sema.analyzeValueAsCallconv(block, cc_src, val);24261 break :blk try sema.analyzeValueAsCallconv(block, cc_src, val);
24262 } else if (extra.data.bits.has_cc_ref) blk: {24262 } else if (extra.data.bits.has_cc_ref) blk: {
24263 const cc_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]);24263 const cc_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]);
24264 extra_index += 1;24264 extra_index += 1;
24265 const cc_ty = try sema.getBuiltinType(cc_src, .CallingConvention);24265 const cc_ty = try sema.getStdLangType(cc_src, .CallingConvention);
24266 const uncoerced_cc = sema.resolveInst(cc_ref);24266 const uncoerced_cc = sema.resolveInst(cc_ref);
24267 const coerced_cc = try sema.coerce(block, cc_ty, uncoerced_cc, cc_src);24267 const coerced_cc = try sema.coerce(block, cc_ty, uncoerced_cc, cc_src);
24268 const cc_val = try sema.resolveConstDefinedValue(block, cc_src, coerced_cc, .{ .simple = .@"callconv" });24268 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...@@ -24275,10 +24275,10 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
24275 if (zir_decl.linkage == .@"export") {24275 if (zir_decl.linkage == .@"export") {
24276 break :cc target.cCallingConvention() orelse {24276 break :cc target.cCallingConvention() orelse {
24277 // This target has no default C calling convention. We sometimes trigger a similar24277 // 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,
24279 // let's eval that now and just get the transitive error. (It's guaranteed to error24279 // let's eval that now and just get the transitive error. (It's guaranteed to error
24280 // because it does the exact `cCallingConvention` call we just did.)24280 // 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);
24282 _ = try sema.namespaceLookupVal(24282 _ = try sema.namespaceLookupVal(
24283 block,24283 block,
24284 LazySrcLoc.unneeded,24284 LazySrcLoc.unneeded,
...@@ -24286,7 +24286,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A...@@ -24286,7 +24286,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
24286 try ip.getOrPutString(gpa, io, pt.tid, "c", .no_embedded_nulls),24286 try ip.getOrPutString(gpa, io, pt.tid, "c", .no_embedded_nulls),
24287 );24287 );
24288 // The above should have errored.24288 // The above should have errored.
24289 @panic("std.builtin is corrupt");24289 @panic("std.lang is corrupt");
24290 };24290 };
24291 }24291 }
24292 }24292 }
...@@ -24406,7 +24406,7 @@ fn resolvePrefetchOptions(...@@ -24406,7 +24406,7 @@ fn resolvePrefetchOptions(
24406 const io = comp.io;24406 const io = comp.io;
24407 const ip = &zcu.intern_pool;24407 const ip = &zcu.intern_pool;
2440824408
24409 const options_ty = try sema.getBuiltinType(src, .PrefetchOptions);24409 const options_ty = try sema.getStdLangType(src, .PrefetchOptions);
24410 const options = try sema.coerce(block, options_ty, sema.resolveInst(zir_ref), src);24410 const options = try sema.coerce(block, options_ty, sema.resolveInst(zir_ref), src);
2441124411
24412 const rw_src = block.src(.{ .init_field_rw = src.offset.node_offset_builtin_call_arg.builtin_call_node });24412 const rw_src = block.src(.{ .init_field_rw = src.offset.node_offset_builtin_call_arg.builtin_call_node });
...@@ -24423,9 +24423,9 @@ fn resolvePrefetchOptions(...@@ -24423,9 +24423,9 @@ fn resolvePrefetchOptions(
24423 const cache_val = try sema.resolveConstDefinedValue(block, cache_src, cache, .{ .simple = .prefetch_options });24423 const cache_val = try sema.resolveConstDefinedValue(block, cache_src, cache, .{ .simple = .prefetch_options });
2442424424
24425 return std.builtin.PrefetchOptions{24425 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),
24427 .locality = @intCast(locality_val.toUnsignedInt(zcu)),24427 .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),
24429 };24429 };
24430}24430}
2443124431
...@@ -24480,7 +24480,7 @@ fn resolveExternOptions(...@@ -24480,7 +24480,7 @@ fn resolveExternOptions(
24480 const ip = &zcu.intern_pool;24480 const ip = &zcu.intern_pool;
2448124481
24482 const options_inst = sema.resolveInst(zir_ref);24482 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);
24484 const options = try sema.coerce(block, extern_options_ty, options_inst, src);24484 const options = try sema.coerce(block, extern_options_ty, options_inst, src);
2448524485
24486 const name_src = block.src(.{ .init_field_name = src.offset.node_offset_builtin_call_arg.builtin_call_node });24486 const name_src = block.src(.{ .init_field_name = src.offset.node_offset_builtin_call_arg.builtin_call_node });
...@@ -24500,11 +24500,11 @@ fn resolveExternOptions(...@@ -24500,11 +24500,11 @@ fn resolveExternOptions(
2450024500
24501 const linkage_ref = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, io, pt.tid, "linkage", .no_embedded_nulls), linkage_src);24501 const linkage_ref = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, io, pt.tid, "linkage", .no_embedded_nulls), linkage_src);
24502 const linkage_val = try sema.resolveConstDefinedValue(block, linkage_src, linkage_ref, .{ .simple = .extern_options });24502 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
24505 const visibility_ref = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, io, pt.tid, "visibility", .no_embedded_nulls), visibility_src);24505 const visibility_ref = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, io, pt.tid, "visibility", .no_embedded_nulls), visibility_src);
24506 const visibility_val = try sema.resolveConstDefinedValue(block, visibility_src, visibility_ref, .{ .simple = .extern_options });24506 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
24509 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);24509 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);
24510 const is_thread_local_val = try sema.resolveConstDefinedValue(block, thread_local_src, is_thread_local, .{ .simple = .extern_options });24510 const is_thread_local_val = try sema.resolveConstDefinedValue(block, thread_local_src, is_thread_local, .{ .simple = .extern_options });
...@@ -24523,11 +24523,11 @@ fn resolveExternOptions(...@@ -24523,11 +24523,11 @@ fn resolveExternOptions(
2452324523
24524 const relocation_ref = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, io, pt.tid, "relocation", .no_embedded_nulls), relocation_src);24524 const relocation_ref = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, io, pt.tid, "relocation", .no_embedded_nulls), relocation_src);
24525 const relocation_val = try sema.resolveConstDefinedValue(block, relocation_src, relocation_ref, .{ .simple = .extern_options });24525 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
24528 const decoration_ref = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, io, pt.tid, "decoration", .no_embedded_nulls), decoration_src);24528 const decoration_ref = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, io, pt.tid, "decoration", .no_embedded_nulls), decoration_src);
24529 const decoration_val = try sema.resolveConstDefinedValue(block, decoration_src, decoration_ref, .{ .simple = .extern_options });24529 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
24532 if (name.len == 0) {24532 if (name.len == 0) {
24533 return sema.fail(block, name_src, "extern symbol name cannot be empty", .{});24533 return sema.fail(block, name_src, "extern symbol name cannot be empty", .{});
...@@ -24696,7 +24696,7 @@ fn zirInComptime(...@@ -24696,7 +24696,7 @@ fn zirInComptime(
24696 return if (block.isComptime()) .bool_true else .bool_false;24696 return if (block.isComptime()) .bool_true else .bool_false;
24697}24697}
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 {
24700 const pt = sema.pt;24700 const pt = sema.pt;
24701 const zcu = pt.zcu;24701 const zcu = pt.zcu;
24702 const comp = zcu.comp;24702 const comp = zcu.comp;
...@@ -24706,9 +24706,9 @@ fn zirBuiltinValue(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstD...@@ -24706,9 +24706,9 @@ fn zirBuiltinValue(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstD
2470624706
24707 const src_node: std.zig.Ast.Node.Offset = @enumFromInt(@as(i32, @bitCast(extended.operand)));24707 const src_node: std.zig.Ast.Node.Offset = @enumFromInt(@as(i32, @bitCast(extended.operand)));
24708 const src = block.nodeOffset(src_node);24708 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) {
24712 // zig fmt: off24712 // zig fmt: off
24713 .atomic_order => .AtomicOrder,24713 .atomic_order => .AtomicOrder,
24714 .atomic_rmw_op => .AtomicRmwOp,24714 .atomic_rmw_op => .AtomicRmwOp,
...@@ -24732,28 +24732,28 @@ fn zirBuiltinValue(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstD...@@ -24732,28 +24732,28 @@ fn zirBuiltinValue(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstD
2473224732
24733 // Values are handled here.24733 // Values are handled here.
24734 .calling_convention_c => {24734 .calling_convention_c => {
24735 const callconv_ty = try sema.getBuiltinType(src, .CallingConvention);24735 const callconv_ty = try sema.getStdLangType(src, .CallingConvention);
24736 // Cannot use `Value.uninterpret` because `c` is a *declaration* whose value depends on the target.24736 // Cannot use `Value.uninterpret` because `c` is a *declaration* whose value depends on the target.
24737 return try sema.namespaceLookupVal(24737 return try sema.namespaceLookupVal(
24738 block,24738 block,
24739 src,24739 src,
24740 callconv_ty.getNamespaceIndex(zcu),24740 callconv_ty.getNamespaceIndex(zcu),
24741 try ip.getOrPutString(gpa, io, pt.tid, "c", .no_embedded_nulls),24741 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");
24743 },24743 },
24744 .calling_convention_inline => {24744 .calling_convention_inline => {
24745 const callconv_ty = try sema.getBuiltinType(src, .CallingConvention);24745 const callconv_ty = try sema.getStdLangType(src, .CallingConvention);
24746 return .fromValue(Value.uninterpret(24746 return .fromValue(Value.uninterpret(
24747 @as(std.builtin.CallingConvention, .@"inline"),24747 @as(std.builtin.CallingConvention, .@"inline"),
24748 callconv_ty,24748 callconv_ty,
24749 pt,24749 pt,
24750 ) catch |err| switch (err) {24750 ) catch |err| switch (err) {
24751 error.TypeMismatch => @panic("std.builtin is corrupt"),24751 error.TypeMismatch => @panic("std.lang is corrupt"),
24752 error.OutOfMemory => |e| return e,24752 error.OutOfMemory => |e| return e,
24753 });24753 });
24754 },24754 },
24755 };24755 };
24756 return .fromType(try sema.getBuiltinType(src, builtin_type));24756 return .fromType(try sema.getStdLangType(src, std_lang_type));
24757}24757}
2475824758
24759fn zirInplaceArithResultTy(sema: *Sema, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref {24759fn 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...@@ -24788,14 +24788,14 @@ fn zirBranchHint(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstDat
24788 const uncoerced_hint = sema.resolveInst(extra.operand);24788 const uncoerced_hint = sema.resolveInst(extra.operand);
24789 const operand_src = block.builtinCallArgSrc(extra.node, 0);24789 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);
24792 const coerced_hint = try sema.coerce(block, hint_ty, uncoerced_hint, operand_src);24792 const coerced_hint = try sema.coerce(block, hint_ty, uncoerced_hint, operand_src);
24793 const hint_val = try sema.resolveConstDefinedValue(block, operand_src, coerced_hint, .{ .simple = .operand_branchHint });24793 const hint_val = try sema.resolveConstDefinedValue(block, operand_src, coerced_hint, .{ .simple = .operand_branchHint });
2479424794
24795 // We only apply the first hint in a branch.24795 // We only apply the first hint in a branch.
24796 // This allows user-provided hints to override implicit cold hints.24796 // This allows user-provided hints to override implicit cold hints.
24797 if (sema.branch_hint == null) {24797 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);
24799 }24799 }
24800}24800}
2480124801
...@@ -25148,7 +25148,7 @@ fn getPanicIdFunc(sema: *Sema, src: LazySrcLoc, panic_id: Zcu.SimplePanicId) !In...@@ -25148,7 +25148,7 @@ fn getPanicIdFunc(sema: *Sema, src: LazySrcLoc, panic_id: Zcu.SimplePanicId) !In
25148 const zcu = sema.pt.zcu;25148 const zcu = sema.pt.zcu;
25149 const io = zcu.comp.io;25149 const io = zcu.comp.io;
25150 try sema.ensureMemoizedStateResolved(src, .panic);25150 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());
25152 switch (sema.owner.unwrap()) {25152 switch (sema.owner.unwrap()) {
25153 .@"comptime",25153 .@"comptime",
25154 .nav_ty,25154 .nav_ty,
...@@ -25292,7 +25292,7 @@ fn safetyPanicUnwrapError(sema: *Sema, block: *Block, src: LazySrcLoc, err: Air....@@ -25292,7 +25292,7 @@ fn safetyPanicUnwrapError(sema: *Sema, block: *Block, src: LazySrcLoc, err: Air.
25292 if (!zcu.backendSupportsFeature(.panic_fn)) {25292 if (!zcu.backendSupportsFeature(.panic_fn)) {
25293 _ = try block.addNoOp(.trap);25293 _ = try block.addNoOp(.trap);
25294 } else {25294 } else {
25295 const panic_fn = try getBuiltin(sema, src, .@"panic.unwrapError");25295 const panic_fn = try getStdLangValue(sema, src, .@"panic.unwrapError");
25296 try sema.callBuiltin(block, src, Air.internedToRef(panic_fn), .auto, &.{err}, .@"safety check");25296 try sema.callBuiltin(block, src, Air.internedToRef(panic_fn), .auto, &.{err}, .@"safety check");
25297 }25297 }
25298}25298}
...@@ -25382,7 +25382,7 @@ fn addSafetyCheckCall(...@@ -25382,7 +25382,7 @@ fn addSafetyCheckCall(
25382 parent_block: *Block,25382 parent_block: *Block,
25383 src: LazySrcLoc,25383 src: LazySrcLoc,
25384 ok: Air.Inst.Ref,25384 ok: Air.Inst.Ref,
25385 comptime func_decl: Zcu.BuiltinDecl,25385 comptime func_decl: Zcu.StdLangDecl,
25386 args: []const Air.Inst.Ref,25386 args: []const Air.Inst.Ref,
25387) !void {25387) !void {
25388 assert(!parent_block.isComptime());25388 assert(!parent_block.isComptime());
...@@ -25406,7 +25406,7 @@ fn addSafetyCheckCall(...@@ -25406,7 +25406,7 @@ fn addSafetyCheckCall(
25406 if (!zcu.backendSupportsFeature(.panic_fn)) {25406 if (!zcu.backendSupportsFeature(.panic_fn)) {
25407 _ = try fail_block.addNoOp(.trap);25407 _ = try fail_block.addNoOp(.trap);
25408 } else {25408 } else {
25409 const panic_fn = try getBuiltin(sema, src, func_decl);25409 const panic_fn = try getStdLangValue(sema, src, func_decl);
25410 try sema.callBuiltin(&fail_block, src, Air.internedToRef(panic_fn), .auto, args, .@"safety check");25410 try sema.callBuiltin(&fail_block, src, Air.internedToRef(panic_fn), .auto, args, .@"safety check");
25411 }25411 }
2541225412
...@@ -33114,10 +33114,10 @@ pub fn analyzeAsAddressSpace(...@@ -33114,10 +33114,10 @@ pub fn analyzeAsAddressSpace(
33114 ctx: std.Target.AddressSpaceContext,33114 ctx: std.Target.AddressSpaceContext,
33115) !std.builtin.AddressSpace {33115) !std.builtin.AddressSpace {
33116 const pt = sema.pt;33116 const pt = sema.pt;
33117 const addrspace_ty = try sema.getBuiltinType(src, .AddressSpace);33117 const addrspace_ty = try sema.getStdLangType(src, .AddressSpace);
33118 const coerced = try sema.coerce(block, addrspace_ty, air_ref, src);33118 const coerced = try sema.coerce(block, addrspace_ty, air_ref, src);
33119 const addrspace_val = try sema.resolveConstDefinedValue(block, src, coerced, .{ .simple = .@"addrspace" });33119 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);
33121 const target = pt.zcu.getTarget();33121 const target = pt.zcu.getTarget();
3312233122
33123 if (!target.supportsAddressSpace(address_space, ctx)) {33123 if (!target.supportsAddressSpace(address_space, ctx)) {
...@@ -33819,15 +33819,15 @@ pub const type_resolution = @import("Sema/type_resolution.zig");...@@ -33819,15 +33819,15 @@ pub const type_resolution = @import("Sema/type_resolution.zig");
33819pub const ensureLayoutResolved = type_resolution.ensureLayoutResolved;33819pub const ensureLayoutResolved = type_resolution.ensureLayoutResolved;
33820pub const ensureStructDefaultsResolved = type_resolution.ensureStructDefaultsResolved;33820pub 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 {
33823 assert(decl.kind() == .type);33823 assert(decl.kind() == .type);
33824 try sema.ensureMemoizedStateResolved(src, decl.stage());33824 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));
33826}33826}
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 {
33828 assert(decl.kind() != .type);33828 assert(decl.kind() != .type);
33829 try sema.ensureMemoizedStateResolved(src, decl.stage());33829 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);
33831}33831}
3383233832
33833pub const NavPtrModifiers = struct {33833pub const NavPtrModifiers = struct {
...@@ -33928,30 +33928,30 @@ pub fn analyzeMemoizedState(sema: *Sema, stage: InternPool.MemoizedStateStage) C...@@ -33928,30 +33928,30 @@ pub fn analyzeMemoizedState(sema: *Sema, stage: InternPool.MemoizedStateStage) C
33928 };33928 };
33929 defer block.instructions.deinit(gpa);33929 defer block.instructions.deinit(gpa);
3393033930
33931 const std_builtin_ty: Type = ty: {33931 const std_lang_ty: Type = ty: {
33932 const std_src = block.nodeOffset(.zero);33932 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);
33934 const nav = try sema.namespaceLookup(&block, std_src, block.namespace, decl_name) orelse {33934 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'", .{});
33936 };33936 };
33937 const uncoerced_val = try sema.analyzeNavVal(&block, std_src, nav);33937 const uncoerced_val = try sema.analyzeNavVal(&block, std_src, nav);
33938 const decl_src: LazySrcLoc = .{33938 const decl_src: LazySrcLoc = .{
33939 .base_node_inst = ip.getNav(nav).srcInst(ip),33939 .base_node_inst = ip.getNav(nav).srcInst(ip),
33940 .offset = .nodeOffset(.zero),33940 .offset = .nodeOffset(.zero),
33941 };33941 };
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);
33943 };33943 };
3394433944
33945 var any_changed = false;33945 var any_changed = false;
3394633946
33947 inline for (comptime std.enums.values(Zcu.BuiltinDecl)) |builtin_decl| {33947 inline for (comptime std.enums.values(Zcu.StdLangDecl)) |std_lang_decl| {
33948 if (stage == comptime builtin_decl.stage()) {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 builtin_decl.access()) {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_builtin_ty, "std.builtin", name },33950 .direct => |name| .{ std_lang_ty, "std.lang", name },
33951 .nested => |nested| access: {33951 .nested => |nested| access: {
33952 const parent_decl, const name = nested;33952 const parent_decl, const name = nested;
33953 const parent_ty: Type = .fromInterned(zcu.builtin_decl_values.get(parent_decl));33953 const parent_ty: Type = .fromInterned(zcu.std_lang_decl_values.get(parent_decl));
33954 break :access .{ parent_ty, "std.builtin." ++ @tagName(parent_decl), name };33954 break :access .{ parent_ty, "std.lang." ++ @tagName(parent_decl), name };
33955 },33955 },
33956 };33956 };
3395733957
...@@ -33970,25 +33970,25 @@ pub fn analyzeMemoizedState(sema: *Sema, stage: InternPool.MemoizedStateStage) C...@@ -33970,25 +33970,25 @@ pub fn analyzeMemoizedState(sema: *Sema, stage: InternPool.MemoizedStateStage) C
33970 .offset = .nodeOffset(.zero),33970 .offset = .nodeOffset(.zero),
33971 };33971 };
3397233972
33973 const val: Value = switch (builtin_decl.kind()) {33973 const val: Value = switch (std_lang_decl.kind()) {
33974 .type => val: {33974 .type => val: {
33975 const ty = try sema.analyzeAsType(&block, decl_src, .std_builtin_decl, uncoerced_val);33975 const ty = try sema.analyzeAsType(&block, decl_src, .std_lang_decl, uncoerced_val);
33976 try sema.ensureLayoutResolved(ty, decl_src, .builtin_type);33976 try sema.ensureLayoutResolved(ty, decl_src, .std_lang_type);
33977 break :val ty.toValue();33977 break :val ty.toValue();
33978 },33978 },
33979 .func => val: {33979 .func => val: {
33980 const func_ty = try sema.getExpectedBuiltinFnType(builtin_decl);33980 const func_ty = try sema.getExpectedBuiltinFnType(std_lang_decl);
33981 const coerced = try sema.coerce(&block, func_ty, uncoerced_val, decl_src);33981 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 });
33983 },33983 },
33984 .string => val: {33984 .string => val: {
33985 const coerced = try sema.coerce(&block, .slice_const_u8, uncoerced_val, decl_src);33985 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 });
33987 },33987 },
33988 };33988 };
3398933989
33990 if (zcu.builtin_decl_values.get(builtin_decl) != val.toIntern()) {33990 if (zcu.std_lang_decl_values.get(std_lang_decl) != val.toIntern()) {
33991 zcu.builtin_decl_values.set(builtin_decl, val.toIntern());33991 zcu.std_lang_decl_values.set(std_lang_decl, val.toIntern());
33992 any_changed = true;33992 any_changed = true;
33993 }33993 }
33994 }33994 }
...@@ -33998,7 +33998,7 @@ pub fn analyzeMemoizedState(sema: *Sema, stage: InternPool.MemoizedStateStage) C...@@ -33998,7 +33998,7 @@ pub fn analyzeMemoizedState(sema: *Sema, stage: InternPool.MemoizedStateStage) C
33998}33998}
3399933999
34000/// Given that `decl.kind() == .func`, get the type expected of the function.34000/// 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 {
34002 const pt = sema.pt;34002 const pt = sema.pt;
34003 return switch (decl) {34003 return switch (decl) {
34004 // `noinline fn () void`34004 // `noinline fn () void`
src/Sema/type_resolution.zig+2-2
...@@ -35,7 +35,7 @@ pub const LayoutResolveReason = enum {...@@ -35,7 +35,7 @@ pub const LayoutResolveReason = enum {
35 @"export",35 @"export",
36 @"extern",36 @"extern",
37 asm_out_type,37 asm_out_type,
38 builtin_type,38 std_lang_type,
3939
40 /// Written after string: "while resolving type 'T' "40 /// Written after string: "while resolving type 'T' "
41 /// e.g. "while resolving type 'MyStruct' for variable declared here"41 /// e.g. "while resolving type 'MyStruct' for variable declared here"
...@@ -62,7 +62,7 @@ pub const LayoutResolveReason = enum {...@@ -62,7 +62,7 @@ pub const LayoutResolveReason = enum {
62 .@"export" => "for export here",62 .@"export" => "for export here",
63 .@"extern" => "for extern declaration here",63 .@"extern" => "for extern declaration here",
64 .asm_out_type => "for inline assembly output type declared here",64 .asm_out_type => "for inline assembly output type declared here",
65 .builtin_type => "from 'std.builtin'",65 .std_lang_type => "from 'std.lang'",
66 // zig fmt: on66 // zig fmt: on
67 };67 };
68 }68 }
src/Value.zig+5-5
...@@ -2199,19 +2199,19 @@ pub fn pointerDerivation(ptr_val: Value, arena: Allocator, pt: Zcu.PerThread, op...@@ -2199,19 +2199,19 @@ pub fn pointerDerivation(ptr_val: Value, arena: Allocator, pt: Zcu.PerThread, op
2199const InterpretMode = enum {2199const InterpretMode = enum {
2200 /// In this mode, types are assumed to match what the compiler was built with in terms of field2200 /// In this mode, types are assumed to match what the compiler was built with in terms of field
2201 /// order, field types, etc. This improves compiler performance. However, it means that certain2201 /// 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.
2203 direct,2203 direct,
2204 /// In this mode, various details of the type are allowed to differ from what the compiler was built2204 /// In this mode, various details of the type are allowed to differ from what the compiler was built
2205 /// with. Fields are matched by name rather than index; added struct fields are ignored, and removed2205 /// with. Fields are matched by name rather than index; added struct fields are ignored, and removed
2206 /// struct fields use their default value if one exists. This is slower than `.direct`, but permits2206 /// 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 it2207 /// making certain changes to `std.lang` (in particular reordering/adding/removing fields), so it is
2208 /// is useful when applying breaking changes.2208 /// useful when applying breaking changes.
2209 by_name,2209 by_name,
2210};2210};
2211const interpret_mode: InterpretMode = @field(InterpretMode, @tagName(build_options.value_interpret_mode));2211const interpret_mode: InterpretMode = @field(InterpretMode, @tagName(build_options.value_interpret_mode));
22122212
2213/// Given a `Value` representing a comptime-known value of type `T`, unwrap it into an actual `T` known to the compiler.2213/// 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.
2215pub fn interpret(val: Value, comptime T: type, pt: Zcu.PerThread) error{ OutOfMemory, UndefinedValue, TypeMismatch }!T {2215pub fn interpret(val: Value, comptime T: type, pt: Zcu.PerThread) error{ OutOfMemory, UndefinedValue, TypeMismatch }!T {
2216 const zcu = pt.zcu;2216 const zcu = pt.zcu;
2217 const io = zcu.comp.io;2217 const io = zcu.comp.io;
...@@ -2313,7 +2313,7 @@ pub fn interpret(val: Value, comptime T: type, pt: Zcu.PerThread) error{ OutOfMe...@@ -2313,7 +2313,7 @@ pub fn interpret(val: Value, comptime T: type, pt: Zcu.PerThread) error{ OutOfMe
2313}2313}
23142314
2315/// Given any `val` and a `Type` corresponding `@TypeOf(val)`, construct a `Value` representing it which can be used2315/// 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.
2317/// This is the inverse of `interpret`.2317/// This is the inverse of `interpret`.
2318pub fn uninterpret(val: anytype, ty: Type, pt: Zcu.PerThread) error{ OutOfMemory, TypeMismatch }!Value {2318pub fn uninterpret(val: anytype, ty: Type, pt: Zcu.PerThread) error{ OutOfMemory, TypeMismatch }!Value {
2319 const T = @TypeOf(val);2319 const T = @TypeOf(val);
src/Zcu.zig+17-17
...@@ -333,7 +333,7 @@ all_type_references: std.ArrayList(TypeReference) = .empty,...@@ -333,7 +333,7 @@ all_type_references: std.ArrayList(TypeReference) = .empty,
333free_type_references: std.ArrayList(u32) = .empty,333free_type_references: std.ArrayList(u32) = .empty,
334334
335/// Populated by analysis of `AnalUnit.wrap(.{ .memoized_state = s })`, where `s` depends on the element.335/// 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
338incremental_debug_state: if (build_options.enable_debug_extensions) IncrementalDebugState else void =338incremental_debug_state: if (build_options.enable_debug_extensions) IncrementalDebugState else void =
339 if (build_options.enable_debug_extensions) .init else {},339 if (build_options.enable_debug_extensions) .init else {},
...@@ -425,11 +425,11 @@ pub const EmbedTableAdapter = struct {...@@ -425,11 +425,11 @@ pub const EmbedTableAdapter = struct {
425 }425 }
426};426};
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`.
429/// The name must exactly match the declaration name, as comptime logic is used to compute the namespace accesses.429/// The name must exactly match the declaration name, as comptime logic is used to compute the namespace accesses.
430/// Parent namespaces must be before their children in this enum. For instance, `.Type` must be before `.@"Type.Fn"`.430/// 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`.431/// Additionally, parent namespaces must be resolved in the same stage as their children; see `StdLangDecl.stage`.
432pub const BuiltinDecl = enum {432pub const StdLangDecl = enum {
433 Signedness,433 Signedness,
434 AddressSpace,434 AddressSpace,
435 CallingConvention,435 CallingConvention,
...@@ -508,7 +508,7 @@ pub const BuiltinDecl = enum {...@@ -508,7 +508,7 @@ pub const BuiltinDecl = enum {
508 @"assembly.Clobbers",508 @"assembly.Clobbers",
509509
510 /// Determines what kind of validation will be done to the decl's value.510 /// 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 } {
512 return switch (decl) {512 return switch (decl) {
513 .returnError => .func,513 .returnError => .func,
514514
...@@ -593,7 +593,7 @@ pub const BuiltinDecl = enum {...@@ -593,7 +593,7 @@ pub const BuiltinDecl = enum {
593 }593 }
594594
595 /// Resolution of these values is done in three distinct stages:595 /// Resolution of these values is done in three distinct stages:
596 /// * Resolution of `std.builtin.Panic` and everything under it596 /// * Resolution of `std.lang.Panic` and everything under it
597 /// * Resolution of `VaList`597 /// * Resolution of `VaList`
598 /// * Resolution of `assembly`598 /// * Resolution of `assembly`
599 /// * Everything else599 /// * Everything else
...@@ -606,12 +606,12 @@ pub const BuiltinDecl = enum {...@@ -606,12 +606,12 @@ pub const BuiltinDecl = enum {
606 /// by itself.606 /// by itself.
607 ///607 ///
608 /// `assembly` is separate because its value depends on the target.608 /// `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 {
610 return switch (decl) {610 return switch (decl) {
611 .VaList => .va_list,611 .VaList => .va_list,
612 .assembly, .@"assembly.Clobbers" => .assembly,612 .assembly, .@"assembly.Clobbers" => .assembly,
613 else => {613 else => {
614 if (@intFromEnum(decl) <= @intFromEnum(BuiltinDecl.@"Type.Declaration")) {614 if (@intFromEnum(decl) <= @intFromEnum(StdLangDecl.@"Type.Declaration")) {
615 return .main;615 return .main;
616 } else {616 } else {
617 return .panic;617 return .panic;
...@@ -621,24 +621,24 @@ pub const BuiltinDecl = enum {...@@ -621,24 +621,24 @@ pub const BuiltinDecl = enum {
621 }621 }
622622
623 /// Based on the tag name, determines how to access this decl; either as a direct child of the623 /// 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.624 /// `std.lang` namespace, or as a child of some preceding `StdLangDecl` value.
625 pub fn access(decl: BuiltinDecl) union(enum) {625 pub fn access(decl: StdLangDecl) union(enum) {
626 direct: []const u8,626 direct: []const u8,
627 nested: struct { BuiltinDecl, []const u8 },627 nested: struct { StdLangDecl, []const u8 },
628 } {628 } {
629 @setEvalBranchQuota(2000);629 @setEvalBranchQuota(2000);
630 return switch (decl) {630 return switch (decl) {
631 inline else => |tag| {631 inline else => |tag| {
632 const name = @tagName(tag);632 const name = @tagName(tag);
633 const split = (comptime std.mem.lastIndexOfScalar(u8, name, '.')) orelse return .{ .direct = name };633 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]);
635 comptime assert(@intFromEnum(parent) < @intFromEnum(tag)); // dependencies ordered correctly635 comptime assert(@intFromEnum(parent) < @intFromEnum(tag)); // dependencies ordered correctly
636 return .{ .nested = .{ parent, name[split + 1 ..] } };636 return .{ .nested = .{ parent, name[split + 1 ..] } };
637 },637 },
638 };638 };
639 }639 }
640640
641 const Memoized = std.enums.EnumArray(BuiltinDecl, InternPool.Index);641 const Memoized = std.enums.EnumArray(StdLangDecl, InternPool.Index);
642};642};
643643
644pub const SimplePanicId = enum {644pub const SimplePanicId = enum {
...@@ -662,7 +662,7 @@ pub const SimplePanicId = enum {...@@ -662,7 +662,7 @@ pub const SimplePanicId = enum {
662 memcpy_alias,662 memcpy_alias,
663 noreturn_returned,663 noreturn_returned,
664664
665 pub fn toBuiltin(id: SimplePanicId) BuiltinDecl {665 pub fn toStdLangDecl(id: SimplePanicId) StdLangDecl {
666 return switch (id) {666 return switch (id) {
667 // zig fmt: off667 // zig fmt: off
668 .reached_unreachable => .@"panic.reachedUnreachable",668 .reached_unreachable => .@"panic.reachedUnreachable",
...@@ -3941,7 +3941,7 @@ pub fn addGlobalAssembly(zcu: *Zcu, unit: AnalUnit, source: []const u8) !void {...@@ -3941,7 +3941,7 @@ pub fn addGlobalAssembly(zcu: *Zcu, unit: AnalUnit, source: []const u8) !void {
39413941
3942pub const Feature = enum {3942pub const Feature = enum {
3943 /// When this feature is enabled, Sema will emit calls to3943 /// When this feature is enabled, Sema will emit calls to
3944 /// `std.builtin.panic` functions for things like safety checks and3944 /// `std.lang.panic` functions for things like safety checks and
3945 /// unreachables. Otherwise traps will be emitted.3945 /// unreachables. Otherwise traps will be emitted.
3946 panic_fn,3946 panic_fn,
3947 /// When this feature is enabled, Sema will insert tracer functions for gathering a stack3947 /// When this feature is enabled, Sema will insert tracer functions for gathering a stack
...@@ -4995,7 +4995,7 @@ fn addDependencyLoopErrorLine(...@@ -4995,7 +4995,7 @@ fn addDependencyLoopErrorLine(
4995 }),4995 }),
4996 .memoized_state => |stage| switch (stage) {4996 .memoized_state => |stage| switch (stage) {
4997 .panic => try eb.printString("{f} requires panic handler for call here", .{fmt_source}),4997 .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}),
4999 },4999 },
5000 .func => |func| try eb.printString("{f} uses inferred error set of function '{f}' here", .{5000 .func => |func| try eb.printString("{f} uses inferred error set of function '{f}' here", .{
5001 fmt_source, ip.getNav(zcu.funcInfo(func).owner_nav).fqn.fmt(ip),5001 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...@@ -5046,7 +5046,7 @@ fn formatDependencyLoopSourceUnit(data: FormatAnalUnit, w: *Io.Writer) Io.Writer
5046 .nav_ty => |nav| try w.print("type of declaration '{f}'", .{ip.getNav(nav).fqn.fmt(ip)}),5046 .nav_ty => |nav| try w.print("type of declaration '{f}'", .{ip.getNav(nav).fqn.fmt(ip)}),
5047 .memoized_state => |stage| switch (stage) {5047 .memoized_state => |stage| switch (stage) {
5048 .panic => try w.writeAll("panic handler"),5048 .panic => try w.writeAll("panic handler"),
5049 else => try w.writeAll("'std.builtin' declarations"),5049 else => try w.writeAll("'std.lang' declarations"),
5050 },5050 },
5051 .type_layout => |ty| try w.print("type '{f}'", .{5051 .type_layout => |ty| try w.print("type '{f}'", .{
5052 Type.fromInterned(ty).containerTypeName(ip).fmt(ip),5052 Type.fromInterned(ty).containerTypeName(ip).fmt(ip),
src/Zcu/PerThread.zig+3-3
...@@ -1083,13 +1083,13 @@ pub fn ensureMemoizedStateUpToDate(...@@ -1083,13 +1083,13 @@ pub fn ensureMemoizedStateUpToDate(
1083 } else {1083 } else {
1084 if (prev_failed) return error.AnalysisFail;1084 if (prev_failed) return error.AnalysisFail;
1085 // We use an arbitrary element to check if the state has been resolved yet.1085 // 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) {
1087 .main => .Type,1087 .main => .Type,
1088 .panic => .panic,1088 .panic => .panic,
1089 .va_list => .VaList,1089 .va_list => .VaList,
1090 .assembly => .assembly,1090 .assembly => .assembly,
1091 };1091 };
1092 if (zcu.builtin_decl_values.get(to_check) != .none) return;1092 if (zcu.std_lang_decl_values.get(to_check) != .none) return;
1093 }1093 }
10941094
1095 if (zcu.comp.debugIncremental()) {1095 if (zcu.comp.debugIncremental()) {
...@@ -3751,7 +3751,7 @@ pub fn populateTestFunctions(pt: Zcu.PerThread) Allocator.Error!void {...@@ -3751,7 +3751,7 @@ pub fn populateTestFunctions(pt: Zcu.PerThread) Allocator.Error!void {
37513751
3752 // Our job is to correctly set the value of the `test_functions` declaration if it has been3752 // Our job is to correctly set the value of the `test_functions` declaration if it has been
3753 // analyzed and sent to codegen, It usually will have been, because the test runner will3753 // 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 been3754 // reference it, and `std.lang` shouldn't have type errors. However, if it hasn't been
3755 // analyzed, we will just terminate early, since clearly the test runner hasn't referenced3755 // analyzed, we will just terminate early, since clearly the test runner hasn't referenced
3756 // `test_functions` so there's no point populating it. More to the the point, we potentially3756 // `test_functions` so there's no point populating it. More to the the point, we potentially
3757 // *can't* populate it without doing some type resolution, and... let's try to leave Sema in3757 // *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...@@ -7981,7 +7981,7 @@ fn emit(isel: *Select, instruction: codegen.aarch64.encoding.Instruction) !void
7981fn emitPanic(isel: *Select, panic_id: Zcu.SimplePanicId) !void {7981fn emitPanic(isel: *Select, panic_id: Zcu.SimplePanicId) !void {
7982 const zcu = isel.pt.zcu;7982 const zcu = isel.pt.zcu;
7983 try isel.nav_relocs.append(zcu.gpa, .{7983 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()))) {
7985 else => unreachable,7985 else => unreachable,
7986 inline .@"extern", .func => |func| func.owner_nav,7986 inline .@"extern", .func => |func| func.owner_nav,
7987 },7987 },
src/codegen/llvm.zig+2-2
...@@ -1755,7 +1755,7 @@ pub const Object = struct {...@@ -1755,7 +1755,7 @@ pub const Object = struct {
1755 }1755 }
17561756
1757 // If the first export specifies a linksection, set the exported variable's section to that1757 // 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 actually1758 // one. This is kind of a hack because `std.lang.ExportOptions.section` doesn't actually
1759 // make much sense: the linksection should be associated with the declaration itself rather1759 // make much sense: the linksection should be associated with the declaration itself rather
1760 // than some particular symbol it is exported as!1760 // than some particular symbol it is exported as!
1761 if (export_indices[0].ptr(zcu).opts.section.toSlice(ip)) |section_slice| {1761 if (export_indices[0].ptr(zcu).opts.section.toSlice(ip)) |section_slice| {
...@@ -3378,7 +3378,7 @@ pub const Object = struct {...@@ -3378,7 +3378,7 @@ pub const Object = struct {
3378 }3378 }
33793379
3380 if (fn_info.cc == .auto and zcu.comp.config.any_error_tracing) {3380 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`.
3382 const llvm_ptr_ty = try o.builder.ptrType(toLlvmAddressSpace(.generic, target));3382 const llvm_ptr_ty = try o.builder.ptrType(toLlvmAddressSpace(.generic, target));
3383 try llvm_params.append(o.gpa, llvm_ptr_ty);3383 try llvm_params.append(o.gpa, llvm_ptr_ty);
3384 }3384 }
src/codegen/llvm/FuncGen.zig+1-1
...@@ -891,7 +891,7 @@ fn buildSimplePanic(fg: *FuncGen, panic_id: Zcu.SimplePanicId) Allocator.Error!v...@@ -891,7 +891,7 @@ fn buildSimplePanic(fg: *FuncGen, panic_id: Zcu.SimplePanicId) Allocator.Error!v
891 const o = fg.object;891 const o = fg.object;
892 const zcu = o.zcu;892 const zcu = o.zcu;
893 const target = zcu.getTarget();893 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()));
895 const fn_info = zcu.typeToFunc(.fromInterned(panic_func.ty)).?;895 const fn_info = zcu.typeToFunc(.fromInterned(panic_func.ty)).?;
896 const llvm_panic_fn_ty = try o.lowerType(.fromInterned(panic_func.ty));896 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(...@@ -2358,7 +2358,7 @@ fn buildWideMul(
2358/// The SPIR-V backend is not yet advanced enough to support the std testing infrastructure.2358/// The SPIR-V backend is not yet advanced enough to support the std testing infrastructure.
2359/// In order to be able to run tests, we "temporarily" lower test kernels into separate entry-2359/// In order to be able to run tests, we "temporarily" lower test kernels into separate entry-
2360/// points. The test executor will then be able to invoke these to run the tests.2360/// 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`.
2362/// (anyerror!void has the same layout as anyerror).2362/// (anyerror!void has the same layout as anyerror).
2363/// Each test declaration generates a function like.2363/// Each test declaration generates a function like.
2364/// %anyerror = OpTypeInt 0 162364/// %anyerror = OpTypeInt 0 16
src/codegen/wasm/CodeGen.zig+1-1
...@@ -586,7 +586,7 @@ fn addExtraAssumeCapacity(cg: *CodeGen, extra: anytype) error{OutOfMemory}!u32 {...@@ -586,7 +586,7 @@ fn addExtraAssumeCapacity(cg: *CodeGen, extra: anytype) error{OutOfMemory}!u32 {
586 return result;586 return result;
587}587}
588588
589/// For `std.builtin.CallingConvention.auto`.589/// For `std.lang.CallingConvention.auto`.
590pub fn typeToValtype(ty: Type, zcu: *const Zcu, target: *const std.Target) std.wasm.Valtype {590pub fn typeToValtype(ty: Type, zcu: *const Zcu, target: *const std.Target) std.wasm.Valtype {
591 return switch (ty.zigTypeTag(zcu)) {591 return switch (ty.zigTypeTag(zcu)) {
592 .float => switch (ty.floatBits(target)) {592 .float => switch (ty.floatBits(target)) {
src/print_zir.zig+3-3
...@@ -693,7 +693,7 @@ const Writer = struct {...@@ -693,7 +693,7 @@ const Writer = struct {
693 .restore_err_ret_index => try self.writeRestoreErrRetIndex(stream, extended),693 .restore_err_ret_index => try self.writeRestoreErrRetIndex(stream, extended),
694 .closure_get => try self.writeClosureGet(stream, extended),694 .closure_get => try self.writeClosureGet(stream, extended),
695 .field_parent_ptr => try self.writeFieldParentPtr(stream, extended),695 .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),
697 .inplace_arith_result_ty => try self.writeInplaceArithResultTy(stream, extended),697 .inplace_arith_result_ty => try self.writeInplaceArithResultTy(stream, extended),
698698
699 .dbg_empty_stmt => try stream.writeAll("))"),699 .dbg_empty_stmt => try stream.writeAll("))"),
...@@ -2232,8 +2232,8 @@ const Writer = struct {...@@ -2232,8 +2232,8 @@ const Writer = struct {
2232 try self.writeSrcNode(stream, src_node);2232 try self.writeSrcNode(stream, src_node);
2233 }2233 }
22342234
2235 fn writeBuiltinValue(self: *Writer, stream: *std.Io.Writer, extended: Zir.Inst.Extended.InstData) !void {2235 fn writeStdLangValue(self: *Writer, stream: *std.Io.Writer, extended: Zir.Inst.Extended.InstData) !void {
2236 const val: Zir.Inst.BuiltinValue = @enumFromInt(extended.small);2236 const val: Zir.Inst.StdLangValue = @enumFromInt(extended.small);
2237 try stream.print("{s})) ", .{@tagName(val)});2237 try stream.print("{s})) ", .{@tagName(val)});
2238 const src_node: Ast.Node.Offset = @enumFromInt(@as(i32, @bitCast(extended.operand)));2238 const src_node: Ast.Node.Offset = @enumFromInt(@as(i32, @bitCast(extended.operand)));
2239 try self.writeSrcNode(stream, src_node);2239 try self.writeSrcNode(stream, src_node);
test/cases/compile_errors/invalid_member_of_builtin_enum.zig+3-3
...@@ -1,10 +1,10 @@...@@ -1,10 +1,10 @@
1const builtin = @import("std").builtin;1const lang = @import("std").lang;
2export fn entry() void {2export fn entry() void {
3 const foo = builtin.OptimizeMode.x86;3 const foo = lang.OptimizeMode.x86;
4 _ = foo;4 _ = foo;
5}5}
66
7// error7// error
8//8//
9// :3:38: error: enum 'builtin.OptimizeMode' has no member named 'x86'9// :3:35: error: enum 'lang.OptimizeMode' has no member named 'x86'
10// : note: enum declared here10// : 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 {...@@ -16,4 +16,4 @@ pub fn main() void {
16// error16// error
17// target=x86_64-linux17// target=x86_64-linux
18//18//
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 {...@@ -12,6 +12,6 @@ export fn entry() void {
1212
13// error13// error
14//14//
15// :9:54: error: values of type 'builtin.Type.StructField' must be comptime-known, but index value is runtime-known15// :9:54: error: values of type 'lang.Type.StructField' must be comptime-known, but index value is runtime-known
16// : note: struct requires comptime because of this field16// : note: struct requires comptime because of this field
17// : note: types are not available at runtime17// : 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 {...@@ -16,10 +16,10 @@ export fn entryU() void {
1616
17// error17// error
18//18//
19// :2:14: error: expected type 'builtin.Signedness', found 'comptime_int'19// :2:14: error: expected type 'lang.Signedness', found 'comptime_int'
20// :?:?: note: enum declared here20// :?:?: note: enum declared here
21// :6:15: error: expected type 'type', found 'comptime_int'21// :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'
23// :?:?: enum declared here23// :?:?: 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'
25// :?:?: enum declared here25// :?:?: 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 {...@@ -5,5 +5,5 @@ export fn entry() void {
55
6// error6// error
7//7//
8// :3:47: error: expected type 'builtin.AtomicOrder', found 'u32'8// :3:47: error: expected type 'lang.AtomicOrder', found 'u32'
9// :?:?: note: enum declared here9// :?:?: note: enum declared here
test/cases/compile_errors/wrong_types_given_to_export.zig+1-1
...@@ -5,5 +5,5 @@ comptime {...@@ -5,5 +5,5 @@ comptime {
55
6// error6// error
7//7//
8// :3:42: error: expected type 'builtin.GlobalLinkage', found 'u32'8// :3:42: error: expected type 'lang.GlobalLinkage', found 'u32'
9// :?:?: note: enum declared here9// :?:?: note: enum declared here