| ... | ... | @@ -463,12 +463,11 @@ pub fn formatType( |
| 463 | 463 | try formatType(@enumToInt(value), fmt, options, writer, max_depth); |
| 464 | 464 | try writer.writeAll(")"); |
| 465 | 465 | }, |
| 466 | | .Union => { |
| 466 | .Union => |info| { |
| 467 | 467 | try writer.writeAll(@typeName(T)); |
| 468 | 468 | if (max_depth == 0) { |
| 469 | 469 | return writer.writeAll("{ ... }"); |
| 470 | 470 | } |
| 471 | | const info = @typeInfo(T).Union; |
| 472 | 471 | if (info.tag_type) |UnionTagType| { |
| 473 | 472 | try writer.writeAll("{ ."); |
| 474 | 473 | try writer.writeAll(@tagName(@as(UnionTagType, value))); |
| ... | ... | @@ -507,30 +506,30 @@ pub fn formatType( |
| 507 | 506 | if (info.child == u8) { |
| 508 | 507 | return formatText(value, fmt, options, writer); |
| 509 | 508 | } |
| 510 | | return format(writer, "{}@{x}", .{ @typeName(@typeInfo(T).Pointer.child), @ptrToInt(value) }); |
| 509 | return format(writer, "{}@{x}", .{ @typeName(ptr_info.child), @ptrToInt(value) }); |
| 511 | 510 | }, |
| 512 | 511 | .Enum, .Union, .Struct => { |
| 513 | 512 | return formatType(value.*, fmt, options, writer, max_depth); |
| 514 | 513 | }, |
| 515 | | else => return format(writer, "{}@{x}", .{ @typeName(@typeInfo(T).Pointer.child), @ptrToInt(value) }), |
| 514 | else => return format(writer, "{}@{x}", .{ @typeName(ptr_info.child), @ptrToInt(value) }), |
| 516 | 515 | }, |
| 517 | 516 | .Many, .C => { |
| 518 | 517 | if (ptr_info.sentinel) |sentinel| { |
| 519 | 518 | return formatType(mem.span(value), fmt, options, writer, max_depth); |
| 520 | 519 | } |
| 521 | 520 | if (ptr_info.child == u8) { |
| 522 | | if (fmt.len > 0 and fmt[0] == 's') { |
| 521 | if (fmt.len > 0 and comptime mem.indexOfScalar(u8, "sxXzZ", fmt[0]) != null) { |
| 523 | 522 | return formatText(mem.span(value), fmt, options, writer); |
| 524 | 523 | } |
| 525 | 524 | } |
| 526 | | return format(writer, "{}@{x}", .{ @typeName(@typeInfo(T).Pointer.child), @ptrToInt(value) }); |
| 525 | return format(writer, "{}@{x}", .{ @typeName(ptr_info.child), @ptrToInt(value) }); |
| 527 | 526 | }, |
| 528 | 527 | .Slice => { |
| 529 | 528 | if (max_depth == 0) { |
| 530 | 529 | return writer.writeAll("[ ... ]"); |
| 531 | 530 | } |
| 532 | 531 | if (ptr_info.child == u8) { |
| 533 | | if (fmt.len == 0 or fmt[0] == 's' or fmt[0] == 'x' or fmt[0] == 'X') { |
| 532 | if (fmt.len == 0 or comptime mem.indexOfScalar(u8, "sxXzZ", fmt[0]) != null) { |
| 534 | 533 | return formatText(value, fmt, options, writer); |
| 535 | 534 | } |
| 536 | 535 | } |