| ... | ... | @@ -1200,6 +1200,8 @@ pub inline fn hasUniqueRepresentation(comptime T: type) bool { |
| 1200 | 1200 | .Array => |info| hasUniqueRepresentation(info.child), |
| 1201 | 1201 | |
| 1202 | 1202 | .Struct => |info| { |
| 1203 | if (info.layout == .@"packed") return @sizeOf(T) * 8 == @bitSizeOf(T); |
| 1204 | |
| 1203 | 1205 | var sum_size = @as(usize, 0); |
| 1204 | 1206 | |
| 1205 | 1207 | inline for (info.fields) |field| { |
| ... | ... | @@ -1245,6 +1247,19 @@ test hasUniqueRepresentation { |
| 1245 | 1247 | |
| 1246 | 1248 | try testing.expect(!hasUniqueRepresentation(TestStruct5)); |
| 1247 | 1249 | |
| 1250 | const TestStruct6 = packed struct(u8) { |
| 1251 | @"0": bool, |
| 1252 | @"1": bool, |
| 1253 | @"2": bool, |
| 1254 | @"3": bool, |
| 1255 | @"4": bool, |
| 1256 | @"5": bool, |
| 1257 | @"6": bool, |
| 1258 | @"7": bool, |
| 1259 | }; |
| 1260 | |
| 1261 | try testing.expect(hasUniqueRepresentation(TestStruct6)); |
| 1262 | |
| 1248 | 1263 | const TestUnion1 = packed union { |
| 1249 | 1264 | a: u32, |
| 1250 | 1265 | b: u16, |