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

resolve: allow limited inherent impl's outside of the implementee's module. #17376

Closed
wants to merge 1 commit into from

Conversation

eddyb
Copy link
Member

@eddyb eddyb commented Sep 18, 2014

Allow inherent impl's in different modules than the one the type they are implemented for is in.
Unlike regular inherent impl's, these cannot contain static methods or associated items and are not subject to UFCS.
NOTE: this requires an RFC amending RFC 57.

@alexcrichton
Copy link
Member

Isn't this reversing RFC 57? What is the motivation for this change? I also think that to reverse an RFC will require an RFC itself.

@eddyb
Copy link
Member Author

eddyb commented Sep 18, 2014

@alexcrichton Sorry for not clarifying it from the start, I edited the description, hopefully it's good now.

Reading that RFC again, the only thing I don't handle is impl X where X is imported from a different module.
As of right now, the compiler claims that in such a case the import of X conflicts with the impl X "module".
That's harder to fix properly, but the error message could be improved.

@apoelstra
Copy link
Contributor

I'd support this change. When I wrote RFC 57 I was concerned that allowing this would result in too specific a rule (and I was already fighting comments along the lines of "you shouldn't be changing the language in response to the current resolve design") for users to remember, but (a) this pattern is really useful, and (b) it is easy to provide good error messages. I'm working on the latter in #17321 --- it just needs some more unit tests and it'll be ready.

@huonw
Copy link
Member

huonw commented Sep 20, 2014

The description seems unclear still. Would an accurate summary be: impl X { ... } is allowed in other modules only if it only has methods (things mentioning self)?

(Closing pending an RFC update.)

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.

4 participants