Skip to content

Allow using Self in impls #12600

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

Closed
emberian opened this issue Feb 27, 2014 · 11 comments
Closed

Allow using Self in impls #12600

emberian opened this issue Feb 27, 2014 · 11 comments
Labels
A-type-system Area: Type system

Comments

@emberian
Copy link
Member

This is convenient because it allows you to copy-paste trait declarations.

@emberian
Copy link
Member Author

Fully back-compat, certainly not a 1.0 priority.

@emberian
Copy link
Member Author

This would essentially involve adding a "hidden" type parameter in every impl.

@emberian
Copy link
Member Author

cc @nikomatsakis @pnkfelix

@eddyb
Copy link
Member

eddyb commented Feb 27, 2014

Is there really a need for another magic type parameter?
I would think astconv can resolve Self in impls to the actual type, and nothing needs to see ty_self.

@emberian
Copy link
Member Author

Sure that could work

On Thu, Feb 27, 2014 at 3:30 PM, Eduard Burtescu
[email protected]:

Is there really a need for another magic type parameter?
I would think astconv can resolve Self in impls to the actual type, and
nothing needs to see ty_self.


Reply to this email directly or view it on GitHubhttps://github.com//issues/12600#issuecomment-36287579
.

@nikomatsakis
Copy link
Contributor

As @eddyb said, I think this is basically syntactic sugar, and I have no particular problem with it. I think the main reason not to do it (and the reason we didn't before) is so as not to obscure the role of Self as a type parameter and so on, which isn't applicable to impls, but I don't know that it really matters.

@pnkfelix
Copy link
Member

+1 to all of what Niko said. In particular, I do like the sugar being suggested here. But at the same time, I noticed that in a recent rust-dev post, @anasazi used the notation Self<T> to apply a hypothetical higher-kinded Self : * -> * to a type parameter. If we wanted to leave such options open for the future, it may constrains how we use/abuse Self now. (But as niko said, the role of Self in trait definitions may not be relevant to its role in impls.)

@flaper87
Copy link
Contributor

This should probably go through the new RFC process. @cmr are you going to submit one? Can we close this issue?

@emberian
Copy link
Member Author

I suppose I can write one later this week.

@nikomatsakis
Copy link
Contributor

On Mon, Mar 24, 2014 at 04:10:00PM -0700, Flavio Percoco Premoli wrote:

This should probably go through the new RFC process. @cmr are you going to submit an one? Can we close this issue?

Agreed

@rust-highfive
Copy link
Contributor

This issue has been moved to the RFCs repo: rust-lang/rfcs#310

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-type-system Area: Type system
Projects
None yet
Development

No branches or pull requests

6 participants