@@ -18,7 +18,7 @@ const file_struct = @This();
18
18
pub const Type = extern union {
19
19
/// If the tag value is less than Tag.no_payload_count, then no pointer
20
20
/// dereference is needed.
21
- tag_if_small_enough : usize ,
21
+ tag_if_small_enough : Tag ,
22
22
ptr_otherwise : * Payload ,
23
23
24
24
pub fn zigTypeTag (ty : Type ) std.builtin.TypeId {
@@ -178,7 +178,7 @@ pub const Type = extern union {
178
178
179
179
pub fn initTag (comptime small_tag : Tag ) Type {
180
180
comptime assert (@enumToInt (small_tag ) < Tag .no_payload_count );
181
- return .{ .tag_if_small_enough = @enumToInt ( small_tag ) };
181
+ return .{ .tag_if_small_enough = small_tag };
182
182
}
183
183
184
184
pub fn initPayload (payload : * Payload ) Type {
@@ -187,8 +187,8 @@ pub const Type = extern union {
187
187
}
188
188
189
189
pub fn tag (self : Type ) Tag {
190
- if (self .tag_if_small_enough < Tag .no_payload_count ) {
191
- return @intToEnum ( Tag , @intCast ( std . meta . Tag ( Tag ), self .tag_if_small_enough )) ;
190
+ if (@enumToInt ( self .tag_if_small_enough ) < Tag .no_payload_count ) {
191
+ return self .tag_if_small_enough ;
192
192
} else {
193
193
return self .ptr_otherwise .tag ;
194
194
}
@@ -199,7 +199,7 @@ pub const Type = extern union {
199
199
if (@hasField (T , "base_tag" )) {
200
200
return self .castTag (T .base_tag );
201
201
}
202
- if (self .tag_if_small_enough < Tag .no_payload_count ) {
202
+ if (@enumToInt ( self .tag_if_small_enough ) < Tag .no_payload_count ) {
203
203
return null ;
204
204
}
205
205
inline for (@typeInfo (Tag ).Enum .fields ) | field | {
@@ -217,7 +217,7 @@ pub const Type = extern union {
217
217
}
218
218
219
219
pub fn castTag (self : Type , comptime t : Tag ) ? * t .Type () {
220
- if (self .tag_if_small_enough < Tag .no_payload_count )
220
+ if (@enumToInt ( self .tag_if_small_enough ) < Tag .no_payload_count )
221
221
return null ;
222
222
223
223
if (self .ptr_otherwise .tag == t )
@@ -690,7 +690,7 @@ pub const Type = extern union {
690
690
};
691
691
692
692
pub fn copy (self : Type , allocator : * Allocator ) error {OutOfMemory }! Type {
693
- if (self .tag_if_small_enough < Tag .no_payload_count ) {
693
+ if (@enumToInt ( self .tag_if_small_enough ) < Tag .no_payload_count ) {
694
694
return Type { .tag_if_small_enough = self .tag_if_small_enough };
695
695
} else switch (self .ptr_otherwise .tag ) {
696
696
.u1 ,
@@ -1459,7 +1459,7 @@ pub const Type = extern union {
1459
1459
1460
1460
pub fn isNoReturn (self : Type ) bool {
1461
1461
const definitely_correct_result = self .zigTypeTag () == .NoReturn ;
1462
- const fast_result = self .tag_if_small_enough == @enumToInt ( Tag .noreturn ) ;
1462
+ const fast_result = self .tag_if_small_enough == Tag .noreturn ;
1463
1463
assert (fast_result == definitely_correct_result );
1464
1464
return fast_result ;
1465
1465
}
@@ -3165,7 +3165,7 @@ pub const Type = extern union {
3165
3165
/// but with different alignment values, in this data structure they are represented
3166
3166
/// with different enum tags, because the the former requires more payload data than the latter.
3167
3167
/// See `zigTypeTag` for the function that corresponds to `std.builtin.TypeId`.
3168
- pub const Tag = enum {
3168
+ pub const Tag = enum ( usize ) {
3169
3169
// The first section of this enum are tags that require no payload.
3170
3170
u1 ,
3171
3171
u8 ,
@@ -3382,7 +3382,7 @@ pub const Type = extern union {
3382
3382
3383
3383
pub fn init (comptime t : Tag ) file_struct.Type {
3384
3384
comptime std .debug .assert (@enumToInt (t ) < Tag .no_payload_count );
3385
- return .{ .tag_if_small_enough = @enumToInt ( t ) };
3385
+ return .{ .tag_if_small_enough = t };
3386
3386
}
3387
3387
3388
3388
pub fn create (comptime t : Tag , ally : * Allocator , data : Data (t )) error {OutOfMemory }! file_struct.Type {
0 commit comments