Conversation
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>>
|
```
Collaborator
|
rustbot has assigned @ShoyuVanilla. Use Why was this reviewer chosen?The reviewer was selected based on:
|
3 tasks
ShoyuVanilla
approved these changes
Sep 21, 2026
|
|
||
| /// the method's receiver (`self` argument) can't be dispatched on | ||
| UndispatchableReceiver(Option<Span>), | ||
| UndispatchableReceiver(Option<(Span, Symbol)>), |
Member
There was a problem hiding this comment.
The second field Symbol is little bit confusing. It feels like a symbol for the receiver's type or self kw itself, rather than its (maybe empty) lifetime to me 😅. How would you feel about making it as a named field or add a doc comment for it?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Account for receivers with arbitrary self types to suggest idiomatic code.
Instead of