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

Add a dummy lifetime to Wrapper #107

Merged
merged 1 commit into from
Sep 25, 2019
Merged

Add a dummy lifetime to Wrapper #107

merged 1 commit into from
Sep 25, 2019

Conversation

taiki-e
Copy link
Owner

@taiki-e taiki-e commented Sep 25, 2019

If we know that Self doesn't implement Unpin and Self doesn't contain any
generics or lifetimes, we get an error E0277.

To avoid this, add a dummy lifetime to the Wrapper. This allows
Wrapper<Self> to always compile regardless of whether Self
implements UnsafeUnpin.

As the Wrapper implements UnsafeUnpin regardless of a lifetime, this
should not change the actual bounds of the Unpin implementation.

This allows workaround of #102 that "using pin_project(UnsafeUnpin)
and not providing a manual UnsafeUnpin implementation" to work.

Closes #102

cc @Aaron1011 @ogoffart

If we know that `Self` doesn't implement `Unpin` and `Self` doesn't contain any
generics or lifetimes, we get an error `E0277`.

To avoid this, add a dummy lifetime to the `Wrapper`. This allows
`Wrapper<Self>` to always compile regardless of whether `Self`
implements `UnsafeUnpin`.

As the `Wrapper` implements `UnsafeUnpin` regardless of a lifetime, this
should not change the actual bounds of the `Unpin` implementation.
@taiki-e
Copy link
Owner Author

taiki-e commented Sep 25, 2019

bors r+

bors bot added a commit that referenced this pull request Sep 25, 2019
107: Add a dummy lifetime to Wrapper r=taiki-e a=taiki-e

If we know that `Self` doesn't implement `Unpin` and `Self` doesn't contain any
generics or lifetimes, we get an error `E0277`.

To avoid this, add a dummy lifetime to the `Wrapper`. This allows
`Wrapper<Self>` to always compile regardless of whether `Self`
implements `UnsafeUnpin`.

As the `Wrapper` implements `UnsafeUnpin` regardless of a lifetime, this
should not change the actual bounds of the `Unpin` implementation.

This allows workaround of #102 that "using `pin_project(UnsafeUnpin)`
and not providing a manual `UnsafeUnpin` implementation" to work.

Closes #102 

cc @Aaron1011 @ogoffart

Co-authored-by: Taiki Endo <te316e89@gmail.com>
@bors
Copy link
Contributor

bors bot commented Sep 25, 2019

Build succeeded

  • taiki-e.pin-project

@bors bors bot merged commit 479b9a4 into master Sep 25, 2019
@taiki-e taiki-e deleted the issue-102 branch September 25, 2019 16:02
@taiki-e taiki-e mentioned this pull request Sep 25, 2019
bors bot added a commit that referenced this pull request Sep 25, 2019
109: Release 0.4.0 r=taiki-e a=taiki-e

cc #21

### Changes since the latest 0.3 release:

* **Pin projection has become a safe operation.** In the absence of other unsafe code that you write, it is impossible to cause undefined behavior. (#18)

* `#[unsafe_project]` attribute has been replaced with `#[pin_project]` attribute. (#18, #33)

* The `Unpin` argument has been removed - an `Unpin` impl is now generated by default. (#18)

* Drop impls must be specified with `#[pinned_drop]` instead of via a normal `Drop` impl. (#18, #33, #86)

* `Unpin` impls must be specified with an impl of `UnsafeUnpin`, instead of implementing the normal `Unpin` trait. (#18)

* `#[pin_project]` attribute now determines the visibility of the projection type/method is based on the original type. (#96)

* `#[pin_project]` can now be used for public type with private field types. (#53)

* `#[pin_project]` can now interoperate with `#[cfg()]`. (#77)

* Added `project_ref` method to `#[pin_project]` types. (#93)

* Added `#[project_ref]` attribute. (#93)

* Removed "project_attr" feature and always enable `#[project]` attribute. (#94)

* `#[project]` attribute can now be used for `impl` blocks. (#46)

* `#[project]` attribute can now be used for `use` statements. (#85)

* `#[project]` attribute now supports `match` expressions at the position of the initializer expression of `let` expressions. (#51)

### Changes since the 0.4.0-beta.1 release:

* Fixed an issue that caused an error when using `#[pin_project(UnsafeUnpin)]` and not providing a manual `UnsafeUnpin` implementation on a type with no generics or lifetime. (#107)


Co-authored-by: Taiki Endo <te316e89@gmail.com>
bors bot added a commit that referenced this pull request Sep 26, 2019
111: Add a dummy lifetime to UnpinStruct r=taiki-e a=taiki-e

Basically the same as #107.

This fixes #102 completely.

cc #108


Co-authored-by: Taiki Endo <te316e89@gmail.com>
bors bot added a commit that referenced this pull request Sep 26, 2019
111: Add a dummy lifetime to UnpinStruct r=taiki-e a=taiki-e

Basically the same as #107.

This fixes #102 completely.

cc #108


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-unpin Area: Unpin and UnsafeUnpin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

__UnpinStruct is restricting the pinned field.
1 participant