Skip to content

feat(docs): support 0.16.0#320

Open
jinzhongjia wants to merge 2 commits intomainfrom
016
Open

feat(docs): support 0.16.0#320
jinzhongjia wants to merge 2 commits intomainfrom
016

Conversation

@jinzhongjia
Copy link
Copy Markdown
Member

No description provided.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the documentation to reflect the release of Zig 0.16.0. It includes a new version description file and a comprehensive upgrade guide from version 0.15.1, along with updates to the sidebar and theme configuration. The review feedback identifies two issues in the upgrade guide's code examples: a redundant constant redefinition in the C import section and a syntax error in the representation of the deprecated @type usage.

Comment on lines +32 to +38
pub const c = @cImport({
@cInclude("stdio.h");
@cInclude("math.h");
@cInclude("stdlib.h");
});

const c = @import("c.zig").c;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The "Old way" code block contains a redefinition of the constant c. It first defines c using @cImport and then immediately tries to redefine it using @import. These should be presented as separate examples or the redundant line should be removed to avoid confusion.

Suggested change
pub const c = @cImport({
@cInclude("stdio.h");
@cInclude("math.h");
@cInclude("stdlib.h");
});
const c = @import("c.zig").c;
pub const c = @cImport({
@cInclude("stdio.h");
@cInclude("math.h");
@cInclude("stdlib.h");
});

常见迁移:

```zig
@Type(.enum_literal)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

In the "Old way" example, @Type(.enum_literal) is syntactically incorrect for Zig versions prior to 0.16.0. The @Type built-in expects a std.builtin.Type union value, so it should be @Type(.{ .enum_literal = .{} }).

Suggested change
@Type(.enum_literal)
@Type(.{ .enum_literal = .{} })

- `std.process.getCwd*` 改名为 `currentPath*`
- `fs.path.relative` 变成纯函数,需要显式传入上下文
- `File.Stat.atime` 变成可选值
- `std.mem` 里 “index of” 系列统一更名为 “find”
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [AutoCorrect Lint] <AutoCorrect> reported by reviewdog 🐶

Suggested change
- `std.mem`“index of” 系列统一更名为 “find”
- `std.mem`“index of”系列统一更名为“find”


LLVM 后端这一轮的进展有几条:

- **实验性支持增量编译**——这并不会加速 “LLVM Emit Object” 这一步(LLVM 自己负责的部分我们做不了什么),但加速了 Zig 编译器侧生成 LLVM bitcode 的过程,因此当你的代码本身就有编译错误时,你能在 LLVM 后端下也获得近乎瞬时的反馈
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [AutoCorrect Lint] <AutoCorrect> reported by reviewdog 🐶

Suggested change
- **实验性支持增量编译**——这并不会加速 “LLVM Emit Object” 这一步(LLVM 自己负责的部分我们做不了什么),但加速了 Zig 编译器侧生成 LLVM bitcode 的过程,因此当你的代码本身就有编译错误时,你能在 LLVM 后端下也获得近乎瞬时的反馈
- **实验性��——这并不会加速“LLVM Emit Object”这一步(LLVM 自己负责的部分我们做不了什么),但加速了 Zig 编译器侧生成 LLVM bitcode 的过程,因此当你的代码本身就有编译错误时,你能在 LLVM 后端下也获得近乎瞬时的反馈乎瞬时的反馈


LLVM 后端目前通过了 2004 / 2010(100%)行为测试。Matthew 还实验过把 tagged union 和 error union 用 DWARF 的 variant 类型表达,让调试器只显示“当前激活的字段”——但 LLDB 对 variant 类型的支持只有在语言被标成 Rust 时才启用,因此暂未落地。这条路径未来下游若改善还可能再走。

后续还会继续推进 LLVM 后端的并行化:让多个线程同时为不同函数生成 LLVM IR,再由一个 “linker” 线程合并。
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [AutoCorrect Lint] <AutoCorrect> reported by reviewdog 🐶

Suggested change
后续还会继续推进 LLVM 后端的并行化:让多个线程同时为不同函数生成 LLVM IR,再由一个 “linker” 线程合并。
后续还会继续推进 LLVM 后端的并行化:让多个线程同时为不同函数生成 LLVM IR,再由一个“linker”线程合并。


### 配套的 AST Smith 已经替 zig fmt 找到 20 个 bug

新的 Smith 接口本身已经被用来构建一个 “AST Smith”——专门生成随机但合法的 AST。把它丢给 `zig fmt`(再加上一些更早期的简单随机源码测试),一共发现并修复了 **20 个独立 bug**,其中一部分是新发现的。
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [AutoCorrect Lint] <AutoCorrect> reported by reviewdog 🐶

Suggested change
新的 Smith 接口本身已经被用来构建一个 “AST Smith”——专门生成随机但合法的 AST。把它丢给 `zig fmt`(再加上一些更早期的简单随机源码测试),一共发现并修复了 **20 个独立 bug**,其中一部分是新发现的。
新的 Smith 接口本身已经被用来构建一个“AST Smith”——专门生成随机但合法的 AST。把它丢给 `zig fmt`(再加上一些更早期的简单随机源码测试),一共发现并修复了 **20 个独立 bug**,其中一部分是新发现的。


bug 修复方面:

- 大量 “one-possible-value” 类型上的 switch 相关 bug 被修复
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [AutoCorrect Lint] <AutoCorrect> reported by reviewdog 🐶

Suggested change
- 大量 “one-possible-value” 类型上的 switch 相关 bug 被修复
- 大量“one-possible-value”类型上的 switch 相关 bug 被修复

@Fn(param_types, &@splat(.{}), ReturnType, .{ .@"callconv" = .c })
```

`@Struct` 同样采用 “struct of arrays”:字段名、字段类型、字段属性各自传一组数组,属性里包含 alignment、`comptime` 标志、字段默认值:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [AutoCorrect Lint] <AutoCorrect> reported by reviewdog 🐶

Suggested change
`@Struct` 同样采用 “struct of arrays”:字段名、字段类型、字段属性各自传一组数组,属性里包含 alignment、`comptime` 标志、字段默认值:
`@Struct`同样采用“struct of arrays”:字段名、字段类型、字段属性各自传一组数组,属性里包含 alignment、`comptime` 标志、字段默认值:

}
```

由于下面 “`extern` 场景必须显式指定 tag type / backing type” 这条规则的存在,现在某些场景下显式指定 packed union 的 backing integer 是必须的。
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [AutoCorrect Lint] <AutoCorrect> reported by reviewdog 🐶

Suggested change
由于下面 `extern` 场景必须显式指定 tag type / backing type” 这条规则的存在,现在某些场景下显式指定 packed union 的 backing integer 是必须的。
由于下面“`extern` 场景必须显式指定 tag type / backing type” 这条规则的存在,现在某些场景下显式指定 packed union 的 backing integer 是必须的。

}
```

由于下面 “`extern` 场景必须显式指定 tag type / backing type” 这条规则的存在,现在某些场景下显式指定 packed union 的 backing integer 是必须的。
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [AutoCorrect Lint] <AutoCorrect> reported by reviewdog 🐶

Suggested change
由于下面 `extern` 场景必须显式指定 tag type / backing type” 这条规则的存在,现在某些场景下显式指定 packed union 的 backing integer 是必须的。
由于下面 场景必须显式指定 tag type / backing type”这条规则的存在,现在某些场景下显式指定 packed union 的 backing integer 是必须的。��须的


### 文件系统和路径 API 有一批实用迁移点

`fs` 全部 API 都迁到了 `Io`。和 0.15 那次 “writergate” 不同,这次虽然 breaking 范围很大,但绝大多数迁移机械、不需要特别多的判断。最典型的形态就是给原本无参的方法加一个 `io`:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [AutoCorrect Lint] <AutoCorrect> reported by reviewdog 🐶

Suggested change
`fs` 全部 API 都迁到了 `Io`。和 0.15 那次 “writergate” 不同,这次虽然 breaking 范围很大,但绝大多数迁移机械、不需要特别多的判断。最典型的形态就是给原本无参的方法加一个 `io`
`fs` 全部 API 都��。和 0.15 那次“writergate”不同,这次虽然 breaking 范围很大,但绝大多数迁移机械、不需要特别多的判断。最典型的形态就是给原本无参的方法加一个法加一个 `io`


也就是说,Zig 不再想长期维护那批半高层、半底层的历史包装函数。

### `std.mem` 的 “index of” 系列统一更名为 “find”
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [AutoCorrect Lint] <AutoCorrect> reported by reviewdog 🐶

Suggested change
### `std.mem`“index of” 系列统一更名为 “find”
### `std.mem`“index of”系列统一更名为“find”

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant