Allow using Self in impls

76062c9
Opened by emberian at 2014-09-24 05:00:38

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

  1. Fully back-compat, certainly not a 1.0 priority.

    emberian at 2014-02-27 15:53:14

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

    emberian at 2014-02-27 15:54:30

  3. cc @nikomatsakis @pnkfelix

    emberian at 2014-02-27 15:54:44

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

    Eduard-Mihai Burtescu at 2014-02-27 20:30:16

  5. Sure that could work

    On Thu, Feb 27, 2014 at 3:30 PM, Eduard Burtescu notifications@github.comwrote:

    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/mozilla/rust/issues/12600#issuecomment-36287579 .

    emberian at 2014-02-27 20:48:53

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

    Niko Matsakis at 2014-02-28 10:38:39

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

    Felix S Klock II at 2014-02-28 11:44:33

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

    Flavio Percoco at 2014-03-24 23:09:58

  9. I suppose I can write one later this week.

    emberian at 2014-03-24 23:48:36

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

    Niko Matsakis at 2014-03-26 10:14:49

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

    Rust highfive robot at 2014-09-24 05:00:37