| author | |
| committer | |
| log | 95f93a0b281e32583edef36808231a5f61fb7de1 |
| tree | 3fa7aca3b719492a56fad4e0661b8efe02b4b6fd |
| parent | 1d1e2b77802c75b3abb793599aefe4c772a7cfb8 |
Before this PR this
```zig
const namespace = struct {
extern const num: u8 addrspace(.generic);
};
// comment
```
got formatted to this
```zig
const namespace = struct {
extern const num: u8 addrspace(.generic);
(
```
Co-authored-by: rpkak <rpkak@noreply.codeberg.org>
Co-committed-by: rpkak <rpkak@noreply.codeberg.org>2 files changed, 13 insertions(+), 0 deletions(-)
lib/std/zig/Ast.zig+3| ... | ... | @@ -1195,6 +1195,9 @@ pub fn lastToken(tree: Ast, node: Node.Index) TokenIndex { |
| 1195 | 1195 | if (extra.section_node.unwrap()) |section_node| { |
| 1196 | 1196 | end_offset += 1; // for the rparen |
| 1197 | 1197 | n = section_node; |
| 1198 | } else if (extra.addrspace_node.unwrap()) |addrspace_node| { | |
| 1199 | end_offset += 1; // for the rparen | |
| 1200 | n = addrspace_node; | |
| 1198 | 1201 | } else if (extra.align_node.unwrap()) |align_node| { |
| 1199 | 1202 | end_offset += 1; // for the rparen |
| 1200 | 1203 | n = align_node; |
lib/std/zig/parser_test.zig+10| ... | ... | @@ -6084,6 +6084,16 @@ test "zig fmt: do not canonicalize invalid cast builtins" { |
| 6084 | 6084 | ); |
| 6085 | 6085 | } |
| 6086 | 6086 | |
| 6087 | test "zig fmt: extern addrspace in struct" { | |
| 6088 | try testCanonical( | |
| 6089 | \\const namespace = struct { | |
| 6090 | \\ extern const num: u8 addrspace(.generic); | |
| 6091 | \\}; | |
| 6092 | \\// comment | |
| 6093 | \\ | |
| 6094 | ); | |
| 6095 | } | |
| 6096 | ||
| 6087 | 6097 | test "recovery: top level" { |
| 6088 | 6098 | try testError( |
| 6089 | 6099 | \\test "" {inline} |