On function and method calls in patterns, link to the book
``` error: expected a pattern, found an expression --> f889.rs:3:13 | 3 | let (x, y.drop()) = (1, 2); //~ ERROR | ^^^^^^^^ not a pattern | = note: arbitrary expressions are not allowed in patterns: <https://doc.rust-lang.org/book/ch18-00-patterns.html> error[E0532]: expected a pattern, found a function call --> f889.rs:2:13 | 2 | let (x, drop(y)) = (1, 2); //~ ERROR | ^^^^ not a tuple struct or tuple variant | = note: function calls are not allowed in patterns: <https://doc.rust-lang.org/book/ch18-00-patterns.html> ``` Fix #97200.
This commit is contained in:
parent
14f303bc14
commit
7f5548fa8b
19 changed files with 156 additions and 64 deletions
|
@ -812,7 +812,8 @@ parse_unexpected_expr_in_pat =
|
|||
*[false] a pattern
|
||||
}, found an expression
|
||||
|
||||
.label = arbitrary expressions are not allowed in patterns
|
||||
.label = not a pattern
|
||||
.note = arbitrary expressions are not allowed in patterns: <https://doc.rust-lang.org/book/ch18-00-patterns.html>
|
||||
|
||||
parse_unexpected_expr_in_pat_const_sugg = consider extracting the expression into a `const`
|
||||
|
||||
|
|
|
@ -2608,6 +2608,7 @@ pub(crate) struct ExpectedCommaAfterPatternField {
|
|||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(parse_unexpected_expr_in_pat)]
|
||||
#[note]
|
||||
pub(crate) struct UnexpectedExpressionInPattern {
|
||||
/// The unexpected expr's span.
|
||||
#[primary_span]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue