1
Fork 0

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:
Esteban Küber 2024-10-06 01:44:59 +00:00
parent 14f303bc14
commit 7f5548fa8b
19 changed files with 156 additions and 64 deletions

View file

@ -2,8 +2,9 @@ error: expected a pattern range bound, found an expression
--> $DIR/range_pat_interactions1.rs:17:16
|
LL | 0..5+1 => errors_only.push(x),
| ^^^ arbitrary expressions are not allowed in patterns
| ^^^ not a pattern
|
= note: arbitrary expressions are not allowed in patterns: <https://doc.rust-lang.org/book/ch18-00-patterns.html>
help: consider extracting the expression into a `const`
|
LL + const VAL: /* Type */ = 5+1;

View file

@ -14,8 +14,9 @@ error: expected a pattern range bound, found an expression
--> $DIR/range_pat_interactions2.rs:10:18
|
LL | 0..=(5+1) => errors_only.push(x),
| ^^^ arbitrary expressions are not allowed in patterns
| ^^^ not a pattern
|
= note: arbitrary expressions are not allowed in patterns: <https://doc.rust-lang.org/book/ch18-00-patterns.html>
help: consider extracting the expression into a `const`
|
LL + const VAL: /* Type */ = 5+1;