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

Do not expose unnamed projected types #268

Merged
merged 1 commit into from
Sep 7, 2020
Merged

Do not expose unnamed projected types #268

merged 1 commit into from
Sep 7, 2020

Conversation

taiki-e
Copy link
Owner

@taiki-e taiki-e commented Sep 7, 2020

Defines projected types in inside const _: () = {} when the users don't name it;

cc #264

@taiki-e taiki-e added A-pin-projection Area: #[pin_project] breaking-change This proposes a breaking change relnotes labels Sep 7, 2020
@taiki-e taiki-e added this to the v1.0 milestone Sep 7, 2020
@taiki-e
Copy link
Owner Author

taiki-e commented Sep 7, 2020

This is not actually a breaking change as the generated unnamed projected types aren't public API.

@taiki-e taiki-e removed breaking-change This proposes a breaking change relnotes labels Sep 7, 2020
Comment on lines 43 to +47
const _: () = {
#[allow(dead_code)]
#[allow(single_use_lifetimes)]
#[allow(clippy::type_repetition_in_bounds)]
enum __EnumProjectionRef<'pin, T, U>
Copy link
Owner Author

Choose a reason for hiding this comment

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

This doesn't actually need to be generated, since we can't access the variant without naming it.
I'll optimize it in a later PR.

@taiki-e
Copy link
Owner Author

taiki-e commented Sep 7, 2020

bors r+

@bors
Copy link
Contributor

bors bot commented Sep 7, 2020

Build succeeded:

@bors bors bot merged commit 1c3844a into master Sep 7, 2020
@bors bors bot deleted the unnamed branch September 7, 2020 09:40
bors bot added a commit that referenced this pull request Sep 10, 2020
270: Optimize code generation when used on enums r=taiki-e a=taiki-e

When `#[pin_project]` is used on enums, only named projection types and methods are generated because there is no way to access variants of projected types without naming it. (When `#[pin_project]` is used on structs, both methods are always generated.)

Addresses #268 (comment)

Co-authored-by: Taiki Endo <te316e89@gmail.com>
bors bot added a commit that referenced this pull request Sep 10, 2020
270: Optimize code generation when used on enums r=taiki-e a=taiki-e

When `#[pin_project]` is used on enums, only named projection types and methods are generated because there is no way to access variants of projected types without naming it. (When `#[pin_project]` is used on structs, both methods are always generated.)

Addresses #268 (comment)

Co-authored-by: Taiki Endo <te316e89@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-pin-projection Area: #[pin_project]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant