feat(docs): support 0.16.0#320
Conversation
There was a problem hiding this comment.
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.
| pub const c = @cImport({ | ||
| @cInclude("stdio.h"); | ||
| @cInclude("math.h"); | ||
| @cInclude("stdlib.h"); | ||
| }); | ||
|
|
||
| const c = @import("c.zig").c; |
There was a problem hiding this comment.
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.
| 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) |
There was a problem hiding this comment.
| - `std.process.getCwd*` 改名为 `currentPath*` | ||
| - `fs.path.relative` 变成纯函数,需要显式传入上下文 | ||
| - `File.Stat.atime` 变成可选值 | ||
| - `std.mem` 里 “index of” 系列统一更名为 “find” |
There was a problem hiding this comment.
🚫 [AutoCorrect Lint] <AutoCorrect> reported by reviewdog 🐶
| - `std.mem` 里 “index of” 系列统一更名为 “find” | |
| - `std.mem`里“index of”系列统一更名为“find”� |
|
|
||
| LLVM 后端这一轮的进展有几条: | ||
|
|
||
| - **实验性支持增量编译**——这并不会加速 “LLVM Emit Object” 这一步(LLVM 自己负责的部分我们做不了什么),但加速了 Zig 编译器侧生成 LLVM bitcode 的过程,因此当你的代码本身就有编译错误时,你能在 LLVM 后端下也获得近乎瞬时的反馈 |
There was a problem hiding this comment.
🚫 [AutoCorrect Lint] <AutoCorrect> reported by reviewdog 🐶
| - **实验性支持增量编译**——这并不会加速 “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” 线程合并。 |
There was a problem hiding this comment.
🚫 [AutoCorrect Lint] <AutoCorrect> reported by reviewdog 🐶
| 后续还会继续推进 LLVM 后端的并行化:让多个线程同时为不同函数生成 LLVM IR,再由一个 “linker” 线程合并。 | |
| 后续还会继续推进 LLVM 后端的并行化:让多个线程同时为不同函数生成 LLVM IR,再由一个“linker”线程合并。 |
|
|
||
| ### 配套的 AST Smith 已经替 zig fmt 找到 20 个 bug | ||
|
|
||
| 新的 Smith 接口本身已经被用来构建一个 “AST Smith”——专门生成随机但合法的 AST。把它丢给 `zig fmt`(再加上一些更早期的简单随机源码测试),一共发现并修复了 **20 个独立 bug**,其中一部分是新发现的。 |
There was a problem hiding this comment.
🚫 [AutoCorrect Lint] <AutoCorrect> reported by reviewdog 🐶
| 新的 Smith 接口本身已经被用来构建一个 “AST Smith”——专门生成随机但合法的 AST。把它丢给 `zig fmt`(再加上一些更早期的简单随机源码测试),一共发现并修复了 **20 个独立 bug**,其中一部分是新发现的。 | |
| 新的 Smith 接口本身已经被用来构建一个“AST Smith”——专门生成随机但合法的 AST。把它丢给 `zig fmt`(再加上一些更早期的简单随机源码测试),一共发现并修复了 **20 个独立 bug**,其中一部分是新发现的。 |
|
|
||
| bug 修复方面: | ||
|
|
||
| - 大量 “one-possible-value” 类型上的 switch 相关 bug 被修复 |
There was a problem hiding this comment.
🚫 [AutoCorrect Lint] <AutoCorrect> reported by reviewdog 🐶
| - 大量 “one-possible-value” 类型上的 switch 相关 bug 被修复 | |
| - 大量“one-possible-value”类型上的 switch 相关 bug 被修复 |
| @Fn(param_types, &@splat(.{}), ReturnType, .{ .@"callconv" = .c }) | ||
| ``` | ||
|
|
||
| `@Struct` 同样采用 “struct of arrays”:字段名、字段类型、字段属性各自传一组数组,属性里包含 alignment、`comptime` 标志、字段默认值: |
There was a problem hiding this comment.
🚫 [AutoCorrect Lint] <AutoCorrect> reported by reviewdog 🐶
| `@Struct` 同样采用 “struct of arrays”:字段名、字段类型、字段属性各自传一组数组,属性里包含 alignment、`comptime` 标志、字段默认值: | |
| `@Struct`同样采用“struct of arrays”:字段名、字段类型、字段属性各自传一组数组,属性里包含 alignment、�`comptime` 标志、字段默认值: |
| } | ||
| ``` | ||
|
|
||
| 由于下面 “`extern` 场景必须显式指定 tag type / backing type” 这条规则的存在,现在某些场景下显式指定 packed union 的 backing integer 是必须的。 |
There was a problem hiding this comment.
🚫 [AutoCorrect Lint] <AutoCorrect> reported by reviewdog 🐶
| 由于下面 “`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 是必须的。 |
There was a problem hiding this comment.
🚫 [AutoCorrect Lint] <AutoCorrect> reported by reviewdog 🐶
| 由于下面 “`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`: |
There was a problem hiding this comment.
🚫 [AutoCorrect Lint] <AutoCorrect> reported by reviewdog 🐶
| `fs` 全部 API 都迁到了 `Io`。和 0.15 那次 “writergate” 不同,这次虽然 breaking 范围很大,但绝大多数迁移机械、不需要特别多的判断。最典型的形态就是给原本无参的方法加一个 `io`: | |
| `fs` 全部 API 都��。和 0.15 那次“writergate”不同,这次虽然 breaking 范围很大,但绝大多数迁移机械、不需要特别多的判断。最典型的形态就是给原本无参的方法加一个法加一个 `io`: |
|
|
||
| 也就是说,Zig 不再想长期维护那批半高层、半底层的历史包装函数。 | ||
|
|
||
| ### `std.mem` 的 “index of” 系列统一更名为 “find” |
There was a problem hiding this comment.
🚫 [AutoCorrect Lint] <AutoCorrect> reported by reviewdog 🐶
| ### `std.mem` 的 “index of” 系列统一更名为 “find” | |
| ### `std.mem`的“index of”系列统一更名为“find”� |
No description provided.