@@ -72,11 +72,11 @@ Match ergonomics works a little differently in edition 2024 and above.
72
72
## ` mut ` no longer strips the inherited reference
73
73
74
74
` 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.
75
76
76
77
``` rust
77
78
// ! 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
80
80
```
81
81
82
82
## Matching against inherited references
@@ -132,14 +132,12 @@ including the "default binding mode" terminology. Refer to [RFC 2005](./2005-mat
132
132
133
133
## Edition 2024: ` mut ` does not reset binding mode to by-value
134
134
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.
138
137
139
138
``` rust
140
139
// ! Edition ≥ 2024
141
- let [mut a ] = & [42 ];
142
- a = & 47 ;
140
+ // let [mut a] = &[42]; //ERROR
143
141
```
144
142
145
143
## Edition 2024: ` & ` patterns can match against ` &mut ` references
@@ -441,7 +439,8 @@ concerns with certain proposals for "deref patterns".
441
439
[ future-possibilities ] : #future-possibilities
442
440
443
441
- 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.
445
444
- Future changes to reference types (partial borrows, language sugar for ` Pin ` ,
446
445
etc) may interact with match ergonomics.
447
446
@@ -461,7 +460,7 @@ behind `&`:
461
460
462
461
``` rust
463
462
// 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
465
464
```
466
465
467
466
There are two strategies we could take to support this:
0 commit comments