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-03-21 20:10:07 +00:00
2026-07-31 22:44:48 +03:00
2025-08-18 21:57:11 +08:00
2026-05-27 16:09:22 +02:00
2026-01-02 22:32:52 +00:00
2026-07-24 01:59:27 -04:00
2026-07-27 07:52:45 +00:00
2026-03-29 21:16:08 +01:00
2026-07-21 15:50:58 +00:00
2026-08-22 10:48:37 +02:00
2026-07-21 16:11:09 +00:00
2026-07-13 10:54:53 +02:00
2026-07-01 18:33:39 +01:00
2025-11-24 19:36:20 +08:00
2025-12-02 18:25:13 +00:00
2025-12-10 23:41:19 +00:00
2025-12-10 23:41:19 +00:00
2025-08-05 07:10:31 +05:00
2025-12-10 23:41:19 +00:00
2025-12-10 23:41:19 +00:00
2026-07-13 10:54:53 +02:00
2026-04-18 13:03:47 +08:00
2026-04-18 13:03:47 +08:00
2026-05-03 10:59:52 +02:00
2026-07-26 18:18:15 +10:00
2026-01-26 04:09:28 +05:30
2026-07-03 15:45:29 +08:00
2026-07-03 15:45:29 +08:00
2025-07-15 12:00:46 +08:00
2025-11-08 04:51:33 +01:00
2026-06-28 16:10:41 +02:00
2026-08-06 07:22:43 +05:30
2026-05-11 16:58:25 +08:00
2026-05-11 16:58:25 +08:00
2026-07-13 10:54:53 +02:00
2026-05-16 20:23:53 -04:00
2026-05-16 20:23:53 -04:00
2026-07-29 18:23:20 +00:00
2026-07-29 18:23:20 +00:00
2025-12-10 23:41:19 +00:00
2025-10-11 21:59:51 -04:00
2025-10-11 21:59:51 -04:00
2026-06-02 23:00:47 +08:00
2026-06-02 23:00:47 +08:00
2026-02-17 16:51:44 +00:00
2026-02-17 16:51:44 +00:00
2026-06-17 17:42:48 +02:00
2026-06-17 17:42:48 +02:00
2026-02-12 18:49:58 +08:00
2025-08-11 16:58:21 -05:00
2025-08-11 16:58:21 -05:00
2026-03-21 20:10:07 +00:00
2026-03-21 20:10:07 +00:00
2026-03-21 20:10:07 +00:00
2026-03-21 20:10:07 +00:00
2026-08-06 07:22:43 +05:30
2025-07-18 20:34:58 +08:00
2025-07-18 20:34:58 +08:00
2026-07-31 13:27:22 +02:00
2026-07-31 13:27:22 +02:00
2026-07-21 16:11:09 +00:00
2026-05-17 23:54:13 +02:00
2026-05-17 23:54:13 +02:00
2025-07-25 20:38:54 +05:00
2026-05-09 01:27:23 +09:00
2026-05-09 01:27:23 +09:00
2026-02-12 15:12:29 +08:00
2026-07-21 15:50:58 +00:00
2026-06-09 18:03:46 -04:00
2026-06-09 18:03:46 -04:00
2026-03-28 16:18:11 +09:00
2026-08-13 14:12:34 +02:00
2025-07-31 21:25:49 +05:00
2026-06-25 16:35:47 -04:00
2026-06-25 16:35:47 -04:00
2026-06-25 16:35:47 -04:00
2026-07-21 16:11:09 +00:00
2026-06-07 19:00:21 +02:00
2026-06-07 19:00:21 +02:00
2026-06-07 19:00:21 +02:00
2026-06-07 19:00:21 +02:00
2025-09-02 00:02:16 +00:00
2026-05-31 04:04:30 +05:30
2025-09-15 10:48:26 -07:00
2025-08-31 01:43:57 +00:00
2025-08-31 01:43:57 +00:00
2026-06-02 23:00:47 +08:00
2026-06-02 23:00:47 +08:00
2025-08-07 21:39:00 +00:00
2026-07-13 10:54:53 +02:00
2025-12-02 18:25:13 +00:00
2026-05-16 20:23:53 -04:00
2026-05-16 20:23:53 -04:00
2025-08-09 16:27:20 +05:00
2025-11-27 14:13:58 -05:00
2025-11-27 14:13:58 -05:00
2026-08-06 07:22:43 +05:30
2026-08-06 07:22:43 +05:30
2026-08-12 21:11:19 +07:00
2026-08-12 21:11:19 +07:00
2026-08-12 21:11:19 +07:00
2026-02-24 00:04:45 -05:00
2026-06-17 17:42:48 +02:00
2025-10-18 21:17:48 +02:00
2026-02-22 20:20:33 +01:00
2025-07-10 18:47:20 +05:00
2025-10-11 20:50:21 +00:00
2025-10-11 20:50:21 +00:00
2025-10-11 20:50:21 +00:00
2025-09-12 14:45:12 -04:00
2025-09-12 14:45:12 -04:00
2025-08-14 21:31:47 +08:00
2026-07-21 15:50:58 +00:00
2026-08-10 10:05:45 +02:00
2026-08-10 10:05:45 +02:00
2025-12-10 23:41:19 +00:00
2025-11-28 20:02:38 +01:00
2026-08-13 14:12:34 +02:00
2026-04-22 12:27:03 +02:00
2026-04-22 12:27:03 +02:00
2026-04-22 12:27:03 +02:00
2025-08-14 21:31:47 +08:00
2026-02-12 15:30:41 +08:00
2026-02-12 15:30:41 +08:00
2025-10-01 22:45:16 +02:00
2025-10-02 20:24:34 +02:00
2026-07-13 10:54:53 +02:00
2026-04-20 22:21:51 +08:00
2026-01-15 19:32:39 +00:00
2026-01-15 19:32:39 +00:00
2026-01-15 19:32:39 +00:00
2025-12-23 21:13:24 +09:00
2025-12-23 21:13:24 +09:00
2026-02-17 16:51:44 +00:00
2026-02-17 16:51:44 +00:00
2026-02-17 16:51:44 +00:00
2026-02-17 16:51:44 +00:00
2026-07-15 23:25:52 +05:30
2026-07-21 01:03:16 +03:00
2026-07-21 01:03:16 +03:00
2025-08-14 21:31:47 +08:00
2026-07-09 23:34:43 +02:00
2025-11-24 19:36:20 +08:00
2025-11-24 19:36:20 +08:00
2026-07-13 10:54:53 +02:00
2025-08-27 00:23:26 -04:00
2025-08-14 21:31:47 +08:00
2026-03-14 20:13:43 +00:00
2026-03-14 20:13:43 +00:00
2025-10-11 21:59:51 -04:00
2026-07-09 23:34:43 +02:00
2026-07-21 15:50:58 +00:00
2026-04-26 21:41:46 +10:00
2026-04-26 21:41:46 +10:00
2025-08-22 13:16:44 +08:00
2025-08-22 13:16:44 +08:00
2026-03-06 17:44:18 +01:00
2026-08-12 21:11:19 +07:00
2026-07-13 10:54:53 +02:00
2026-07-13 10:54:53 +02:00
2026-07-13 10:54:53 +02:00
2026-04-23 22:28:00 +02:00
2026-04-23 22:28:00 +02:00
2026-01-26 04:09:28 +05:30
2026-01-26 04:09:28 +05:30
2026-02-16 12:24:15 +00:00
2025-12-22 13:55:49 +00:00
2026-07-19 10:43:39 +08:00
2026-07-19 10:43:39 +08:00
2026-07-19 10:57:26 +08:00
2026-07-19 10:57:26 +08:00
2025-08-14 21:31:36 +08:00
2025-08-14 21:31:47 +08:00
2026-08-09 19:58:38 +00:00
2025-07-13 00:03:31 +05:00
2026-07-13 10:54:53 +02:00
2026-04-01 17:01:59 +02:00
2025-11-27 14:13:58 -05:00
2025-11-27 14:13:58 -05:00
2025-08-16 16:15:58 +02:00
2025-08-16 16:15:58 +02:00
2025-08-16 16:15:58 +02:00
2025-11-27 14:13:58 -05: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-11-27 11:19:00 -05:00
2025-11-27 11:19:00 -05:00
2025-09-26 15:33:48 +02:00
2025-09-26 15:33:48 +02:00
2025-08-18 21:57:11 +08:00
2025-08-18 21:57:11 +08:00
2026-08-23 07:07:46 +05:30
2026-08-23 07:07:46 +05:30
2025-12-10 23:41:19 +00:00
2025-09-24 21:31:23 +00:00
2025-09-24 21:31:23 +00:00
2025-07-31 13:55:59 +08:00
2025-07-05 03:46:08 +05:00
2025-07-05 03:46:08 +05:00
2025-07-05 03:46:08 +05:00
2025-12-23 21:13:24 +09:00
2025-12-23 21:13:24 +09:00
2025-07-23 13:48:04 +02:00
2026-03-26 11:42:38 +08:00
2026-03-26 11:42:38 +08:00
2026-03-26 11:42:38 +08:00
2026-07-21 01:03:16 +03:00
2026-07-21 01:03:16 +03:00
2025-12-02 18:25:13 +00:00
2025-12-02 18:25:13 +00:00
2026-07-22 11:42:09 +02:00
2026-07-22 11:42:09 +02:00
2025-11-10 14:33:56 +01:00
2026-07-30 10:28:14 +08:00
2026-07-30 10:28:14 +08:00
2025-11-27 11:19:00 -05:00
2025-12-02 18:25:13 +00:00
2026-04-10 21:45:26 +08:00
2026-04-10 21:45:26 +08:00