The Rust team has published a new corrective release of Rust, 1.41.1. Rust is a programming language that allows everyone to create reliable and efficient software.
If you installed the previous version of Rust using tools rustup
, then to upgrade to version 1.41.1 you just need to run the following command:
rustup update stable
If you havenβt already installed it rustup
, you can install it from the corresponding page of our website
What is included in the stable version 1.41.1
Rust 1.41.1 is dedicated to two critical regressions that appeared in Rust 1.41.0: incorrectness in static lifetimes and incorrect compilation that causes segmentation errors. These regressions do not affect previous releases of Rust, and we recommend that users of Rust 1.41.0 upgrade as quickly as possible. Another problem related to the interaction between lifetimes 'static
and trait implementations was Copy
present since Rust 1.0 and is also fixed by this release.
static
Element Verification Failure
In Rust 1.41.0, due to some changes in the internal representation of static
values, the borrowing analyzer accidentally resolved some erroneous programs. In particular, the borrowing analyzer did not check the correctness of the type of static
elements. This, in turn, made it possible to temporarily assign values ββwith a lifetime shorter than 'static
to the static
variable:
static mut MY_STATIC: &'static u8 = &0;
fn main() {
let my_temporary = 42;
unsafe {
MY_STATIC = &my_temporary;
}
}
In 1.41.1, such code will not compile:
error[E0597]: `my_temporary` does not live long enough
--> src/main.rs:6:21
|
6 | MY_STATIC = &my_temporary;
| ------------^^^^^^^^^^^^^
| | |
| | borrowed value does not live long enough
| assignment requires that `my_temporary` is borrowed for `'static`
7 | }
8 | }
| - `my_temporary` dropped here while still borrowed
You can learn more about this error in # 69114 and the PR that fixed it .
Implementation Copy
for lifetime'static
Starting with Rust 1.0, the following error program was successfully compiled:
#[derive(Clone)]
struct Foo<'a>(&'a u32);
impl Copy for Foo<'static> {}
fn main() {
let temporary = 2;
let foo = (Foo(&temporary),);
drop(foo.0);
drop(foo.0);
}
For Rust 1.41.1, this problem has been fixed with the same PR as above . Compiling the program now produces the following error:
error[E0597]: `temporary` does not live long enough
--> src/main.rs:7:20
|
7 | let foo = (Foo(&temporary),);
| ^^^^^^^^^^ borrowed value does not live long enough
8 | drop(foo.0);
| ----- copying this value requires that
| `temporary` is borrowed for `'static`
9 | drop(foo.0);
10 | }
| - `temporary` dropped here while still borrowed
- , Foo<'a>
, 'a
, Copy
, 'a: 'static
. temporary
'0
'static
, , Foo<'0>
Copy
, drop
.
, .
, Rust 1.41.0, . , , . , LLVM, LLVM 9 LLVM 10.
Rust 1.41.0 LLVM 9 Rust 1.41.1 , . : #69225.
1.41.1
, Rust 1.41.1. , !
Rust - .