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

Fix RFC 2302 to support unit structs, fn pointers, and use value namespace instead for exprs #5

Merged
merged 3 commits into from
Jun 21, 2018

Conversation

Centril
Copy link
Owner

@Centril Centril commented Jun 21, 2018

Changes:

  • unit structs are now supported,
  • Self is permitted as a function pointer,
  • things are defined in expression contexts by adding to the value namespace,
  • consequence changes elsewhere due to the above points,
  • cleared the unresolved questions,

…nit structs, change reference explanation, etc. + consequence changes.
Rust (now) allows usage of `Self(v0, v1, ..)` inside inherent
and trait `impl`s of tuple structs, either when mentioning the
tuple struct directly in the `impl` header, or via a type alias.
Rust (now) allows usage of `Self(v0, v1, ..)` inside inherent and

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find this now confusing. Does it mean before or after the RFC?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After the RFC :)

Rust (now) allows usage of `Self(v0, v1, ..)` inside inherent and
trait `impl`s of tuple structs, either when mentioning the tuple struct
directly in the `impl` header, or via a type alias.
This usage is permitted both in expression and pattern contexts.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I would prefer if we can rewrite this Reference-Level Explanation to be a little more "implementation focused". Right now it reads a bit to me like restating the premise of the RFC. For example, I think I would prefer to say:

When entering one of the following contexts, the value namespace is extended with Self which maps to the tuple constructor fn (or constant, in the case of a unit struct):

  • inherent impls where the Self type is a tuple or unit struct
  • trait impls where the Self type is a tuple or unit struct

directly in the `impl` header, or via a type alias.
This usage is permitted both in expression and pattern contexts.

Furthermore, `Self`, when referring to a tuple struct, can be legally coerced

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this basically follows from the description I gave before; it could be rewritten to say "This should allow Self to be legally coerced..."

@Centril Centril merged commit 2a16873 into rfc/tuple-struct-self-ctor Jun 21, 2018
@Centril Centril deleted the patch-1/tuple-struct-self-ctor branch June 21, 2018 17:54
Centril pushed a commit that referenced this pull request May 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants