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
Merged

Conversation

nrc
Copy link
Member

@nrc nrc commented Dec 14, 2014

Closes #310

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

@nrc
Copy link
Member Author

nrc commented Dec 14, 2014

rendered

@nrc
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
Copy link
Member

aturon commented Dec 14, 2014

Nice! I've often wanted this.

@sinistersnare
Copy link

+1 simple and useful for macros

@pythonesque
Copy link
Contributor

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

@nikomatsakis
Copy link
Contributor

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
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
Copy link
Contributor

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
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.

@nrc nrc merged commit b74894e into rust-lang:master Dec 19, 2014
@Stebalien Stebalien mentioned this pull request Aug 19, 2016
@Centril Centril added A-traits Trait system related proposals & ideas A-impls Implementations related proposals & ideas A-resolve Proposals relating to name resolution. A-syntax Syntax related proposals & ideas labels Nov 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-impls Implementations related proposals & ideas A-resolve Proposals relating to name resolution. A-syntax Syntax related proposals & ideas A-traits Trait system related proposals & ideas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow using Self in impls
6 participants