发布 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 stable 版本中有哪些新内容

此补丁版本修复了 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 更改。