Skip to content

Commit a9e7562

Browse files
Add 1.79 announcement
1 parent 5b5c18b commit a9e7562

File tree

1 file changed

+167
-0
lines changed

1 file changed

+167
-0
lines changed

posts/2024-06-13-Rust-1.79.0.md

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
---
2+
layout: post
3+
title: "Announcing Rust 1.79.0"
4+
author: The Rust Release Team
5+
release: true
6+
---
7+
8+
The Rust team is happy to announce a new version of Rust, 1.79.0. Rust is a programming language empowering everyone to build reliable and efficient software.
9+
10+
If you have a previous version of Rust installed via `rustup`, you can get 1.79.0 with:
11+
12+
```console
13+
$ rustup update stable
14+
```
15+
16+
If you don't have it already, you can [get `rustup`](https://www.rust-lang.org/install.html) from the appropriate page on our website, and check out the [detailed release notes for 1.79.0](https://doc.rust-lang.org/nightly/releases.html#version-1790-2024-06-13).
17+
18+
If you'd like to help us out by testing future releases, you might consider updating locally to use the beta channel (`rustup default beta`) or the nightly channel (`rustup default nightly`). Please [report](https://github.com/rust-lang/rust/issues/new/choose) any bugs you might come across!
19+
20+
## What's in 1.79.0 stable
21+
22+
### Inline `const` expressions
23+
24+
`const { ... }` blocks are now stable in expression position, permitting
25+
explicitly entering a const context without requiring extra declarations (e.g.,
26+
defining `const` items or associated constants on a trait).
27+
28+
Unlike const items (`const ITEM: ... = ...`), inline consts are able to make
29+
use of in-scope generics, making them particularly useful for inline code snippets. For example, a pattern like:
30+
31+
```rust
32+
const EMPTY: Option<Vec<u8>> = None;
33+
let foo = [EMPTY; 100];
34+
```
35+
36+
can now be written like this:
37+
38+
```rust
39+
let foo = [const { None }; 100];
40+
```
41+
42+
Notably, this is also true of generic contexts, where previously a verbose trait declaration with an associated constant would be required:
43+
44+
```rust
45+
fn create_none_array<T, const N: usize>() -> [Option<T>; N] {
46+
[const { None::<T> }; N]
47+
}
48+
```
49+
50+
This makes this code much more succinct and easier to read.
51+
52+
See the [reference documentation](https://doc.rust-lang.org/nightly/reference/expressions/block-expr.html#const-blocks) for details.
53+
54+
### Accept bounds in associated type position
55+
56+
Rust 1.79 stabilizes the associated item bounds syntax, which allows us to put
57+
bounds in associated type position within other bounds, i.e.
58+
`T: Trait<Assoc: Bounds...>`. This avoids the need to provide an extra,
59+
explicit generic type just to constrain the associated type.
60+
61+
This feature allows specifying bounds in a few places that previously either
62+
were not possible or imposed extra, unnecessary constraints on usage:
63+
64+
* **`where` clauses** - in this position, this is equivalent to breaking up the bound into two (or more) `where` clauses. For example, `where T: Trait<Assoc: Bound>` is equivalent to `where T: Trait, <T as Trait>::Assoc: Bound`.
65+
* **Supertraits** - a bound specified via the new syntax is implied when the trait is used, unlike where clauses. Sample syntax: `trait CopyIterator: Iterator<Item: Copy> {}`.
66+
* **Associated type item bounds** - This allows constraining the *nested* rigid projections that are associated with a trait's associated types. e.g. `trait Trait { type Assoc: Trait2<Assoc2: Copy>; }`.
67+
* **opaque item bounds (RPIT, TAIT)** - This allows constraining associated types that are associated with the opaque without having to *name* the opaque. For example, `impl Iterator<Item: Copy>` defines an iterator whose item is `Copy` without having to actually name that item bound.
68+
69+
See [stabilization report](https://github.com/rust-lang/rust/pull/122055/#issue-2170532454) for more details.
70+
71+
### Extending automatic temporary lifetime extension
72+
73+
Continuing the efforts of removing unnecessary lifetime-related errors,
74+
temporaries which are immediately referenced in construction are now
75+
automatically lifetime extended in `match` and `if` constructs. This has the
76+
same behavior as lifetime extension for temporaries in block constructs.
77+
78+
For example:
79+
80+
```rust
81+
let a = if true {
82+
..;
83+
&temp() // used to error, but now gets lifetime extended
84+
} else {
85+
..;
86+
&temp() // used to error, but now gets lifetime extended
87+
};
88+
```
89+
90+
and
91+
92+
```rust
93+
let a = match () {
94+
_ => {
95+
..;
96+
&temp() // used to error, but now gets lifetime extended
97+
}
98+
};
99+
```
100+
101+
are now consistent with prior behavior:
102+
103+
```rust
104+
let a = {
105+
..;
106+
&temp() // lifetime is extended
107+
};
108+
```
109+
110+
This behavior is backwards compatible since these programs used to fail compilation.
111+
112+
### Frame pointers enabled in standard library builds
113+
114+
The standard library distributed by the Rust project is now compiled with
115+
`-Cforce-frame-pointers=yes`, enabling downstream users to more easily profile
116+
their programs. Note that the standard library also continues to come up with
117+
line-level debug info (e.g., DWARF), though that is [stripped by default] in Cargo's release profiles.
118+
119+
[stripped by default]: https://blog.rust-lang.org/2024/03/21/Rust-1.77.0.html#enable-strip-in-release-profiles-by-default
120+
121+
### Stabilized APIs
122+
123+
- [`{integer}::unchecked_add`](https://doc.rust-lang.org/stable/core/primitive.i32.html#method.unchecked_add)
124+
- [`{integer}::unchecked_mul`](https://doc.rust-lang.org/stable/core/primitive.i32.html#method.unchecked_mul)
125+
- [`{integer}::unchecked_sub`](https://doc.rust-lang.org/stable/core/primitive.i32.html#method.unchecked_sub)
126+
- [`<[T]>::split_at_unchecked`](https://doc.rust-lang.org/stable/core/primitive.slice.html#method.split_at_unchecked)
127+
- [`<[T]>::split_at_mut_unchecked`](https://doc.rust-lang.org/stable/core/primitive.slice.html#method.split_at_mut_unchecked)
128+
- [`<[u8]>::utf8_chunks`](https://doc.rust-lang.org/stable/core/primitive.slice.html#method.utf8_chunks)
129+
- [`str::Utf8Chunks`](https://doc.rust-lang.org/stable/core/str/struct.Utf8Chunks.html)
130+
- [`str::Utf8Chunk`](https://doc.rust-lang.org/stable/core/str/struct.Utf8Chunk.html)
131+
- [`<*const T>::is_aligned`](https://doc.rust-lang.org/stable/core/primitive.pointer.html#method.is_aligned)
132+
- [`<*mut T>::is_aligned`](https://doc.rust-lang.org/stable/core/primitive.pointer.html#method.is_aligned-1)
133+
- [`NonNull::is_aligned`](https://doc.rust-lang.org/stable/core/ptr/struct.NonNull.html#method.is_aligned)
134+
- [`<*const [T]>::len`](https://doc.rust-lang.org/stable/core/primitive.pointer.html#method.len)
135+
- [`<*mut [T]>::len`](https://doc.rust-lang.org/stable/core/primitive.pointer.html#method.len-1)
136+
- [`<*const [T]>::is_empty`](https://doc.rust-lang.org/stable/core/primitive.pointer.html#method.is_empty)
137+
- [`<*mut [T]>::is_empty`](https://doc.rust-lang.org/stable/core/primitive.pointer.html#method.is_empty-1)
138+
- [`NonNull::<[T]>::is_empty`](https://doc.rust-lang.org/stable/core/ptr/struct.NonNull.html#method.is_empty)
139+
- [`CStr::count_bytes`](https://doc.rust-lang.org/stable/core/ffi/c_str/struct.CStr.html#method.count_bytes)
140+
- [`io::Error::downcast`](https://doc.rust-lang.org/stable/std/io/struct.Error.html#method.downcast)
141+
- [`num::NonZero<T>`](https://doc.rust-lang.org/stable/core/num/struct.NonZero.html)
142+
- [`path::absolute`](https://doc.rust-lang.org/stable/std/path/fn.absolute.html)
143+
- [`proc_macro::Literal::byte_character`](https://doc.rust-lang.org/stable/proc_macro/struct.Literal.html#method.byte_character)
144+
- [`proc_macro::Literal::c_string`](https://doc.rust-lang.org/stable/proc_macro/struct.Literal.html#method.c_string)
145+
146+
These APIs are now stable in const contexts:
147+
148+
- [`Atomic*::into_inner`](https://doc.rust-lang.org/stable/core/sync/atomic/struct.AtomicUsize.html#method.into_inner)
149+
- [`io::Cursor::new`](https://doc.rust-lang.org/stable/std/io/struct.Cursor.html#method.new)
150+
- [`io::Cursor::get_ref`](https://doc.rust-lang.org/stable/std/io/struct.Cursor.html#method.get_ref)
151+
- [`io::Cursor::position`](https://doc.rust-lang.org/stable/std/io/struct.Cursor.html#method.position)
152+
- [`io::empty`](https://doc.rust-lang.org/stable/std/io/fn.empty.html)
153+
- [`io::repeat`](https://doc.rust-lang.org/stable/std/io/fn.repeat.html)
154+
- [`io::sink`](https://doc.rust-lang.org/stable/std/io/fn.sink.html)
155+
- [`panic::Location::caller`](https://doc.rust-lang.org/stable/std/panic/struct.Location.html#method.caller)
156+
- [`panic::Location::file`](https://doc.rust-lang.org/stable/std/panic/struct.Location.html#method.file)
157+
- [`panic::Location::line`](https://doc.rust-lang.org/stable/std/panic/struct.Location.html#method.line)
158+
- [`panic::Location::column`](https://doc.rust-lang.org/stable/std/panic/struct.Location.html#method.column)
159+
160+
161+
### Other changes
162+
163+
Check out everything that changed in [Rust](https://github.com/rust-lang/rust/releases/tag/1.79.0), [Cargo](https://github.com/rust-lang/cargo/blob/master/CHANGELOG.md#cargo-179-2024-06-13), and [Clippy](https://github.com/rust-lang/rust-clippy/blob/master/CHANGELOG.md#rust-179).
164+
165+
## Contributors to 1.79.0
166+
167+
Many people came together to create Rust 1.79.0. We couldn't have done it without all of you. [Thanks!](https://thanks.rust-lang.org/rust/1.79.0/)

0 commit comments

Comments
 (0)