Matthias Krüger
15b7792a65
Rollup merge of #146593 - Jules-Bertholet:restrict-e0719, r=BoxyUwU
Allow specifying multiple bounds for same associated item, except in trait objects
Supersedes https://github.com/rust-lang/rust/pull/143146, fixes https://github.com/rust-lang/rust/issues/143143.
This PR proposes to stop enforcing E0719 in all contexts other than trait object types.
E0719 forbids constraining the same associated item twice within the same angle-bracket delimited associated item bound list (the `…` inside `T: Trait<…>`). For example, the following are forbidden:
| Forbidden | Working alternative |
|--------------------------------------------|--------------------------------------------------------------------|
| `T: Trait<Gat<u32> = u32, Gat<u64> = u64>` | `T: Trait<Gat<u32> = u32> + Trait<Gat<u64> = u64>` |
| `T: Iterator<Item = u32, Item = i32>` | `T: Iterator<Item = u32> + Iterator<Item = i32>` (trivially false) |
| `T: Iterator<Item = u32, Item = u32>` | `T: Iterator<Item = u32>` |
| `T: Iterator<Item: Send, Item: Sync>` | `T: Iterator<Item: Send + Sync>` |
| `T: Trait<ASSOC = 3, ASSOC = 4>` | `T: Trait<ASSOC = 3> + Trait<ASSOC = 4>` (trivially false) |
| `T: Trait<ASSOC = 3, ASSOC = 3>` | `T: Trait<ASSOC = 3>` |
With this PR, all those previously forbidden examples would start working, as well as their APIT and RPIT equivalents.
Types like `dyn Iterator<Item = u32, Item = u32>` will continue to be rejected, however. See https://github.com/rust-lang/rust/pull/143146#issuecomment-3274421752 for the reason why.
```@rustbot``` label T-lang T-types needs-fcp
2025-10-01 18:42:34 +02:00
..
2024-11-23 08:57:25 -07:00
2024-12-23 22:15:32 +00:00
2024-12-23 22:15:32 +00:00
2024-12-23 22:15:32 +00:00
2024-12-23 22:15:32 +00:00
2024-12-23 22:15:32 +00:00
2024-12-23 22:15:32 +00:00
2025-06-27 17:03:48 +02:00
2025-06-27 17:03:48 +02:00
2025-02-21 00:41:17 +00:00
2025-02-10 20:21:39 +00:00
2025-05-23 12:20:35 +00:00
2025-05-23 12:20:35 +00:00
2025-02-10 20:21:39 +00:00
2025-06-13 18:10:06 +02:00
2025-02-10 20:21:39 +00:00
2025-02-21 00:41:17 +00:00
2025-02-21 00:41:17 +00:00
2025-02-21 00:41:17 +00:00
2025-04-08 23:06:31 +03:00
2025-06-02 15:37:15 +00:00
2025-06-07 13:42:30 +02:00
2024-10-19 09:44:37 +00:00
2024-10-19 09:44:37 +00:00
2025-02-24 14:31:19 +01:00
2025-04-06 21:41:47 +02:00
2025-04-06 21:41:47 +02:00
2025-02-24 07:53:59 +01:00
2025-02-24 07:53:59 +01:00
2025-04-30 10:44:24 +03:00
2025-04-30 10:44:24 +03:00
2025-07-09 17:07:04 +00:00
2025-09-29 03:28:52 +00:00
2025-03-12 16:56:26 +00:00
2025-04-13 21:48:53 +03:00
2025-04-13 21:48:53 +03:00
2024-12-27 19:58:16 +11:00
2025-06-13 01:16:36 +02:00
2025-06-13 01:16:36 +02:00
2025-03-14 19:50:03 +00:00
2025-04-08 23:06:31 +03:00
2025-05-07 18:12:54 +00:00
2025-05-07 18:12:54 +00:00
2025-08-11 16:58:21 -05:00
2025-02-10 20:21:39 +00:00
2025-02-10 20:21:39 +00:00
2025-05-06 17:04:03 +02:00
2025-01-15 01:26:24 +00:00
2025-01-06 17:58:30 +00:00
2025-02-21 00:54:01 +00:00
2025-02-21 00:54:01 +00:00
2025-04-08 23:06:31 +03:00
2025-06-24 18:59:42 +00:00
2025-04-08 23:06:31 +03:00
2025-08-07 21:18:00 +00:00
2025-08-07 21:18:00 +00:00
2024-10-29 16:26:57 +00:00
2024-10-29 16:26:57 +00:00
2025-02-10 20:21:39 +00:00
2025-02-24 07:53:59 +01:00
2025-02-24 07:53:59 +01:00
2025-02-24 19:34:54 +00:00
2025-02-24 19:34:54 +00:00
2025-03-15 10:52:07 -06:00
2025-03-15 10:52:07 -06:00
2025-01-24 04:07:10 +00:00
2025-07-31 13:55:59 +08:00
2025-07-03 23:47:19 +08:00
2025-04-30 10:44:24 +03:00
2025-04-30 10:44:24 +03:00
2025-01-24 01:19:50 +00:00
2025-02-10 20:21:39 +00:00
2025-01-18 20:33:15 +00:00
2024-12-23 20:25:41 +00:00
2024-12-23 20:25:41 +00:00
2025-08-27 20:25:18 +02:00
2025-08-27 20:25:18 +02:00
2025-02-03 19:43:24 +00:00
2025-03-04 00:21:02 +08:00
2025-02-03 19:38:52 +00:00
2025-03-04 00:21:02 +08:00
2025-06-27 17:03:48 +02:00
2025-02-27 12:22:59 +01:00
2025-02-27 12:22:59 +01:00
2025-04-08 23:06:31 +03:00
2025-02-10 20:21:39 +00:00
2025-02-03 19:38:52 +00:00
2025-03-04 00:21:02 +08:00
2025-06-17 23:22:51 +02:00
2025-06-17 23:22:51 +02:00
2025-06-17 23:22:51 +02:00
2025-08-11 17:02:32 +00:00
2025-08-11 16:00:49 +00:00
2025-02-24 14:31:19 +01:00
2025-03-06 12:53:35 +01:00
2025-04-08 23:06:31 +03:00
2025-04-13 21:48:53 +03:00
2025-06-06 20:52:34 +00:00
2025-04-08 23:06:31 +03:00
2025-02-25 16:56:04 +00:00
2024-11-29 00:45:14 +01:00
2024-11-29 20:49:06 +01:00
2025-06-06 20:52:34 +00:00
2025-07-01 19:58:27 +08:00
2025-02-10 20:21:39 +00:00
2025-06-02 11:02:50 +02:00
2025-06-02 11:02:50 +02:00
2025-05-28 15:14:34 +01:00
2025-05-28 15:14:34 +01:00
2025-06-03 10:13:33 +02:00
2025-06-03 10:13:33 +02:00
2025-08-14 18:18:42 +02:00
2025-09-18 09:16:58 -04:00
2025-09-18 09:16:58 -04:00
2025-02-10 20:21:39 +00:00
2025-02-28 20:43:15 +00:00
2025-02-24 14:31:19 +01:00
2025-02-24 14:31:19 +01:00
2025-07-13 13:50:01 +00:00
2025-08-07 21:39:00 +00:00