Skip to content
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

feat: error if generic type parameter in impl is not mentioned in self type #6388

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

asterite
Copy link
Collaborator

Description

Problem

Resolves #5855

Summary

I decided to do this check separately... that is, another way could have been to keep track of which generics we saw while we solve self_type, but I think that would lead to code that's harder to understand. I was also able to use the visitor pattern to quickly find the mentioned generic types (I had to update Visitor so that it correctly traverses unresolved type expressions).

Additional Context

Some questions:

  1. We only produce this error for impl... do we also want to do it for trait impls? If yes, in this PR or a separate one?
  2. Should we use the same error message as Rust? I find it a bit hard to understand, although it kind of makes sense. Let me know!

Documentation

Check one:

  • No documentation needed.
  • Documentation included in this PR.
  • [For Experimental Features] Documentation to be submitted in a separate PR.

PR Checklist

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt on default settings.

@asterite asterite marked this pull request as draft October 29, 2024 15:53
@asterite
Copy link
Collaborator Author

Marked as draft because of #5855 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Concrete types do not throw an error if an impl is defined with generics
1 participant