-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detect when user tries to write Iterator
that incorrectly borrows from Self
and would need GATs
#125337
Comments
I'll give it a go. So far managed to implement something that detects this condition. |
@pacak great! I wonder if we should make the first note something like
(that can be done by creating a You'd have to check whether |
Check I made is basically if there's a problem with an anonymous lifetime and we are writing an impl Basically works right now, remaining issues are cosmetic - need to figure out the easiest way to go from ast Will try to make a pull request tomorrow or later today. |
I think there's an opportunity here for two separate improvements. The one you're making (explicit help for |
Yea, I was thinking about a generic version as well - looking up how associated datatype is defined in the trait and complaining. That's going to be later. |
Rollup merge of rust-lang#125407 - pacak:no-lending-iterators, r=pnkfelix Detect when user is trying to create a lending `Iterator` and give a custom explanation The scope for this diagnostic is to detect lending iterators specifically and it's main goal is to help beginners to understand that what they are trying to implement might not be possible for `Iterator` trait specifically. I ended up to changing the wording from originally proposed in the ticket because it might be misleading otherwise: `Data` might have a lifetime parameter but it can be unrelated to items user is planning to return. Fixes rust-lang#125337
Code
Current output
Desired output
Rationale and extra context
No response
Other cases
No response
Rust Version
Anything else?
Taken from https://users.rust-lang.org/t/lifetime-error-from-iterator-with-its-item-as-a-reference/108863
The text was updated successfully, but these errors were encountered: