Jonathan Brouwer
91eefd7a9e
Rollup merge of #156226 - shivendra02467:fix-diagnostic-155880, r=lcnr
...
diagnostics: point to coroutine body on higher-ranked auto trait errors
Fixes rust-lang/rust#155880
When encountering a higher-ranked auto trait bound error involving a coroutine or async function,the trait solver previously used the span of the outermost cause (eg. `spawn(...)` or `is_send(...)`).
This PR modifies the `TraitPlaceholderMismatch` formatting logic to walk down the `ObligationCauseCode` chain.If the obligation originates from a `ty::Coroutine` or `ty::CoroutineWitness`, it extracts that specific span, providing a much more accurate underline for the user.
#### Before:
```text
error: implementation of `Send` is not general enough
--> src/main.rs:25:5
|
25 | is_send(outer())
| ^^^^^^^^^^^^^^^^ implementation of `Send` is not general enough
```
#### After:
```text
error: implementation of `Send` is not general enough
--> src/main.rs:13:74
|
13 | async fn inner<'a, T: Trait + 'a>(_: T, x: T::Assoc<'a>) -> T::Assoc<'a> {
| __________________________________________________________________________^
14 | | std::future::ready(x).await
15 | | }
| |_^ implementation of `Send` is not general enough
```
2026-06-16 22:11:06 +02:00
..
2026-06-15 16:16:07 -04:00
2026-06-09 11:24:07 +00:00
2026-05-28 10:15:29 +08:00
2025-12-10 15:15:56 +01:00
2026-03-21 20:10:07 +00:00
2026-06-04 08:10:27 +00:00
2026-02-06 16:14:09 +03:00
2026-05-09 17:50:35 +12:00
2025-08-20 11:10:38 +02:00
2026-06-15 23:13:37 +05:30
2024-12-14 03:54:31 +01:00
2025-12-09 16:46:33 +00:00
2024-05-07 16:56:54 -04:00
2025-06-10 08:41:23 +00:00
2025-08-20 11:04:38 +02:00
2024-12-13 00:04:56 +00:00
2024-12-13 00:04:56 +00:00
2024-12-13 00:04:56 +00:00
2024-12-13 00:04:56 +00:00
2024-11-02 03:08:04 +00:00
2024-10-29 16:26:57 +00:00
2025-04-15 21:48:36 +02:00
2025-04-15 21:48:36 +02:00
2025-04-15 21:48:36 +02:00
2024-05-21 19:05:37 -07:00
2024-10-29 16:26:57 +00:00
2024-04-24 08:05:29 +00:00
2026-04-20 18:42:24 +09:00
2026-04-20 18:42:24 +09:00
2025-06-13 01:16:36 +02:00
2025-06-13 01:16:36 +02:00
2024-05-21 19:05:37 -07:00
2026-06-15 23:13:37 +05:30
2026-06-15 23:13:37 +05:30
2024-12-13 00:04:56 +00:00
2025-01-16 21:34:40 +01:00
2024-11-02 03:08:04 +00:00
2026-01-13 01:16:58 +00:00
2025-06-06 20:12:11 +00:00
2025-07-23 13:48:04 +02:00
2025-12-22 13:55:49 +00:00
2025-08-31 10:55:14 +08:00
2025-01-16 21:34:40 +01:00
2025-08-08 18:53:18 +00:00
2025-08-08 18:53:18 +00:00
2025-08-08 18:53:18 +00:00
2025-08-08 18:53:18 +00:00
2026-03-20 21:09:32 +01:00
2025-06-06 20:12:11 +00:00
2025-04-08 23:06:31 +03:00
2024-10-29 16:26:57 +00:00
2025-07-15 16:02:26 +00:00
2025-07-15 16:02:26 +00:00
2024-11-22 11:12:15 -08:00
2025-04-03 21:41:58 +00:00
2025-04-08 23:06:31 +03:00
2024-10-29 16:26:57 +00:00
2024-10-12 06:14:46 -04:00
2024-10-12 06:14:46 -04:00
2025-05-26 14:59:48 +02:00
2024-12-05 14:14:17 -08:00
2024-12-05 14:14:17 -08:00
2024-12-05 14:14:17 -08:00
2025-05-17 01:30:07 +09:00
2026-03-21 16:42:02 +01:00
2025-07-15 16:02:26 +00:00
2025-07-15 16:02:26 +00:00
2025-10-15 09:35:05 +01:00
2025-10-15 09:35:05 +01:00
2025-07-15 16:02:26 +00:00
2025-07-15 16:02:26 +00:00
2025-07-15 16:02:26 +00:00
2025-07-15 16:02:26 +00:00
2025-07-31 17:38:28 +00:00
2025-07-15 16:02:26 +00:00
2025-10-15 09:35:05 +01:00
2025-07-15 16:02:26 +00:00
2025-07-15 16:02:26 +00:00
2025-07-15 16:02:26 +00:00
2025-07-15 16:02:26 +00:00
2025-07-15 16:02:26 +00:00
2025-07-15 16:02:26 +00:00
2025-07-15 16:02:26 +00:00
2026-06-15 23:13:37 +05:30
2026-06-15 23:13:37 +05:30
2025-07-15 16:02:26 +00:00
2025-07-15 16:02:26 +00:00
2025-07-15 16:02:26 +00:00
2025-07-15 16:02:26 +00:00
2025-07-15 16:02:26 +00:00
2025-07-15 16:02:26 +00:00
2025-10-15 09:35:05 +01:00
2025-07-15 16:02:26 +00:00
2025-07-15 16:02:26 +00:00
2025-07-15 16:02:26 +00:00
2025-07-15 16:02:26 +00:00
2025-07-15 16:02:26 +00:00
2025-07-15 16:02:26 +00:00
2025-07-15 16:02:26 +00:00
2025-10-03 10:32:23 -04:00
2025-10-03 10:32:23 -04:00
2025-07-01 16:26:57 +05:00
2025-07-01 16:26:57 +05:00
2025-06-23 21:30:56 +03:00
2025-06-23 21:30:56 +03:00
2025-02-10 20:21:39 +00:00
2025-01-22 09:20:57 -08:00
2025-12-09 16:46:33 +00:00
2025-04-10 09:56:37 +02:00
2026-01-13 01:16:58 +00:00
2026-01-13 01:16:58 +00:00
2024-07-04 02:02:21 +00:00
2025-08-22 17:55:15 +00:00
2025-08-22 17:55:15 +00:00
2025-12-09 16:46:33 +00:00
2025-07-29 10:32:15 +02:00
2025-05-26 14:59:48 +02:00
2025-05-26 14:59:48 +02:00
2025-05-26 14:59:48 +02:00
2024-12-13 15:40:37 +00:00
2024-10-29 16:26:57 +00:00
2024-10-29 16:26:57 +00:00
2026-02-09 15:09:43 +08:00
2026-02-09 15:09:43 +08:00
2026-02-09 15:09:43 +08:00
2026-02-09 15:09:43 +08:00
2025-04-07 19:13:31 +03:00
2025-07-29 10:32:15 +02:00
2025-12-02 18:25:13 +00:00
2024-12-13 00:04:56 +00:00
2026-05-11 23:01:08 -04:00
2025-08-20 11:10:38 +02:00
2025-08-20 11:10:38 +02:00
2026-01-13 01:16:58 +00:00
2025-07-31 17:31:51 +00:00
2025-02-02 01:00:33 +00:00
2025-02-02 01:00:33 +00:00
2025-06-06 20:12:11 +00:00
2026-01-21 05:04:42 +03:00
2025-10-11 21:59:51 -04:00
2025-10-11 21:59:51 -04:00
2026-02-16 12:24:15 +00:00
2025-12-22 13:55:49 +00:00
2026-03-17 17:39:59 +08:00
2024-06-04 14:19:42 -03:00
2024-06-04 14:19:42 -03:00
2026-05-15 07:33:29 -04:00
2024-12-13 00:04:56 +00:00
2025-04-03 21:41:58 +00:00
2024-04-24 08:05:29 +00:00
2025-03-11 12:05:02 +00:00
2025-12-09 16:46:33 +00:00
2024-10-29 16:26:57 +00:00
2024-05-28 20:05:01 +00:00
2024-05-28 20:48:35 +00:00
2025-04-12 20:54:08 +00:00
2025-08-13 14:10:19 +02:00
2025-08-10 02:21:48 +00:00
2024-12-13 00:04:56 +00:00
2024-12-13 00:04:56 +00:00
2024-12-13 00:04:56 +00:00
2025-04-10 23:48:57 +03:00
2025-04-10 23:48:57 +03:00
2025-05-26 14:59:48 +02:00
2025-05-26 14:59:48 +02:00
2025-05-26 14:59:48 +02:00
2025-05-26 14:59:48 +02:00
2024-10-12 06:14:45 -04:00
2026-01-13 01:16:58 +00:00
2024-12-13 00:04:56 +00:00
2025-02-20 18:15:39 +00:00
2025-02-11 22:59:57 +00:00
2025-12-02 18:25:13 +00:00
2025-06-06 20:12:11 +00:00
2024-07-31 12:24:26 -04:00
2026-01-26 17:34:31 +00:00
2026-04-20 16:46:57 +06:00
2025-06-13 01:16:36 +02:00
2025-06-13 01:16:36 +02:00