-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement edition 2024 match ergonomics restrictions #131381
Conversation
bf3b7f3
to
2ef0a8f
Compare
r? compiler |
Thanks @Nadrieril. Lang discussed the RFC 3627-nano rules in our 2024-10-02 planning meeting, and people were on board with this. So let's... @rfcbot fcp merge |
Team member @traviscross has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns. |
@rfcbot reviewed |
1 similar comment
@rfcbot reviewed |
@rfcbot reviewed |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
LL | let Foo(mut x) = &Foo(0); | ||
| -^^^^^^^^^ | ||
| | | ||
| help: desugar the match ergonomics: `&` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this message may be a little bit too obtuse for the average reader.
In particular, my guess is that the average person leveraging match ergnonomics may not even know that they are doing so, and so they will not necessarily understand what this help message is telling them to do.
I recommend rephrasing it with a little more direction. Perhaps: "add a &
to the pattern you have written to correspond to the type of the expression being matched" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh yeah excellent point
I had a nit regarding the diagnostic messaging here, but I don't think that needs to block landing this PR. |
@bors r+ |
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#130822 (Add `from_ref` and `from_mut` constructors to `core::ptr::NonNull`.) - rust-lang#131381 (Implement edition 2024 match ergonomics restrictions) - rust-lang#131594 (rustdoc: Rename "object safe" to "dyn compatible") - rust-lang#131686 (Add fast-path when computing the default visibility) - rust-lang#131699 (Try to improve error messages involving aliases in the solver) - rust-lang#131757 (Ignore lint-non-snake-case-crate#proc_macro_ on targets without unwind) - rust-lang#131783 (Fix explicit_iter_loop in rustc_serialize) - rust-lang#131788 (Fix mismatched quotation mark) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#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: - rust-lang#123076
This implements the minimalest version of match ergonomics for edition 2024. This minimal version makes it an error to ever reset the default binding mode. The implemented proposal is described precisely here, where it is called "RFC 3627-nano".
Rules:
move
(whether or not behind a reference), writingmut
,ref
, orref mut
on a binding is an error.move
.This minimal version is forward-compatible with the main proposals for match ergonomics 2024: RFC3627 itself, the alternative rule 4-early variant, and others. 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: