Files
rust/tests/ui/error-codes
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
..
2025-02-21 00:41:17 +00:00
2023-04-03 15:59:21 +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
2024-04-14 09:42:53 -04:00
2023-01-30 20:12:19 +00:00
2024-09-09 19:39:43 -07:00
2024-09-09 19:39:43 -07:00
2024-09-09 19:39:43 -07:00
2024-09-09 19:39:43 -07:00
2024-09-09 19:39:43 -07:00
2024-09-09 19:39:43 -07: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
2024-07-22 22:04:49 +00:00
2024-06-21 19:00:18 -04:00
2024-01-05 09:30:27 +00:00
2024-01-05 10:00:59 +00:00
2023-12-15 16:12:27 +00:00
2025-06-13 01:16:36 +02:00
2025-06-13 01:16:36 +02:00
2025-08-11 16:58:21 -05:00
2023-03-08 00:00:18 +00:00
2024-01-11 09:03:26 +00:00
2024-05-20 11:13:10 -04:00
2023-12-15 16:12:27 +00:00
2023-10-20 21:10:38 +00:00
2025-08-27 20:25:18 +02:00
2025-08-27 20:25:18 +02:00
2024-06-21 19:00:18 -04:00
2025-02-24 14:31:19 +01:00
2025-06-06 20:52:34 +00:00
2023-11-16 17:00:23 +00:00
2025-02-25 16:56:04 +00:00
2024-11-29 00:45:14 +01:00
2025-06-06 20:52:34 +00:00
2024-03-20 17:29:58 +00:00
2025-05-28 15:14:34 +01:00
2025-05-28 15:14:34 +01:00
2025-08-14 18:18:42 +02:00
2025-09-18 09:16:58 -04: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