-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Type parameters can be constrained only as an associated type #26262
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
Comments
Heh, I was just telling @aturon in IRC the other day that this case was broken. I agree, the current logic is too simplistic (it's also something I've been writing up in this RFC I keep talking about...). Basically, it currently considers all input/type parameters which appear as constrianed, but it ought to stop at projections. I made this gist, which is a similar example: https://gist.github.com/0c562768aeb9412269ce |
To be clear, I don't think that fixing this issue requires an RFC (it's just a bug, I think). I just meant that I was writing up various text that referenced the notion of "constrained type parameters" and tried to give a definition, which is how I realized this problem. |
Fixes #26262 Because this rejects code that previously compiled, this is a [breaking-change] r? @nikomatsakis
You can create an inherent impl where the impl substs are not constrained by the impl signature. If the parameters are constrained by the method signature, you can even get code that usefully runs (otherwise you get "can't resolve" errors):
Note that you need to use UFCS notation to avoid #25679 (which is an issue with method lookup).
RFC447 is silent with regards to this issue, but this allows you to create an impl that is not resolvable by its trait-ref.
The text was updated successfully, but these errors were encountered: