|
|
@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
# Rust 新版解读 | 1.69 | cargo fix
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
> Rust 1.69 官方 release doc: [Announcing Rust 1.69.0 | Rust Blog](https://blog.rust-lang.org/2023/04/20/Rust-1.69.0.html)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
通过 [rustup](https://www.rust-lang.org/tools/install) 安装的同学可以使用以下命令升级到 1.69 版本:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
|
|
|
$ rustup update stable
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Cargo 提供自动修复建议
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
在 Rust 1.29.0 版本添加的 `cargo fix` 子命令,能够自动修复一些简单的编译错误。从那以后,能够自动修复的错误/警告原因的数量一直在稳步增加。此外,还增加了对自动修复一些简单的 Clippy 警告的支持。
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
为了让更多人注意到这些能力,现在当检测到可自动修复的错误时,Cargo 会建议运行 `cargo fix` 或 `cargo clippy --fix` 命令:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
|
|
|
warning: unused import: `std::hash::Hash`
|
|
|
|
|
|
|
|
--> src/main.rs:1:5
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 | use std::hash::Hash;
|
|
|
|
|
|
|
|
| ^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
= note: `#[warn(unused_imports)]` on by default
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
warning: `foo` (bin "foo") generated 1 warning (run `cargo fix --bin "foo"` to apply 1 suggestion)
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
注意上面的完整命令(即包含 `--bin foo`)仅在你想要精确修复一个单独的 crate 时需要附上。默认执行 workspace 下所有 fixs 只需要 `cargo fix` 。
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## 构建脚步默认不再包含调试信息
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
为了提高编译速度,Cargo 现在默认避免在构建脚本中发出调试信息。构建脚本成功执行时不会有可见的效果,但构建脚本中的回溯(backtraces)将包含更少的信息。
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
所以如果想要 debug 构建脚本,需要额外开启调试信息,在 `Cargo.toml` 文件里添加
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```text
|
|
|
|
|
|
|
|
[profile.dev.build-override]
|
|
|
|
|
|
|
|
debug = true
|
|
|
|
|
|
|
|
[profile.release.build-override]
|
|
|
|
|
|
|
|
debug = true
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Others
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
其它更新细节,和稳定的API列表,参考[原Blog](https://blog.rust-lang.org/2023/04/20/Rust-1.69.0.html#stabilized-apis)
|
|
|
|
|
|
|
|
|