Rust 1.34.1 发布公告

2019年4月25日 · Rust 发布团队

Rust 团队很高兴地宣布 Rust 的新版本 1.34.1 和 rustup 的新版本 1.18.1。Rust 是一种编程语言,它使每个人都能够构建可靠且高效的软件。

如果您之前通过 rustup 安装了 Rust,那么获取 Rust 1.34.1 和 rustup 1.18.1 非常简单,只需运行:

$ rustup update stable

如果您还没有安装,可以从我们网站上的相应页面获取 rustup

1.34.1 稳定版中的新功能

此补丁版本修复了 Clippy 中的两个误报以及检查宏时发生的 panic。Clippy 是一个工具,提供了一系列 lint 来捕获常见错误并改进您的 Rust 代码。

clippy::redundant_closure 中的误报

redundant_closure lint 中的一个误报已被修复。该 lint 没有考虑到借用的数量差异

在下面的代码片段中,方法 required 期望 dep: &D,但 dep 的实际类型是 &&D

dependencies.iter().filter(|dep| dep.required());

Clippy 错误地建议 .filter(Dependency::required),由于借用差异,这会被编译器拒绝。

clippy::missing_const_for_fn 中的误报

missing_const_for_fn lint 中的另一个误报已被修复。此 lint 没有考虑到 trait 实现中的函数不能是 const fn。 例如,给定以下代码片段,该 lint 会触发:

#[derive(PartialEq, Eq)] // warning: this could be a const_fn
struct Point(isize, isize);

impl std::ops::Add for Point {
    type Output = Self;

    fn add(self, other: Self) -> Self { // warning: this could be a const_fn
        Point(self.0 + other.0, self.1 + other.1)
    }
}

rustup 1.18.1 中的新功能

最近发布的 rustup 版本 1.18.0 引入了一个回归,该回归阻止了在旧平台上通过 shell 脚本安装 Rust。发布了一个修复该问题的补丁,避免在不支持 TLS v1.2 的平台上强制使用它。

您可以在其完整发布说明中查看其他 rustup 更改。