authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-05-18 20:02:10-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-06-10 20:47:53-07:00
log607737d841bc2279cbe5fee68a0a546b9a5a802e
treeabc69a87afc874b9257a9a02ab5042a5ad5cd7ea
parentf21ca3da190c8c64fd99c700f0840af59792b6b2

compiler: eliminate legacy Type.Tag.optional

Now optional types are only stored in InternPool.

2 files changed, 19 insertions(+), 184 deletions(-)

src/Sema.zig+6-44
...@@ -18589,12 +18589,10 @@ fn fieldType(...@@ -18589,12 +18589,10 @@ fn fieldType(
18589 return sema.addType(field.ty);18589 return sema.addType(field.ty);
18590 },18590 },
18591 .Optional => {18591 .Optional => {
18592 if (cur_ty.castTag(.optional)) |some| {18592 // Struct/array init through optional requires the child type to not be a pointer.
18593 // Struct/array init through optional requires the child type to not be a pointer.18593 // If the child of .optional is a pointer it'll error on the next loop.
18594 // If the child of .optional is a pointer it'll error on the next loop.18594 cur_ty = mod.intern_pool.indexToKey(cur_ty.ip_index).opt_type.toType();
18595 cur_ty = some.data;18595 continue;
18596 continue;
18597 }
18598 },18596 },
18599 .ErrorUnion => {18597 .ErrorUnion => {
18600 cur_ty = cur_ty.errorUnionPayload();18598 cur_ty = cur_ty.errorUnionPayload();
...@@ -20390,7 +20388,7 @@ fn zirAlignCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A...@@ -20390,7 +20388,7 @@ fn zirAlignCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
20390 ptr_info.@"align" = dest_align;20388 ptr_info.@"align" = dest_align;
20391 var dest_ty = try Type.ptr(sema.arena, sema.mod, ptr_info);20389 var dest_ty = try Type.ptr(sema.arena, sema.mod, ptr_info);
20392 if (ptr_ty.zigTypeTag(mod) == .Optional) {20390 if (ptr_ty.zigTypeTag(mod) == .Optional) {
20393 dest_ty = try Type.Tag.optional.create(sema.arena, dest_ty);20391 dest_ty = try mod.optionalType(dest_ty.toIntern());
20394 }20392 }
2039520393
20396 if (try sema.resolveDefinedValue(block, ptr_src, ptr)) |val| {20394 if (try sema.resolveDefinedValue(block, ptr_src, ptr)) |val| {
...@@ -31622,10 +31620,6 @@ pub fn resolveTypeRequiresComptime(sema: *Sema, ty: Type) CompileError!bool {...@@ -31622,10 +31620,6 @@ pub fn resolveTypeRequiresComptime(sema: *Sema, ty: Type) CompileError!bool {
31622 }31620 }
31623 },31621 },
3162431622
31625 .optional => {
31626 return sema.resolveTypeRequiresComptime(ty.optionalChild(mod));
31627 },
31628
31629 .error_union => return sema.resolveTypeRequiresComptime(ty.errorUnionPayload()),31623 .error_union => return sema.resolveTypeRequiresComptime(ty.errorUnionPayload()),
31630 },31624 },
31631 else => switch (mod.intern_pool.indexToKey(ty.ip_index)) {31625 else => switch (mod.intern_pool.indexToKey(ty.ip_index)) {
...@@ -33057,15 +33051,6 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {...@@ -33057,15 +33051,6 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {
33057 .pointer,33051 .pointer,
33058 => return null,33052 => return null,
3305933053
33060 .optional => {
33061 const child_ty = ty.optionalChild(mod);
33062 if (child_ty.isNoReturn()) {
33063 return Value.null;
33064 } else {
33065 return null;
33066 }
33067 },
33068
33069 .inferred_alloc_const => unreachable,33054 .inferred_alloc_const => unreachable,
33070 .inferred_alloc_mut => unreachable,33055 .inferred_alloc_mut => unreachable,
33071 },33056 },
...@@ -33628,26 +33613,6 @@ fn typePtrOrOptionalPtrTy(sema: *Sema, ty: Type) !?Type {...@@ -33628,26 +33613,6 @@ fn typePtrOrOptionalPtrTy(sema: *Sema, ty: Type) !?Type {
33628 .inferred_alloc_const => unreachable,33613 .inferred_alloc_const => unreachable,
33629 .inferred_alloc_mut => unreachable,33614 .inferred_alloc_mut => unreachable,
3363033615
33631 .optional => {
33632 const child_type = ty.optionalChild(mod);
33633 if (child_type.zigTypeTag(mod) != .Pointer) return null;
33634
33635 const info = child_type.ptrInfo(mod);
33636 switch (info.size) {
33637 .Slice, .C => return null,
33638 .Many, .One => {
33639 if (info.@"allowzero") return null;
33640
33641 // optionals of zero sized types behave like bools, not pointers
33642 if ((try sema.typeHasOnePossibleValue(child_type)) != null) {
33643 return null;
33644 }
33645
33646 return child_type;
33647 },
33648 }
33649 },
33650
33651 else => return null,33616 else => return null,
33652 }33617 }
33653}33618}
...@@ -33682,10 +33647,6 @@ pub fn typeRequiresComptime(sema: *Sema, ty: Type) CompileError!bool {...@@ -33682,10 +33647,6 @@ pub fn typeRequiresComptime(sema: *Sema, ty: Type) CompileError!bool {
33682 }33647 }
33683 },33648 },
3368433649
33685 .optional => {
33686 return sema.typeRequiresComptime(ty.optionalChild(mod));
33687 },
33688
33689 .error_union => return sema.typeRequiresComptime(ty.errorUnionPayload()),33650 .error_union => return sema.typeRequiresComptime(ty.errorUnionPayload()),
33690 },33651 },
33691 else => switch (mod.intern_pool.indexToKey(ty.ip_index)) {33652 else => switch (mod.intern_pool.indexToKey(ty.ip_index)) {
...@@ -33705,6 +33666,7 @@ pub fn typeRequiresComptime(sema: *Sema, ty: Type) CompileError!bool {...@@ -33705,6 +33666,7 @@ pub fn typeRequiresComptime(sema: *Sema, ty: Type) CompileError!bool {
33705 .array_type => |array_type| return sema.typeRequiresComptime(array_type.child.toType()),33666 .array_type => |array_type| return sema.typeRequiresComptime(array_type.child.toType()),
33706 .vector_type => |vector_type| return sema.typeRequiresComptime(vector_type.child.toType()),33667 .vector_type => |vector_type| return sema.typeRequiresComptime(vector_type.child.toType()),
33707 .opt_type => |child| return sema.typeRequiresComptime(child.toType()),33668 .opt_type => |child| return sema.typeRequiresComptime(child.toType()),
33669
33708 .error_union_type => |error_union_type| {33670 .error_union_type => |error_union_type| {
33709 return sema.typeRequiresComptime(error_union_type.payload_type.toType());33671 return sema.typeRequiresComptime(error_union_type.payload_type.toType());
33710 },33672 },
src/type.zig+13-140
...@@ -47,8 +47,6 @@ pub const Type = struct {...@@ -47,8 +47,6 @@ pub const Type = struct {
47 .inferred_alloc_mut,47 .inferred_alloc_mut,
48 => return .Pointer,48 => return .Pointer,
4949
50 .optional => return .Optional,
51
52 .error_union => return .ErrorUnion,50 .error_union => return .ErrorUnion,
53 },51 },
54 else => return switch (mod.intern_pool.indexToKey(ty.ip_index)) {52 else => return switch (mod.intern_pool.indexToKey(ty.ip_index)) {
...@@ -283,10 +281,6 @@ pub const Type = struct {...@@ -283,10 +281,6 @@ pub const Type = struct {
283 return switch (ty.ip_index) {281 return switch (ty.ip_index) {
284 .none => switch (ty.tag()) {282 .none => switch (ty.tag()) {
285 .pointer => ty.castTag(.pointer).?.data,283 .pointer => ty.castTag(.pointer).?.data,
286 .optional => b: {
287 const child_type = ty.optionalChild(mod);
288 break :b child_type.ptrInfo(mod);
289 },
290284
291 else => unreachable,285 else => unreachable,
292 },286 },
...@@ -387,12 +381,6 @@ pub const Type = struct {...@@ -387,12 +381,6 @@ pub const Type = struct {
387 return true;381 return true;
388 },382 },
389383
390 .optional => {
391 if (b.zigTypeTag(mod) != .Optional) return false;
392
393 return a.optionalChild(mod).eql(b.optionalChild(mod), mod);
394 },
395
396 .error_union => {384 .error_union => {
397 if (b.zigTypeTag(mod) != .ErrorUnion) return false;385 if (b.zigTypeTag(mod) != .ErrorUnion) return false;
398386
...@@ -466,12 +454,6 @@ pub const Type = struct {...@@ -466,12 +454,6 @@ pub const Type = struct {
466 std.hash.autoHash(hasher, info.size);454 std.hash.autoHash(hasher, info.size);
467 },455 },
468456
469 .optional => {
470 std.hash.autoHash(hasher, std.builtin.TypeId.Optional);
471
472 hashWithHasher(ty.optionalChild(mod), hasher, mod);
473 },
474
475 .error_union => {457 .error_union => {
476 std.hash.autoHash(hasher, std.builtin.TypeId.ErrorUnion);458 std.hash.autoHash(hasher, std.builtin.TypeId.ErrorUnion);
477459
...@@ -530,19 +512,6 @@ pub const Type = struct {...@@ -530,19 +512,6 @@ pub const Type = struct {
530 .inferred_alloc_mut,512 .inferred_alloc_mut,
531 => unreachable,513 => unreachable,
532514
533 .optional => {
534 const payload = self.cast(Payload.ElemType).?;
535 const new_payload = try allocator.create(Payload.ElemType);
536 new_payload.* = .{
537 .base = .{ .tag = payload.base.tag },
538 .data = try payload.data.copy(allocator),
539 };
540 return Type{
541 .ip_index = .none,
542 .legacy = .{ .ptr_otherwise = &new_payload.base },
543 };
544 },
545
546 .pointer => {515 .pointer => {
547 const payload = self.castTag(.pointer).?.data;516 const payload = self.castTag(.pointer).?.data;
548 const sent: ?Value = if (payload.sentinel) |some|517 const sent: ?Value = if (payload.sentinel) |some|
...@@ -654,13 +623,6 @@ pub const Type = struct {...@@ -654,13 +623,6 @@ pub const Type = struct {
654 while (true) {623 while (true) {
655 const t = ty.tag();624 const t = ty.tag();
656 switch (t) {625 switch (t) {
657 .optional => {
658 const child_type = ty.castTag(.optional).?.data;
659 try writer.writeByte('?');
660 ty = child_type;
661 continue;
662 },
663
664 .pointer => {626 .pointer => {
665 const payload = ty.castTag(.pointer).?.data;627 const payload = ty.castTag(.pointer).?.data;
666 if (payload.sentinel) |some| switch (payload.size) {628 if (payload.sentinel) |some| switch (payload.size) {
...@@ -813,11 +775,6 @@ pub const Type = struct {...@@ -813,11 +775,6 @@ pub const Type = struct {
813 try print(info.pointee_type, writer, mod);775 try print(info.pointee_type, writer, mod);
814 },776 },
815777
816 .optional => {
817 const child_type = ty.castTag(.optional).?.data;
818 try writer.writeByte('?');
819 try print(child_type, writer, mod);
820 },
821 .error_set => {778 .error_set => {
822 const names = ty.castTag(.error_set).?.data.names.keys();779 const names = ty.castTag(.error_set).?.data.names.keys();
823 try writer.writeAll("error{");780 try writer.writeAll("error{");
...@@ -911,8 +868,7 @@ pub const Type = struct {...@@ -911,8 +868,7 @@ pub const Type = struct {
911 },868 },
912 .opt_type => |child| {869 .opt_type => |child| {
913 try writer.writeByte('?');870 try writer.writeByte('?');
914 try print(child.toType(), writer, mod);871 return print(child.toType(), writer, mod);
915 return;
916 },872 },
917 .error_union_type => |error_union_type| {873 .error_union_type => |error_union_type| {
918 try print(error_union_type.error_set_type.toType(), writer, mod);874 try print(error_union_type.error_set_type.toType(), writer, mod);
...@@ -1090,21 +1046,6 @@ pub const Type = struct {...@@ -1090,21 +1046,6 @@ pub const Type = struct {
1090 }1046 }
1091 },1047 },
10921048
1093 .optional => {
1094 const child_ty = ty.optionalChild(mod);
1095 if (child_ty.isNoReturn()) {
1096 // Then the optional is comptime-known to be null.
1097 return false;
1098 }
1099 if (ignore_comptime_only) {
1100 return true;
1101 } else if (strat == .sema) {
1102 return !(try strat.sema.typeRequiresComptime(child_ty));
1103 } else {
1104 return !comptimeOnly(child_ty, mod);
1105 }
1106 },
1107
1108 .inferred_alloc_const => unreachable,1049 .inferred_alloc_const => unreachable,
1109 .inferred_alloc_mut => unreachable,1050 .inferred_alloc_mut => unreachable,
1110 },1051 },
...@@ -1301,8 +1242,6 @@ pub const Type = struct {...@@ -1301,8 +1242,6 @@ pub const Type = struct {
13011242
1302 .inferred_alloc_mut => unreachable,1243 .inferred_alloc_mut => unreachable,
1303 .inferred_alloc_const => unreachable,1244 .inferred_alloc_const => unreachable,
1304
1305 .optional => ty.isPtrLikeOptional(mod),
1306 },1245 },
1307 else => switch (mod.intern_pool.indexToKey(ty.ip_index)) {1246 else => switch (mod.intern_pool.indexToKey(ty.ip_index)) {
1308 .int_type,1247 .int_type,
...@@ -1319,7 +1258,7 @@ pub const Type = struct {...@@ -1319,7 +1258,7 @@ pub const Type = struct {
1319 => false,1258 => false,
13201259
1321 .array_type => |array_type| array_type.child.toType().hasWellDefinedLayout(mod),1260 .array_type => |array_type| array_type.child.toType().hasWellDefinedLayout(mod),
1322 .opt_type => |child| child.toType().isPtrLikeOptional(mod),1261 .opt_type => ty.isPtrLikeOptional(mod),
13231262
1324 .simple_type => |t| switch (t) {1263 .simple_type => |t| switch (t) {
1325 .f16,1264 .f16,
...@@ -1484,7 +1423,6 @@ pub const Type = struct {...@@ -1484,7 +1423,6 @@ pub const Type = struct {
1484 return (ptr_info.pointee_type.abiAlignmentAdvanced(mod, .eager) catch unreachable).scalar;1423 return (ptr_info.pointee_type.abiAlignmentAdvanced(mod, .eager) catch unreachable).scalar;
1485 }1424 }
1486 },1425 },
1487 .optional => return ty.castTag(.optional).?.data.ptrAlignmentAdvanced(mod, opt_sema),
14881426
1489 else => unreachable,1427 else => unreachable,
1490 },1428 },
...@@ -1510,11 +1448,6 @@ pub const Type = struct {...@@ -1510,11 +1448,6 @@ pub const Type = struct {
1510 .none => switch (ty.tag()) {1448 .none => switch (ty.tag()) {
1511 .pointer => ty.castTag(.pointer).?.data.@"addrspace",1449 .pointer => ty.castTag(.pointer).?.data.@"addrspace",
15121450
1513 .optional => {
1514 const child_type = ty.optionalChild(mod);
1515 return child_type.ptrAddressSpace(mod);
1516 },
1517
1518 else => unreachable,1451 else => unreachable,
1519 },1452 },
1520 else => switch (mod.intern_pool.indexToKey(ty.ip_index)) {1453 else => switch (mod.intern_pool.indexToKey(ty.ip_index)) {
...@@ -1580,7 +1513,6 @@ pub const Type = struct {...@@ -1580,7 +1513,6 @@ pub const Type = struct {
1580 .error_set_merged,1513 .error_set_merged,
1581 => return AbiAlignmentAdvanced{ .scalar = 2 },1514 => return AbiAlignmentAdvanced{ .scalar = 2 },
15821515
1583 .optional => return abiAlignmentAdvancedOptional(ty, mod, strat),
1584 .error_union => return abiAlignmentAdvancedErrorUnion(ty, mod, strat),1516 .error_union => return abiAlignmentAdvancedErrorUnion(ty, mod, strat),
15851517
1586 .inferred_alloc_const,1518 .inferred_alloc_const,
...@@ -1962,8 +1894,6 @@ pub const Type = struct {...@@ -1962,8 +1894,6 @@ pub const Type = struct {
1962 .error_set_single,1894 .error_set_single,
1963 => return AbiSizeAdvanced{ .scalar = 2 },1895 => return AbiSizeAdvanced{ .scalar = 2 },
19641896
1965 .optional => return ty.abiSizeAdvancedOptional(mod, strat),
1966
1967 .error_union => {1897 .error_union => {
1968 // This code needs to be kept in sync with the equivalent switch prong1898 // This code needs to be kept in sync with the equivalent switch prong
1969 // in abiAlignmentAdvanced.1899 // in abiAlignmentAdvanced.
...@@ -2282,7 +2212,7 @@ pub const Type = struct {...@@ -2282,7 +2212,7 @@ pub const Type = struct {
2282 .error_set_merged,2212 .error_set_merged,
2283 => return 16, // TODO revisit this when we have the concept of the error tag type2213 => return 16, // TODO revisit this when we have the concept of the error tag type
22842214
2285 .optional, .error_union => {2215 .error_union => {
2286 // Optionals and error unions are not packed so their bitsize2216 // Optionals and error unions are not packed so their bitsize
2287 // includes padding bits.2217 // includes padding bits.
2288 return (try abiSizeAdvanced(ty, mod, strat)).scalar * 8;2218 return (try abiSizeAdvanced(ty, mod, strat)).scalar * 8;
...@@ -2310,7 +2240,11 @@ pub const Type = struct {...@@ -2310,7 +2240,11 @@ pub const Type = struct {
2310 const elem_bit_size = try bitSizeAdvanced(child_ty, mod, opt_sema);2240 const elem_bit_size = try bitSizeAdvanced(child_ty, mod, opt_sema);
2311 return elem_bit_size * vector_type.len;2241 return elem_bit_size * vector_type.len;
2312 },2242 },
2313 .opt_type => @panic("TODO"),2243 .opt_type => {
2244 // Optionals and error unions are not packed so their bitsize
2245 // includes padding bits.
2246 return (try abiSizeAdvanced(ty, mod, strat)).scalar * 8;
2247 },
2314 .error_union_type => @panic("TODO"),2248 .error_union_type => @panic("TODO"),
2315 .func_type => unreachable, // represents machine code; not a pointer2249 .func_type => unreachable, // represents machine code; not a pointer
2316 .simple_type => |t| switch (t) {2250 .simple_type => |t| switch (t) {
...@@ -2499,7 +2433,6 @@ pub const Type = struct {...@@ -2499,7 +2433,6 @@ pub const Type = struct {
2499 }2433 }
25002434
2501 pub const SlicePtrFieldTypeBuffer = union {2435 pub const SlicePtrFieldTypeBuffer = union {
2502 elem_type: Payload.ElemType,
2503 pointer: Payload.Pointer,2436 pointer: Payload.Pointer,
2504 };2437 };
25052438
...@@ -2600,16 +2533,6 @@ pub const Type = struct {...@@ -2600,16 +2533,6 @@ pub const Type = struct {
2600 .One, .Many, .C => return true,2533 .One, .Many, .C => return true,
2601 },2534 },
26022535
2603 .optional => {
2604 const child_type = ty.optionalChild(mod);
2605 if (child_type.zigTypeTag(mod) != .Pointer) return false;
2606 const info = child_type.ptrInfo(mod);
2607 switch (info.size) {
2608 .Slice, .C => return false,
2609 .Many, .One => return !info.@"allowzero",
2610 }
2611 },
2612
2613 else => return false,2536 else => return false,
2614 },2537 },
2615 else => return switch (mod.intern_pool.indexToKey(ty.ip_index)) {2538 else => return switch (mod.intern_pool.indexToKey(ty.ip_index)) {
...@@ -2655,21 +2578,6 @@ pub const Type = struct {...@@ -2655,21 +2578,6 @@ pub const Type = struct {
2655 else => false,2578 else => false,
2656 };2579 };
2657 switch (ty.tag()) {2580 switch (ty.tag()) {
2658 .optional => {
2659 const child_ty = ty.castTag(.optional).?.data;
2660 switch (child_ty.zigTypeTag(mod)) {
2661 .Pointer => {
2662 const info = child_ty.ptrInfo(mod);
2663 switch (info.size) {
2664 .C => return false,
2665 .Slice, .Many, .One => return !info.@"allowzero",
2666 }
2667 },
2668 .ErrorSet => return true,
2669 else => return false,
2670 }
2671 },
2672
2673 .pointer => return ty.castTag(.pointer).?.data.size == .C,2581 .pointer => return ty.castTag(.pointer).?.data.size == .C,
26742582
2675 else => return false,2583 else => return false,
...@@ -2692,16 +2600,6 @@ pub const Type = struct {...@@ -2692,16 +2600,6 @@ pub const Type = struct {
2692 else => false,2600 else => false,
2693 };2601 };
2694 switch (ty.tag()) {2602 switch (ty.tag()) {
2695 .optional => {
2696 const child_ty = ty.castTag(.optional).?.data;
2697 if (child_ty.zigTypeTag(mod) != .Pointer) return false;
2698 const info = child_ty.ptrInfo(mod);
2699 switch (info.size) {
2700 .Slice, .C => return false,
2701 .Many, .One => return !info.@"allowzero",
2702 }
2703 },
2704
2705 .pointer => return ty.castTag(.pointer).?.data.size == .C,2603 .pointer => return ty.castTag(.pointer).?.data.size == .C,
27062604
2707 else => return false,2605 else => return false,
...@@ -2747,7 +2645,6 @@ pub const Type = struct {...@@ -2747,7 +2645,6 @@ pub const Type = struct {
2747 return child_ty;2645 return child_ty;
2748 }2646 }
2749 },2647 },
2750 .optional => ty.castTag(.optional).?.data.childType(mod),
27512648
2752 else => unreachable,2649 else => unreachable,
2753 },2650 },
...@@ -2784,13 +2681,10 @@ pub const Type = struct {...@@ -2784,13 +2681,10 @@ pub const Type = struct {
2784 }2681 }
27852682
2786 /// Asserts that the type is an optional.2683 /// Asserts that the type is an optional.
2787 /// Resulting `Type` will have inner memory referencing `buf`.
2788 /// Note that for C pointers this returns the type unmodified.2684 /// Note that for C pointers this returns the type unmodified.
2789 pub fn optionalChild(ty: Type, mod: *const Module) Type {2685 pub fn optionalChild(ty: Type, mod: *const Module) Type {
2790 return switch (ty.ip_index) {2686 return switch (ty.ip_index) {
2791 .none => switch (ty.tag()) {2687 .none => switch (ty.tag()) {
2792 .optional => ty.castTag(.optional).?.data,
2793
2794 .pointer, // here we assume it is a C pointer2688 .pointer, // here we assume it is a C pointer
2795 => return ty,2689 => return ty,
27962690
...@@ -3305,15 +3199,6 @@ pub const Type = struct {...@@ -3305,15 +3199,6 @@ pub const Type = struct {
3305 .pointer,3199 .pointer,
3306 => return null,3200 => return null,
33073201
3308 .optional => {
3309 const child_ty = ty.optionalChild(mod);
3310 if (child_ty.isNoReturn()) {
3311 return Value.null;
3312 } else {
3313 return null;
3314 }
3315 },
3316
3317 .inferred_alloc_const => unreachable,3202 .inferred_alloc_const => unreachable,
3318 .inferred_alloc_mut => unreachable,3203 .inferred_alloc_mut => unreachable,
3319 },3204 },
...@@ -3524,10 +3409,6 @@ pub const Type = struct {...@@ -3524,10 +3409,6 @@ pub const Type = struct {
3524 }3409 }
3525 },3410 },
35263411
3527 .optional => {
3528 return ty.optionalChild(mod).comptimeOnly(mod);
3529 },
3530
3531 .error_union => return ty.errorUnionPayload().comptimeOnly(mod),3412 .error_union => return ty.errorUnionPayload().comptimeOnly(mod),
3532 },3413 },
3533 else => switch (mod.intern_pool.indexToKey(ty.ip_index)) {3414 else => switch (mod.intern_pool.indexToKey(ty.ip_index)) {
...@@ -4216,7 +4097,6 @@ pub const Type = struct {...@@ -4216,7 +4097,6 @@ pub const Type = struct {
4216 // After this, the tag requires a payload.4097 // After this, the tag requires a payload.
42174098
4218 pointer,4099 pointer,
4219 optional,
4220 error_union,4100 error_union,
4221 error_set,4101 error_set,
4222 error_set_single,4102 error_set_single,
...@@ -4233,8 +4113,6 @@ pub const Type = struct {...@@ -4233,8 +4113,6 @@ pub const Type = struct {
4233 .inferred_alloc_mut,4113 .inferred_alloc_mut,
4234 => @compileError("Type Tag " ++ @tagName(t) ++ " has no payload"),4114 => @compileError("Type Tag " ++ @tagName(t) ++ " has no payload"),
42354115
4236 .optional => Payload.ElemType,
4237
4238 .error_set => Payload.ErrorSet,4116 .error_set => Payload.ErrorSet,
4239 .error_set_inferred => Payload.ErrorSetInferred,4117 .error_set_inferred => Payload.ErrorSetInferred,
4240 .error_set_merged => Payload.ErrorSetMerged,4118 .error_set_merged => Payload.ErrorSetMerged,
...@@ -4326,11 +4204,6 @@ pub const Type = struct {...@@ -4326,11 +4204,6 @@ pub const Type = struct {
4326 data: u64,4204 data: u64,
4327 };4205 };
43284206
4329 pub const ElemType = struct {
4330 base: Payload,
4331 data: Type,
4332 };
4333
4334 pub const Bits = struct {4207 pub const Bits = struct {
4335 base: Payload,4208 base: Payload,
4336 data: u16,4209 data: u16,
...@@ -4570,11 +4443,11 @@ pub const Type = struct {...@@ -4570,11 +4443,11 @@ pub const Type = struct {
4570 }4443 }
45714444
4572 pub fn optional(arena: Allocator, child_type: Type, mod: *Module) Allocator.Error!Type {4445 pub fn optional(arena: Allocator, child_type: Type, mod: *Module) Allocator.Error!Type {
4573 if (child_type.ip_index != .none) {4446 // TODO: update callsites of this function to directly call
4574 return mod.optionalType(child_type.ip_index);4447 // mod.optionalType and then delete this function.
4575 } else {4448 _ = arena;
4576 return Type.Tag.optional.create(arena, child_type);4449
4577 }4450 return mod.optionalType(child_type.ip_index);
4578 }4451 }
45794452
4580 pub fn errorUnion(4453 pub fn errorUnion(