Files
rust/tests/ui/parser
Jacob Pratt 4e637b3c68 Rollup merge of #160279 - ArneshBanerjee:recover-tuple-type-ascription, r=fmease
Recover from tuple patterns with inline element types

If you write the element types inside a tuple pattern:

```rust
let (a: bool, b: u8) = (true, 1);
```

the error you get doesn't really explain the problem:

```
error: expected one of `)`, `,`, `@`, `if`, or `|`, found `:`
 --> src/main.rs:2:11
  |
2 |     let (a: bool, b: u8) = (true, 1);
  |           ^ expected one of `)`, `,`, `@`, `if`, or `|`
```

A let pattern can have a type after it, so now we point out what to do instead:

```
help: to annotate the types of a tuple's elements, write them as a tuple type after the pattern
  |
2 -     let (a: bool, b: u8) = (true, 1);
2 +     let (a, b): (bool, u8) = (true, 1);
  |
```

If an element doesn't have a type written, it just gets `_`, so `(a: bool, b)`
turns into `(a, b): (bool, _)`.

I kept this to let bindings only. That's the case where the pattern doesn't need
a type of its own, so once the types move into the suggestion the rest of the
statement parses fine and you get a single error instead of a pile of follow-up
ones. Match arms, nested patterns and function parameters are left alone.

Closes rust-lang/rust#149246
2026-08-23 05:59:33 -04:00
..
…
2026-07-13 10:54:53 +02:00
2026-07-13 10:54:53 +02:00
fix
2026-07-03 15:45:29 +08:00
fix
2026-07-03 15:45:29 +08:00
2026-06-28 16:10:41 +02:00
2026-07-13 10:54:53 +02:00
fix
2026-06-02 23:00:47 +08:00
fix
2026-06-02 23:00:47 +08:00
2025-07-25 20:38:54 +05:00
2025-07-31 21:25:49 +05:00
2025-09-15 10:48:26 -07:00
fix
2026-06-02 23:00:47 +08:00
fix
2026-06-02 23:00:47 +08:00
2026-07-13 10:54:53 +02:00
2025-08-09 16:27:20 +05:00
2026-02-22 20:20:33 +01:00
2026-08-10 10:05:45 +02:00
2026-08-10 10:05:45 +02:00
2025-10-01 22:45:16 +02:00
2026-07-09 23:34:43 +02:00
2026-07-09 23:34:43 +02:00
2026-07-13 10:54:53 +02:00
2026-07-13 10:54:53 +02:00
2025-11-27 14:13:58 -05:00
2025-11-27 11:19:00 -05:00
2025-11-27 11:19:00 -05:00
2025-11-27 11:19:00 -05:00
2025-12-02 18:25:13 +00:00
2025-11-27 11:19:00 -05:00
2025-12-02 18:25:13 +00:00