rust/compiler/rustc_parse/src
Jonathan Brouwer 70f1120363
Rollup merge of #151102 - zachs18:mut-ref-in-struct-pattern-shorthand-gate, r=JonathanBrouwer
Feature-gate `mut ref` patterns in struct pattern field shorthand

Tracking issue for `mut_ref` (and other parts of Match Ergonomics 2024): https://github.com/rust-lang/rust/issues/123076

https://github.com/rust-lang/rust/pull/123080 introduced `mut ref`[^1] patterns (for by-reference bindings where the binding itself is mutable), feature-gated behind the `mut_ref` feature, except for in struct pattern shorthand, where the feature gating was missing. Thus, `mut ref` patterns in struct pattern shorthand has been unintentionally stable for ~18 months (since 1.79.0 ([compiler explorer](https://rust.godbolt.org/z/4WTrvhboT))).

This PR adds feature-gating for `mut ref` patterns in struct pattern shorthand. Since this is reverting an accidental stabilization, this probably needs a crater run and a T-lang FCP?

Some alternative possibilities:

* Do nothing (let the inconsistency exist until `feature(mut_ref)` is stabilized)
* Document the existing behavior
* Do a FCW instead of fully feature-gating
* Stabilize `feature(mut_ref)`

CC https://github.com/rust-lang/rust/pull/123080#issuecomment-3746793632

CC @Nadrieril

[^1]: everything in this description also applies analogously to `mut ref mut` patterns.
2026-01-31 21:42:46 +01:00
..
lexer Fix ICE when parsing frontmatter without newline 2026-01-31 08:51:40 +00:00
parser Rollup merge of #151102 - zachs18:mut-ref-in-struct-pattern-shorthand-gate, r=JonathanBrouwer 2026-01-31 21:42:46 +01:00
errors.rs fix(parser): Disallow CR in frontmatter 2026-01-28 13:01:02 -06:00
lib.rs Remove all allows for diagnostic_outside_of_impl and untranslatable_diagnostic throughout the codebase 2026-01-19 17:39:49 +01:00