| ... | @@ -220,8 +220,10 @@ pub fn formatType( | ... | @@ -220,8 +220,10 @@ pub fn formatType( |
| 220 | if (fmt.len > 0 and ((fmt[0] == 'x') or (fmt[0] == 'X'))) { | 220 | if (fmt.len > 0 and ((fmt[0] == 'x') or (fmt[0] == 'X'))) { |
| 221 | return formatText(value, fmt, context, Errors, output); | 221 | return formatText(value, fmt, context, Errors, output); |
| 222 | } | 222 | } |
| 223 | const casted_value = ([]const u8)(value); | 223 | if (ptr_info.child == u8) { |
| 224 | return output(context, casted_value); | 224 | return formatText(value, fmt, context, Errors, output); |
| | 225 | } |
| | 226 | return format(context, Errors, output, "{}@{x}", @typeName(ptr_info.child), @ptrToInt(value.ptr)); |
| 225 | }, | 227 | }, |
| 226 | builtin.TypeInfo.Pointer.Size.C => { | 228 | builtin.TypeInfo.Pointer.Size.C => { |
| 227 | return format(context, Errors, output, "{}@{x}", @typeName(T.Child), @ptrToInt(value)); | 229 | return format(context, Errors, output, "{}@{x}", @typeName(T.Child), @ptrToInt(value)); |
| ... | @@ -1009,6 +1011,10 @@ test "fmt.format" { | ... | @@ -1009,6 +1011,10 @@ test "fmt.format" { |
| 1009 | const value: []const u8 = "abc"; | 1011 | const value: []const u8 = "abc"; |
| 1010 | try testFmt("slice: abc\n", "slice: {}\n", value); | 1012 | try testFmt("slice: abc\n", "slice: {}\n", value); |
| 1011 | } | 1013 | } |
| | 1014 | { |
| | 1015 | const value = @intToPtr([*]const []const u8, 0xdeadbeef)[0..0]; |
| | 1016 | try testFmt("slice: []const u8@deadbeef\n", "slice: {}\n", value); |
| | 1017 | } |
| 1012 | { | 1018 | { |
| 1013 | const value = @intToPtr(*i32, 0xdeadbeef); | 1019 | const value = @intToPtr(*i32, 0xdeadbeef); |
| 1014 | try testFmt("pointer: i32@deadbeef\n", "pointer: {}\n", value); | 1020 | try testFmt("pointer: i32@deadbeef\n", "pointer: {}\n", value); |