Files
rust/tests/ui/suggestions
Zalathar b420a664dd Rollup merge of #163049 - estebank:dyn-compat-receiver, r=ShoyuVanilla
Tweak dyn compatibility error when pointing at receiver

Account for receivers with arbitrary self types to suggest idiomatic code.

```
error[E0038]: the trait `Fetcher` is not dyn compatible
  --> $DIR/undispatchable-receiver-and-wc-references-Self.rs:19:21
   |
LL | fn fetcher() -> Box<dyn Fetcher> {
   |                     ^^^^^^^^^^^ `Fetcher` is not dyn compatible
   |
note: for a trait to be dyn compatible it needs to allow building a vtable
      for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
  --> $DIR/undispatchable-receiver-and-wc-references-Self.rs:11:16
   |
LL | pub trait Fetcher: Send + Sync {
   |           ------- this trait is not dyn compatible...
LL |     fn get<'a>(self: &'a Box<Self>) -> Pin<Box<dyn Future<Output = Vec<u8>> + 'a>>
   |                ^^^^^^^^^^^^^^^^^^^ ...because method `get`'s `self` parameter cannot be dispatched on
help: consider changing method `get`'s `self` parameter to be `&self`
   |
LL -     fn get<'a>(self: &'a Box<Self>) -> Pin<Box<dyn Future<Output = Vec<u8>> + 'a>>
LL +     fn get<'a>(&'a self) -> Pin<Box<dyn Future<Output = Vec<u8>> + 'a>>
   |
```

Instead of

```
help: consider changing method `get`'s `self` parameter to be `&self`
   |
LL -     fn get<'a>(self: &'a Box<Self>) -> Pin<Box<dyn Future<Output = Vec<u8>> + 'a>>
LL +     fn get<'a>(self: &Self) -> Pin<Box<dyn Future<Output = Vec<u8>> + 'a>>
   |
```
2026-09-22 12:01:39 +10:00
..
…
2026-09-20 19:17:59 +00:00