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

Allow the `Self` type to be used in impls. #522

Merged
merged 1 commit into from Dec 19, 2014

Conversation

Projects
None yet
6 participants
@nrc
Copy link
Member

nrc commented Dec 14, 2014

Closes #310

See also some discussion in discuss and discussion in the Rust issue tracker.

@nrc

This comment has been minimized.

Copy link
Member Author

nrc commented Dec 14, 2014

@nrc

This comment has been minimized.

Copy link
Member Author

nrc commented Dec 14, 2014

And an implementation to show how easy it is - less than 100 lines of code changed (including the test) and no changes outside of libsyntax.

@nrc nrc self-assigned this Dec 14, 2014

@aturon

This comment has been minimized.

Copy link
Member

aturon commented Dec 14, 2014

Nice! I've often wanted this.

@sinistersnare

This comment has been minimized.

Copy link

sinistersnare commented Dec 14, 2014

+1 simple and useful for macros

@pythonesque

This comment has been minimized.

Copy link
Contributor

pythonesque commented Dec 14, 2014

+1, always seemed like an oversight that you couldn't do this.

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Dec 15, 2014

It'd certainly be convenient and I've kind of expected we'll add it sooner or later. As far as the implementation goes, I would have expected to handle it in astconv, but I guess doing it in libsyntax is ok too and avoids needing to modify resolve, though you'll get some surprising errors (e.g., if you have a resolve error in the self type on the impl).

@nrc

This comment has been minimized.

Copy link
Member Author

nrc commented Dec 16, 2014

I realised today that if we want to accommodate Self::T paths to associated types we would need to either do this in resolve or add the facility to write a path to an associated type via a concrete type (which I think we want to add, but not any time soon). Given the latter is coming, I would prefer to land this and avoid doing the expansion in paths with more than one segment.

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Dec 16, 2014

On Mon, Dec 15, 2014 at 05:27:54PM -0800, Nick Cameron wrote:

add the facility to write a path to an associated type via a
concrete type (which I think we want to add, but not any time soon)

I expect this to fall out of the refactoring for AT we've been
discussing.

@nrc

This comment has been minimized.

Copy link
Member Author

nrc commented Dec 19, 2014

This RFC has been accepted, r=nikomatsakis

Tracking issue

Small, easy to implement, and widely desired. This will NOT block 1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.