diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-10-16 19:18:30 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-16 19:18:30 +0200 |
| commit | c1ed1f133e4e07b5cb03ce44cb9ed6881d7ae6ca (patch) | |
| tree | 3dbe45433fedba0c113535df6c3b480470c9bb6b /compiler/rustc_mir_build/src/errors.rs | |
| parent | 1817de609b0ffaab0cf32de6baae5944f6f6e7d6 (diff) | |
| parent | 2ef0a8fdfd5142e8a524f4dc9fff8c65d0bd7cc2 (diff) | |
| download | rust-c1ed1f133e4e07b5cb03ce44cb9ed6881d7ae6ca.tar.gz rust-c1ed1f133e4e07b5cb03ce44cb9ed6881d7ae6ca.zip | |
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
Diffstat (limited to 'compiler/rustc_mir_build/src/errors.rs')
| -rw-r--r-- | compiler/rustc_mir_build/src/errors.rs | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/compiler/rustc_mir_build/src/errors.rs b/compiler/rustc_mir_build/src/errors.rs index 42be7f9402e..00f65e0c7d0 100644 --- a/compiler/rustc_mir_build/src/errors.rs +++ b/compiler/rustc_mir_build/src/errors.rs @@ -983,6 +983,8 @@ pub(crate) struct Rust2024IncompatiblePat { pub(crate) struct Rust2024IncompatiblePatSugg { pub(crate) suggestion: Vec<(Span, String)>, + /// Whether the incompatibility is a hard error because a relevant span is in edition 2024. + pub(crate) is_hard_error: bool, } impl Subdiagnostic for Rust2024IncompatiblePatSugg { |
