You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Tracking issue for RFC 2300, "Self in type definitions" #49303
B-RFC-approvedBlocker: Approved by a merged RFC.B-RFC-implementedBlocker: Approved by a merged RFC and implemented but not stabilized.B-unstableBlocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCT-langRelevant to the language teamdisposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.
This syntax creates ambiguity if we ever permit types to be declared directly within impls (for example, as the value for an associated type). Do we ever want to support that, and if so, how should we resolve the ambiguity? A possible, interpretation and way to solve the ambiguity consistently is discussed in the rationale.
Feature name: #![feature(self_in_typedefs)]
Version target: 1.32 (2019-01-18)
Originally accepted in rust-lang/rfcs#2300, I propose that we stabilize self_in_typedefs.
This has been in nightly since 2018-08-19 which is ~12 weeks ago.
The proposed change is not a blocker for anyone but it is a nice quality of life feature in some cases.
See the motivation of the RFC for reasons why we would want to do this.
Self becomes a legal type in struct, enum, and union type definitions and refers to the type being defined. Self is permitted both in fields and in where clauses; For example:
enumList<T>where// In where clauses, both on the side of types being constrained and on the bounds side.Self:PartialOrd<Self>{Nil,Cons(T,Box<Self>)// In fields. The usual rules re. infinite types apply.}
What is not being stabilized
Mentions of Self in trait, andtype aliases, and existential types are not being stabilized here.
Divergences from RFC
None
Unresolved questions
There is currently one unresolved question, it reads as:
This syntax creates ambiguity if we ever permit types to be declared directly within impls (for example, as the value for an associated type). Do we ever want to support that, and if so, how should we resolve the ambiguity? A possible, interpretation and way to solve the ambiguity consistently is discussed in the rationale.
At this point I believe that the discussion in the RFC is sufficient and that there is no problem should we ever want to pursue the extension aforementioned.
Thus, I suggest that we resolve the question as a footnote that may have some value in the future but does not impact us now.
Once a majority of reviewers approve (and none object), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!
See this document for info about what commands tagged team members can give me.
An issue is filed in rust-lang/reference#473 for the documentation.
As such, there's nothing more left to do in this issue and therefore we can close it.
B-RFC-approvedBlocker: Approved by a merged RFC.B-RFC-implementedBlocker: Approved by a merged RFC and implemented but not stabilized.B-unstableBlocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCT-langRelevant to the language teamdisposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.
Activity
csmoe commentedon Mar 26, 2018
I have tried to solve this, but the dfficulty of this is beyond my current rust-experience so I'd appreciate any mentorship.
Centril commentedon Aug 2, 2018
re-cc @rust-lang/compiler - could we get some mentoring instructions perhaps per @csmoe's request?
alexreg commentedon Aug 14, 2018
Currently working on this...
Auto merge of #53324 - alexreg:self_in_typedefs, r=eddyb
alexreg commentedon Aug 18, 2018
You can tick off "implemented" now. :-)
Centril commentedon Nov 11, 2018
@rfcbot merge
Stabilization report & proposal
Feature name:
#![feature(self_in_typedefs)]Version target: 1.32 (2019-01-18)
Originally accepted in rust-lang/rfcs#2300, I propose that we stabilize
self_in_typedefs.This has been in nightly since 2018-08-19 which is ~12 weeks ago.
The proposed change is not a blocker for anyone but it is a nice quality of life feature in some cases.
See the motivation of the RFC for reasons why we would want to do this.
What is being stabilized
Relevant artefacts:
The changes are:
Selfbecomes a legal type instruct,enum, anduniontype definitions and refers to the type being defined.Selfis permitted both in fields and inwhereclauses; For example:What is not being stabilized
Mentions of
Selfintrait, andtypealiases, andexistential types are not being stabilized here.Divergences from RFC
None
Unresolved questions
There is currently one unresolved question, it reads as:
At this point I believe that the discussion in the RFC is sufficient and that there is no problem should we ever want to pursue the extension aforementioned.
Thus, I suggest that we resolve the question as a footnote that may have some value in the future but does not impact us now.
rfcbot commentedon Nov 11, 2018
Team member @Centril has proposed to merge this. The next step is review by the rest of the tagged teams:
No concerns currently listed.
Once a majority of reviewers approve (and none object), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!
See this document for info about what commands tagged team members can give me.
8 remaining items
Rollup merge of rust-lang#56366 - alexreg:stabilise-self_in_typedefs,…
Rollup merge of rust-lang#56366 - alexreg:stabilise-self_in_typedefs,…
Rollup merge of rust-lang#56366 - alexreg:stabilise-self_in_typedefs,…
rfcbot commentedon Dec 10, 2018
The final comment period, with a disposition to merge, as per the review above, is now complete.
Centril commentedon Dec 10, 2018
An issue is filed in rust-lang/reference#473 for the documentation.
As such, there's nothing more left to do in this issue and therefore we can close it.
alexreg commentedon Dec 10, 2018
@Centril I believe the reference is already up-to-date.