Skip to content

Commit 099b71f

Browse files
No more implicit mut ref mut
1 parent 19e0c7c commit 099b71f

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

text/3627-match-ergonomics-2024.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ Match ergonomics works a little differently in edition 2024 and above.
7272
## `mut` no longer strips the inherited reference
7373

7474
`mut` on a binding does not reset the binding mode on edition ≥ 2024.
75+
Instead, `mut` on a binding with non-default binding mode is an error.
7576

7677
```rust
7778
//! Edition ≥ 2024
78-
let (x, mut y) = &(true, false);
79-
let _: (&bool, &bool) = (x, y); // instead of `(&bool, bool)`
79+
//let (x, mut y) = &(true, false); // ERROR
8080
```
8181

8282
## Matching against inherited references
@@ -132,14 +132,12 @@ including the "default binding mode" terminology. Refer to [RFC 2005](./2005-mat
132132

133133
## Edition 2024: `mut` does not reset binding mode to by-value
134134

135-
In the new edition, `mut` no longer resets the binding mode to by-value.
136-
Therefore, it is possible to have a mutable by-reference binding. (An explicit
137-
syntax for this is left to a future RFC.)
135+
In the new edition, `mut` no longer resets the binding mode to by-value;
136+
instead, `mut` on a binding with a by-reference binding mode is an error.
138137

139138
```rust
140139
//! Edition ≥ 2024
141-
let [mut a] = &[42];
142-
a = &47;
140+
// let [mut a] = &[42]; //ERROR
143141
```
144142

145143
## Edition 2024: `&` patterns can match against `&mut` references
@@ -441,7 +439,8 @@ concerns with certain proposals for "deref patterns".
441439
[future-possibilities]: #future-possibilities
442440

443441
- An explicit syntax for mutable by-reference bindings should be chosen at some
444-
point.
442+
point, along with removing the prohibition on implicitly by-reference
443+
mutable bindings.
445444
- Future changes to reference types (partial borrows, language sugar for `Pin`,
446445
etc) may interact with match ergonomics.
447446

@@ -461,7 +460,7 @@ behind `&`:
461460

462461
```rust
463462
// No way to avoid the `ref`, even with this RFC
464-
let &[&mut ref x] = &[&mut 42];
463+
let &[&mut ref x] = &[&mut 42]; // x: &i32
465464
```
466465

467466
There are two strategies we could take to support this:

0 commit comments

Comments
 (0)