Commit dfb3521160

Andrew Kelley <andrew@ziglang.org>
2023-05-21 00:50:56
compiler: remove var_args_param_type from SimpleType
This is now represented instead by a special `InternPool.Index.Tag` that has no corresponding type/value.
1 parent 115c089
src/Air.zig
@@ -905,7 +905,6 @@ pub const Inst = struct {
         const_slice_u8_sentinel_0_type = @enumToInt(InternPool.Index.const_slice_u8_sentinel_0_type),
         anyerror_void_error_union_type = @enumToInt(InternPool.Index.anyerror_void_error_union_type),
         generic_poison_type = @enumToInt(InternPool.Index.generic_poison_type),
-        var_args_param_type = @enumToInt(InternPool.Index.var_args_param_type),
         empty_struct_type = @enumToInt(InternPool.Index.empty_struct_type),
         undef = @enumToInt(InternPool.Index.undef),
         zero = @enumToInt(InternPool.Index.zero),
@@ -926,6 +925,9 @@ pub const Inst = struct {
         empty_struct = @enumToInt(InternPool.Index.empty_struct),
         generic_poison = @enumToInt(InternPool.Index.generic_poison),
 
+        /// This Ref does not correspond to any AIR instruction or constant
+        /// value. It is used to handle argument types of var args functions.
+        var_args_param_type = @enumToInt(InternPool.Index.var_args_param_type),
         /// This Ref does not correspond to any AIR instruction or constant
         /// value and may instead be used as a sentinel to indicate null.
         none = @enumToInt(InternPool.Index.none),
src/InternPool.zig
@@ -959,7 +959,6 @@ pub const Index = enum(u32) {
     const_slice_u8_sentinel_0_type,
     anyerror_void_error_union_type,
     generic_poison_type,
-    var_args_param_type,
     /// `@TypeOf(.{})`
     empty_struct_type,
 
@@ -1002,6 +1001,8 @@ pub const Index = enum(u32) {
     /// is not known until generic function instantiation.
     generic_poison,
 
+    /// Used by Air/Sema only.
+    var_args_param_type = std.math.maxInt(u32) - 1,
     none = std.math.maxInt(u32),
 
     _,
@@ -1195,9 +1196,6 @@ pub const static_keys = [_]Key{
     // generic_poison_type
     .{ .simple_type = .generic_poison },
 
-    // var_args_param_type
-    .{ .simple_type = .var_args_param },
-
     // empty_struct_type
     .{ .anon_struct_type = .{
         .types = &.{},
@@ -1570,7 +1568,6 @@ pub const SimpleType = enum(u32) {
     type_info,
 
     generic_poison,
-    var_args_param,
 };
 
 pub const SimpleValue = enum(u32) {
src/Sema.zig
@@ -31657,7 +31657,6 @@ pub fn resolveTypeRequiresComptime(sema: *Sema, ty: Type) CompileError!bool {
                 .anyerror,
                 .noreturn,
                 .generic_poison,
-                .var_args_param,
                 .atomic_order,
                 .atomic_rmw_op,
                 .calling_convention,
@@ -31856,6 +31855,8 @@ pub fn resolveTypeFields(sema: *Sema, ty: Type) CompileError!Type {
     const mod = sema.mod;
 
     switch (ty.ip_index) {
+        .var_args_param_type => unreachable,
+
         // TODO: After the InternPool transition is complete, change this to `unreachable`.
         .none => return ty,
 
@@ -31909,7 +31910,6 @@ pub fn resolveTypeFields(sema: *Sema, ty: Type) CompileError!Type {
         .const_slice_u8_sentinel_0_type,
         .anyerror_void_error_union_type,
         .generic_poison_type,
-        .var_args_param_type,
         .empty_struct_type,
         => return ty,
 
@@ -33123,7 +33123,6 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {
                 .undefined => Value.undef,
 
                 .generic_poison => return error.GenericPoison,
-                .var_args_param => unreachable,
             },
             .struct_type => |struct_type| {
                 const resolved_ty = try sema.resolveTypeFields(ty);
@@ -33678,8 +33677,6 @@ pub fn typeRequiresComptime(sema: *Sema, ty: Type) CompileError!bool {
                 .enum_literal,
                 .type_info,
                 => true,
-
-                .var_args_param => unreachable,
             },
             .struct_type => |struct_type| {
                 const struct_obj = mod.structPtrUnwrap(struct_type.index) orelse return false;
src/type.zig
@@ -105,7 +105,6 @@ pub const Type = struct {
                     .type_info => .Union,
 
                     .generic_poison => return error.GenericPoison,
-                    .var_args_param => unreachable,
                 },
 
                 // values, not types
@@ -803,7 +802,6 @@ pub const Type = struct {
                     => false,
 
                     .generic_poison => unreachable,
-                    .var_args_param => unreachable,
                 },
                 .struct_type => |struct_type| {
                     const struct_obj = mod.structPtrUnwrap(struct_type.index) orelse {
@@ -952,8 +950,6 @@ pub const Type = struct {
                 .type_info,
                 .generic_poison,
                 => false,
-
-                .var_args_param => unreachable,
             },
             .struct_type => |struct_type| {
                 const struct_obj = mod.structPtrUnwrap(struct_type.index) orelse {
@@ -1198,7 +1194,6 @@ pub const Type = struct {
 
                     .noreturn => unreachable,
                     .generic_poison => unreachable,
-                    .var_args_param => unreachable,
                 },
                 .struct_type => |struct_type| {
                     const struct_obj = mod.structPtrUnwrap(struct_type.index) orelse
@@ -1610,7 +1605,6 @@ pub const Type = struct {
                     .type_info => unreachable,
                     .noreturn => unreachable,
                     .generic_poison => unreachable,
-                    .var_args_param => unreachable,
                 },
                 .struct_type => |struct_type| switch (ty.containerLayout(mod)) {
                     .Packed => {
@@ -1841,7 +1835,6 @@ pub const Type = struct {
                 .undefined => unreachable,
                 .enum_literal => unreachable,
                 .generic_poison => unreachable,
-                .var_args_param => unreachable,
 
                 .atomic_order => unreachable, // missing call to resolveTypeFields
                 .atomic_rmw_op => unreachable, // missing call to resolveTypeFields
@@ -2717,7 +2710,6 @@ pub const Type = struct {
                     .undefined => return Value.undef,
 
                     .generic_poison => unreachable,
-                    .var_args_param => unreachable,
                 },
                 .struct_type => |struct_type| {
                     if (mod.structPtrUnwrap(struct_type.index)) |s| {
@@ -2896,8 +2888,6 @@ pub const Type = struct {
                     .enum_literal,
                     .type_info,
                     => true,
-
-                    .var_args_param => unreachable,
                 },
                 .struct_type => |struct_type| {
                     // A struct with no fields is not comptime-only.
src/Zir.zig
@@ -2112,7 +2112,6 @@ pub const Inst = struct {
         const_slice_u8_sentinel_0_type = @enumToInt(InternPool.Index.const_slice_u8_sentinel_0_type),
         anyerror_void_error_union_type = @enumToInt(InternPool.Index.anyerror_void_error_union_type),
         generic_poison_type = @enumToInt(InternPool.Index.generic_poison_type),
-        var_args_param_type = @enumToInt(InternPool.Index.var_args_param_type),
         empty_struct_type = @enumToInt(InternPool.Index.empty_struct_type),
         undef = @enumToInt(InternPool.Index.undef),
         zero = @enumToInt(InternPool.Index.zero),
@@ -2133,6 +2132,9 @@ pub const Inst = struct {
         empty_struct = @enumToInt(InternPool.Index.empty_struct),
         generic_poison = @enumToInt(InternPool.Index.generic_poison),
 
+        /// This tag is here to match Air and InternPool, however it is unused
+        /// for ZIR purposes.
+        var_args_param_type = @enumToInt(InternPool.Index.var_args_param_type),
         /// This Ref does not correspond to any ZIR instruction or constant
         /// value and may instead be used as a sentinel to indicate null.
         none = @enumToInt(InternPool.Index.none),