























The Rust team is happy to announce a new version of Rust, 1.49.0. Rust is a programming language that is empowering everyone to build reliable and efficient software.
If you have a previous version of Rust installed via rustup, getting Rust 1.49.0 is as easy as:
$ rustup update stable
If you don't have it already, you can get rustup from the
appropriate page on our website, and check out the detailed release notes for
1.49.0 on GitHub.
For this release, we have some new targets and an improvement to the test framework. See the detailed release notes to learn about other changes not covered by this post.
The Rust compiler supports a wide variety of targets, but the Rust Team can't provide the same level of support for all of them. To clearly mark how supported each target is, we use a tiering system:
Rust 1.49.0 promotes the aarch64-unknown-linux-gnu target to Tier 1 support,
bringing our highest guarantees to users of 64-bit ARM systems running Linux!
We expect this change to benefit workloads spanning from embedded to desktops
and servers.
This is an important milestone for the project, since it's the first time a non-x86 target has reached Tier 1 support: we hope this will pave the way for more targets to reach our highest tier in the future.
Note that Android is not affected by this change as it uses a different Tier 2 target.
Rust 1.49.0 also features two targets reaching Tier 2 support:
aarch64-apple-darwin target brings support for Rust on Apple M1 systems.aarch64-pc-windows-msvc target brings support for Rust on 64-bit ARM
devices running Windows on ARM.Developers can expect both of those targets to have prebuilt binaries
installable with rustup from now on! The Rust Team is not running the test
suite on those platforms though, so there might be bugs or instabilities.
Rust's built-in testing framework doesn't have a ton of features, but that doesn't mean it can't be improved! Consider a test that looks like this:
#[test]
fn thready_pass() {
println!("fee");
std::thread::spawn(|| {
println!("fie");
println!("foe");
})
.join()
.unwrap();
println!("fum");
}
Here's what running this test looks like before Rust 1.49.0:
❯ cargo +1.48.0 test
Compiling threadtest v0.1.0 (C:\threadtest)
Finished test [unoptimized + debuginfo] target(s) in 0.38s
Running target\debug\deps\threadtest-02f42ffd9836cae5.exe
running 1 test
fie
foe
test thready_pass ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
Doc-tests threadtest
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
You can see that the output from the thread is printed, which intermixes
from the output of the test framework itself. Wouldn't it be nice
if every println! worked like that one that prints "fum?" Well, that's
the behavior in Rust 1.49.0:
❯ cargo test
Compiling threadtest v0.1.0 (C:\threadtest)
Finished test [unoptimized + debuginfo] target(s) in 0.52s
Running target\debug\deps\threadtest-40aabfaa345584be.exe
running 1 test
test thready_pass ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
Doc-tests threadtest
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
But don't worry; if the test were to fail, you'll still see all of the
output. By adding a panic! to the end of the test, we can see what failure
looks like:
❯ cargo test
Compiling threadtest v0.1.0 (C:\threadtest)
Finished test [unoptimized + debuginfo] target(s) in 0.52s
Running target\debug\deps\threadtest-40aabfaa345584be.exe
running 1 test
test thready_pass ... FAILED
failures:
---- thready_pass stdout ----
fee
fie
foe
fum
thread 'thready_pass' panicked at 'explicit panic', src\lib.rs:11:5
Specifically, the test runner makes sure to capture the output, and saves it in case the test fails.
In Rust 1.49.0, there are three new stable functions:
And two functions were made const:
See the detailed release notes to learn about other changes.
There are other changes in the Rust 1.49.0 release: check out what changed in Rust, Cargo, and Clippy.
Many people came together to create Rust 1.49.0. We couldn't have done it without all of you. Thanks!
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。