rust/compiler/rustc_middle/src
Matthias Krüger c1ed1f133e
Rollup merge of #131381 - Nadrieril:min-match-ergonomics, r=pnkfelix
Implement edition 2024 match ergonomics restrictions

This implements the minimalest version of [match ergonomics for edition 2024](https://rust-lang.github.io/rfcs/3627-match-ergonomics-2024.html). This minimal version makes it an error to ever reset the default binding mode. The implemented proposal is described precisely [here](https://hackmd.io/zUqs2ISNQ0Wrnxsa9nhD0Q#RFC-3627-nano), where it is called "RFC 3627-nano".

Rules:
- Rule 1C: When the DBM (default binding mode) is not `move` (whether or not behind a reference), writing `mut`, `ref`, or `ref mut` on a binding is an error.
- Rule 2C: Reference patterns can only match against references in the scrutinee when the DBM is `move`.

This minimal version is forward-compatible with the main proposals for match ergonomics 2024: [RFC3627](https://rust-lang.github.io/rfcs/3627-match-ergonomics-2024.html) itself, the alternative [rule 4-early variant](https://rust-lang.github.io/rfcs/3627-match-ergonomics-2024.html), and [others](https://hackmd.io/zUqs2ISNQ0Wrnxsa9nhD0Q). The idea is to give us more time to iron out a final proposal.

This includes a migration lint that desugars any offending pattern into one that doesn't make use of match ergonomics. Such patterns have identical meaning across editions.

This PR insta-stabilizes the proposed behavior onto edition 2024.

r? `@ghost`

Tracking:

- https://github.com/rust-lang/rust/issues/123076
2024-10-16 19:18:30 +02:00
..
dep_graph Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
hir rm ItemKind::OpaqueTy 2024-10-04 23:28:22 +00:00
hooks Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
infer Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
middle Simplify bound var resolution. 2024-10-04 23:44:27 +00:00
mir Remove Engine::new_gen_kill. 2024-10-14 16:35:28 +11:00
query Simplify bound var resolution. 2024-10-04 23:44:27 +00:00
thir various fixes for naked_asm! implementation 2024-10-06 19:00:09 +02:00
traits Swap PredicateObligation to ThinVec 2024-10-12 15:17:16 +01:00
ty Rollup merge of #131381 - Nadrieril:min-match-ergonomics, r=pnkfelix 2024-10-16 19:18:30 +02:00
util Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
arena.rs Compiler: Rename "object safe" to "dyn compatible" 2024-09-25 13:26:48 +02:00
error.rs Use bool in favor of Option<()> for diagnostics 2024-08-21 01:31:11 -04:00
lib.rs Stabilize const_option 2024-10-12 17:07:13 -04:00
lint.rs Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
macros.rs Improve const traits diagnostics for new desugaring 2024-10-02 19:45:17 +08:00
metadata.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
tests.rs Give an item related to issue 27438 a more meaningful name 2024-04-30 22:27:19 +02:00
thir.rs various fixes for naked_asm! implementation 2024-10-06 19:00:09 +02:00
values.rs only query params_in_repr if def kind is adt 2024-10-02 17:36:31 +08:00