mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
std.zig.Ast: count addrspace tokens correctly
Some checks are pending
ci / aarch64-linux-debug (push) Waiting to run
ci / aarch64-linux-release (push) Waiting to run
ci / aarch64-macos-debug (push) Waiting to run
ci / aarch64-macos-release (push) Waiting to run
ci / loongarch64-linux-debug (push) Waiting to run
ci / loongarch64-linux-release (push) Waiting to run
ci / riscv64-linux-debug (push) Waiting to run
ci / riscv64-linux-release (push) Waiting to run
ci / s390x-linux-debug (push) Waiting to run
ci / s390x-linux-release (push) Waiting to run
ci / x86_64-freebsd-debug (push) Waiting to run
ci / x86_64-freebsd-release (push) Waiting to run
ci / x86_64-linux-debug (push) Waiting to run
ci / x86_64-linux-debug-llvm (push) Waiting to run
ci / x86_64-linux-release (push) Waiting to run
ci / x86_64-windows-debug (push) Waiting to run
ci / x86_64-windows-release (push) Waiting to run
Some checks are pending
ci / aarch64-linux-debug (push) Waiting to run
ci / aarch64-linux-release (push) Waiting to run
ci / aarch64-macos-debug (push) Waiting to run
ci / aarch64-macos-release (push) Waiting to run
ci / loongarch64-linux-debug (push) Waiting to run
ci / loongarch64-linux-release (push) Waiting to run
ci / riscv64-linux-debug (push) Waiting to run
ci / riscv64-linux-release (push) Waiting to run
ci / s390x-linux-debug (push) Waiting to run
ci / s390x-linux-release (push) Waiting to run
ci / x86_64-freebsd-debug (push) Waiting to run
ci / x86_64-freebsd-release (push) Waiting to run
ci / x86_64-linux-debug (push) Waiting to run
ci / x86_64-linux-debug-llvm (push) Waiting to run
ci / x86_64-linux-release (push) Waiting to run
ci / x86_64-windows-debug (push) Waiting to run
ci / x86_64-windows-release (push) Waiting to run
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>
This commit is contained in:
parent
1d1e2b7780
commit
95f93a0b28
2 changed files with 13 additions and 0 deletions
|
|
@ -1195,6 +1195,9 @@ pub fn lastToken(tree: Ast, node: Node.Index) TokenIndex {
|
||||||
if (extra.section_node.unwrap()) |section_node| {
|
if (extra.section_node.unwrap()) |section_node| {
|
||||||
end_offset += 1; // for the rparen
|
end_offset += 1; // for the rparen
|
||||||
n = section_node;
|
n = section_node;
|
||||||
|
} else if (extra.addrspace_node.unwrap()) |addrspace_node| {
|
||||||
|
end_offset += 1; // for the rparen
|
||||||
|
n = addrspace_node;
|
||||||
} else if (extra.align_node.unwrap()) |align_node| {
|
} else if (extra.align_node.unwrap()) |align_node| {
|
||||||
end_offset += 1; // for the rparen
|
end_offset += 1; // for the rparen
|
||||||
n = align_node;
|
n = align_node;
|
||||||
|
|
|
||||||
|
|
@ -6084,6 +6084,16 @@ test "zig fmt: do not canonicalize invalid cast builtins" {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "zig fmt: extern addrspace in struct" {
|
||||||
|
try testCanonical(
|
||||||
|
\\const namespace = struct {
|
||||||
|
\\ extern const num: u8 addrspace(.generic);
|
||||||
|
\\};
|
||||||
|
\\// comment
|
||||||
|
\\
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
test "recovery: top level" {
|
test "recovery: top level" {
|
||||||
try testError(
|
try testError(
|
||||||
\\test "" {inline}
|
\\test "" {inline}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue