Skip to content

Commit 7e79423

Browse files
authored
Merge pull request #1340 from Mark-Simulacrum/1.79.0
Add 1.79 announcement
2 parents 5b5c18b + e5298c3 commit 7e79423

File tree

1 file changed

+166
-0
lines changed

1 file changed

+166
-0
lines changed

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

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
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, and have their type inferred rather than written explicitly, 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+
### 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 type bounds (RPIT, TAIT)** - This allows constraining associated types that are associated with the opaque type without having to *name* the opaque type. For example, `impl Iterator<Item: Copy>` defines an iterator whose item is `Copy` without having to actually name that item bound.
68+
69+
See [the stabilization report](https://github.com/rust-lang/rust/pull/122055/#issue-2170532454) for more details.
70+
71+
### Extending automatic temporary lifetime extension
72+
73+
Temporaries which are immediately referenced in construction are now
74+
automatically lifetime extended in `match` and `if` constructs. This has the
75+
same behavior as lifetime extension for temporaries in block constructs.
76+
77+
For example:
78+
79+
```rust
80+
let a = if true {
81+
..;
82+
&temp() // used to error, but now gets lifetime extended
83+
} else {
84+
..;
85+
&temp() // used to error, but now gets lifetime extended
86+
};
87+
```
88+
89+
and
90+
91+
```rust
92+
let a = match () {
93+
_ => {
94+
..;
95+
&temp() // used to error, but now gets lifetime extended
96+
}
97+
};
98+
```
99+
100+
are now consistent with prior behavior:
101+
102+
```rust
103+
let a = {
104+
..;
105+
&temp() // lifetime is extended
106+
};
107+
```
108+
109+
This behavior is backwards compatible since these programs used to fail compilation.
110+
111+
### Frame pointers enabled in standard library builds
112+
113+
The standard library distributed by the Rust project is now compiled with
114+
`-Cforce-frame-pointers=yes`, enabling downstream users to more easily profile
115+
their programs. Note that the standard library also continues to come up with
116+
line-level debug info (e.g., DWARF), though that is [stripped by default] in Cargo's release profiles.
117+
118+
[stripped by default]: https://blog.rust-lang.org/2024/03/21/Rust-1.77.0.html#enable-strip-in-release-profiles-by-default
119+
120+
### Stabilized APIs
121+
122+
- [`{integer}::unchecked_add`](https://doc.rust-lang.org/stable/core/primitive.i32.html#method.unchecked_add)
123+
- [`{integer}::unchecked_mul`](https://doc.rust-lang.org/stable/core/primitive.i32.html#method.unchecked_mul)
124+
- [`{integer}::unchecked_sub`](https://doc.rust-lang.org/stable/core/primitive.i32.html#method.unchecked_sub)
125+
- [`<[T]>::split_at_unchecked`](https://doc.rust-lang.org/stable/core/primitive.slice.html#method.split_at_unchecked)
126+
- [`<[T]>::split_at_mut_unchecked`](https://doc.rust-lang.org/stable/core/primitive.slice.html#method.split_at_mut_unchecked)
127+
- [`<[u8]>::utf8_chunks`](https://doc.rust-lang.org/stable/core/primitive.slice.html#method.utf8_chunks)
128+
- [`str::Utf8Chunks`](https://doc.rust-lang.org/stable/core/str/struct.Utf8Chunks.html)
129+
- [`str::Utf8Chunk`](https://doc.rust-lang.org/stable/core/str/struct.Utf8Chunk.html)
130+
- [`<*const T>::is_aligned`](https://doc.rust-lang.org/stable/core/primitive.pointer.html#method.is_aligned)
131+
- [`<*mut T>::is_aligned`](https://doc.rust-lang.org/stable/core/primitive.pointer.html#method.is_aligned-1)
132+
- [`NonNull::is_aligned`](https://doc.rust-lang.org/stable/core/ptr/struct.NonNull.html#method.is_aligned)
133+
- [`<*const [T]>::len`](https://doc.rust-lang.org/stable/core/primitive.pointer.html#method.len)
134+
- [`<*mut [T]>::len`](https://doc.rust-lang.org/stable/core/primitive.pointer.html#method.len-1)
135+
- [`<*const [T]>::is_empty`](https://doc.rust-lang.org/stable/core/primitive.pointer.html#method.is_empty)
136+
- [`<*mut [T]>::is_empty`](https://doc.rust-lang.org/stable/core/primitive.pointer.html#method.is_empty-1)
137+
- [`NonNull::<[T]>::is_empty`](https://doc.rust-lang.org/stable/core/ptr/struct.NonNull.html#method.is_empty)
138+
- [`CStr::count_bytes`](https://doc.rust-lang.org/stable/core/ffi/c_str/struct.CStr.html#method.count_bytes)
139+
- [`io::Error::downcast`](https://doc.rust-lang.org/stable/std/io/struct.Error.html#method.downcast)
140+
- [`num::NonZero<T>`](https://doc.rust-lang.org/stable/core/num/struct.NonZero.html)
141+
- [`path::absolute`](https://doc.rust-lang.org/stable/std/path/fn.absolute.html)
142+
- [`proc_macro::Literal::byte_character`](https://doc.rust-lang.org/stable/proc_macro/struct.Literal.html#method.byte_character)
143+
- [`proc_macro::Literal::c_string`](https://doc.rust-lang.org/stable/proc_macro/struct.Literal.html#method.c_string)
144+
145+
These APIs are now stable in const contexts:
146+
147+
- [`Atomic*::into_inner`](https://doc.rust-lang.org/stable/core/sync/atomic/struct.AtomicUsize.html#method.into_inner)
148+
- [`io::Cursor::new`](https://doc.rust-lang.org/stable/std/io/struct.Cursor.html#method.new)
149+
- [`io::Cursor::get_ref`](https://doc.rust-lang.org/stable/std/io/struct.Cursor.html#method.get_ref)
150+
- [`io::Cursor::position`](https://doc.rust-lang.org/stable/std/io/struct.Cursor.html#method.position)
151+
- [`io::empty`](https://doc.rust-lang.org/stable/std/io/fn.empty.html)
152+
- [`io::repeat`](https://doc.rust-lang.org/stable/std/io/fn.repeat.html)
153+
- [`io::sink`](https://doc.rust-lang.org/stable/std/io/fn.sink.html)
154+
- [`panic::Location::caller`](https://doc.rust-lang.org/stable/std/panic/struct.Location.html#method.caller)
155+
- [`panic::Location::file`](https://doc.rust-lang.org/stable/std/panic/struct.Location.html#method.file)
156+
- [`panic::Location::line`](https://doc.rust-lang.org/stable/std/panic/struct.Location.html#method.line)
157+
- [`panic::Location::column`](https://doc.rust-lang.org/stable/std/panic/struct.Location.html#method.column)
158+
159+
160+
### Other changes
161+
162+
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).
163+
164+
## Contributors to 1.79.0
165+
166+
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)