-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #123877 - ShE3py:expr-in-pats-2, r=fmease
Further improve diagnostics for expressions in pattern position Follow-up of #118625, see #121697. ```rs fn main() { match 'b' { y.0.0.1.z().f()? as u32 => {}, } } ``` Before: ``` error: expected one of `=>`, ``@`,` `if`, or `|`, found `.` --> src/main.rs:3:10 | 3 | y.0.0.1.z().f()? as u32 => {}, | ^ expected one of `=>`, ``@`,` `if`, or `|` ``` After: ``` error: expected a pattern, found an expression --> src/main.rs:3:9 | 3 | y.0.0.1.z().f()? as u32 => {}, | ^^^^^^^^^^^^^^^^^^^^^^^ arbitrary expressions are not allowed in patterns | help: consider moving the expression to a match arm guard | 3 | val if val == y.0.0.1.z().f()? as u32 => {}, | ~~~ +++++++++++++++++++++++++++++++++ help: consider extracting the expression into a `const` | 2 + const VAL: /* Type */ = y.0.0.1.z().f()? as u32; 3 ~ match 'b' { 4 ~ VAL => {}, | help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`) | 3 | const { y.0.0.1.z().f()? as u32 } => {}, | +++++++ + ``` --- r? fmease `@rustbot` label +A-diagnostics +A-parser +A-patterns +C-enhancement
- Loading branch information
Showing
27 changed files
with
1,813 additions
and
412 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.