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

Tracking issue for pin-project 0.4 #21

Closed
9 of 11 tasks
taiki-e opened this issue Aug 5, 2019 · 8 comments
Closed
9 of 11 tasks

Tracking issue for pin-project 0.4 #21

taiki-e opened this issue Aug 5, 2019 · 8 comments
Assignees
Milestone

Comments

@taiki-e
Copy link
Owner

taiki-e commented Aug 5, 2019

Current prerelease: 0.4.0-beta.1

The most important fix of this release is that pin projection has become a safe operation (#18, thanks @Aaron1011)

Changes

TODO

Some adjustments are needed.

Unresolved issues

Blockers

I plan to have a few alpha releases before the blockers are resolved.

@taiki-e taiki-e added this to the v0.4 milestone Aug 5, 2019
@taiki-e taiki-e self-assigned this Aug 5, 2019
@taiki-e taiki-e pinned this issue Aug 5, 2019
@taiki-e
Copy link
Owner Author

taiki-e commented Aug 6, 2019

I don't list it as a blocker, but rust-lang/rust#63281 is one of the issues to consider.

@Aaron1011
Copy link
Collaborator

Mention #32 in the documents can be checked off/removed, now that the issue is closed.

@taiki-e
Copy link
Owner Author

taiki-e commented Aug 10, 2019

@Aaron1011 thanks 👍

bors bot added a commit that referenced this issue Aug 10, 2019
33: Remove pin_project! macro and add #[pinned_drop] attribute r=taiki-e a=taiki-e

This removes `pin_project!` block and adds `#[pinned_drop]` attribute as proc-macro-attribute.
If you want a custom `Drop` implementation, you need to pass the `PinnedDrop` argument to `pin_project` attribute instead of defining items in `pin_project!` block.

In the previous implementation, `#[pinned_drop]` implemented `Drop` directly, but this PR changes it to implement this via a private unsafe trait method.

Also, this renames `pin_projectable` to `pin_project`.

cc #21, #26
Related: #18 (comment)

### Examples
Before:
```rust
use std::fmt::Debug;
use pin_project::{pin_project, pin_projectable};
use std::pin::Pin;

pin_project! {
    #[pin_projectable]
    pub struct Foo<T: Debug, U: Debug> {
        #[pin] pinned_field: T,
        unpin_field: U
    }

    #[pinned_drop]
    fn my_drop_fn<T: Debug, U: Debug>(foo: Pin<&mut Foo<T, U>>) {
        let foo = foo.project();
        println!("Dropping pinned field: {:?}", foo.pinned_field);
        println!("Dropping unpin field: {:?}", foo.unpin_field);
    }
}
```

After:
```rust
use std::fmt::Debug;
use pin_project::{pin_project, pinned_drop};
use std::pin::Pin;

#[pin_project(PinnedDrop)]
pub struct Foo<T: Debug, U: Debug> {
    #[pin] pinned_field: T,
    unpin_field: U
}

#[pinned_drop]
fn my_drop_fn<T: Debug, U: Debug>(foo: Pin<&mut Foo<T, U>>) {
    let foo = foo.project();
    println!("Dropping pinned field: {:?}", foo.pinned_field);
    println!("Dropping unpin field: {:?}", foo.unpin_field);
}
```

### TODO
- [x] Update docs



Co-authored-by: Taiki Endo <[email protected]>
bors bot added a commit that referenced this issue Aug 11, 2019
@taiki-e
Copy link
Owner Author

taiki-e commented Aug 11, 2019

Published 0.4.0-alpha.1 (crate.io, releases, docs)!

bors bot added a commit to taiki-e/futures-async-stream that referenced this issue Aug 11, 2019
13: Update pin-project to 0.4.0-alpha.1 r=taiki-e a=taiki-e

Refs: taiki-e/pin-project#21

Co-authored-by: Taiki Endo <[email protected]>
bors bot added a commit that referenced this issue Aug 13, 2019
23: Update proc-macro2, syn, and quote to 1.0 r=taiki-e a=taiki-e

cc #21

Co-authored-by: Taiki Endo <[email protected]>
@taiki-e
Copy link
Owner Author

taiki-e commented Sep 11, 2019

UPDATE: Replaced with #89

TR; DR: Added "Whether or not self: &mut Pin<&mut Self> stabilizes in Rust 1.39" (rust-lang/rust#64325) to blocker list.

rust-lang/rust#64325 stabilizes self: &mut Pin<&mut Self>.
This removes some of the hacks introduced in #47.
It can also solve some existing problems (e.g., tower-rs/tower#326 (comment)).

However, this means will take a different approach between versions prior to 1.39 and versions 1.39 or later. This should not break compatibility, but it will cause a feature that is "supported only with rust 1.39 or later". Specifically, it is a feature that "project/project_into method can be called outside the defined scope" that is planned to be provided by #80.

Also, if stabilization is delayed, the impact on crate using async / await (e.g., tower) is too big, so merge #80 to make those features available in versions 1.39 and earlier.

@taiki-e
Copy link
Owner Author

taiki-e commented Sep 11, 2019

Resolved #26 and added "Change the argument type of project method back to self: Pin<&mut Self>" (#89) to unresolved issue list.

bors bot added a commit that referenced this issue Sep 22, 2019
101: Release 0.4.0-beta.1 r=taiki-e a=taiki-e

Changes:

* [Changed the argument type of project method back to `self: Pin<&mut Self>`.][90]

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

* [Removed "renamed" feature.][100]

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

* [Added `project_ref` method and `#[project_ref]` attribute.][93]

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

cc #21

[85]: #85
[90]: #90
[93]: #93
[94]: #94
[96]: #96
[100]: #100

Co-authored-by: Taiki Endo <[email protected]>
@taiki-e taiki-e added the A-meta label Sep 24, 2019
@taiki-e
Copy link
Owner Author

taiki-e commented Sep 25, 2019

I have filed #107 to fix #102. Once #107 is merged, I will release 0.4.0. As documentation fixes are no breaking changes, will be fixed in the patch versions.

@taiki-e taiki-e added A-meta and removed A-meta labels Sep 25, 2019
@taiki-e taiki-e mentioned this issue Sep 25, 2019
bors bot added a commit that referenced this issue 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 <[email protected]>
@taiki-e
Copy link
Owner Author

taiki-e commented Sep 25, 2019

Published 0.4.0. Thanks everybody for your contribution and feedback (especially @Aaron1011!).

@taiki-e taiki-e closed this as completed Sep 25, 2019
@taiki-e taiki-e unpinned this issue Sep 25, 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

No branches or pull requests

2 participants