-
-
Notifications
You must be signed in to change notification settings - Fork 34
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
Comments
I don't list it as a blocker, but rust-lang/rust#63281 is one of the issues to consider. |
|
@Aaron1011 thanks 👍 |
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]>
42: Release 0.4.0-alpha.1 r=taiki-e a=taiki-e [Changelog](https://github.com/taiki-e/pin-project/blob/1276ad933cf5f0b2aad98a0d38fd4cbe0634090e/CHANGELOG.md#040-alpha1---2019-08-11) cc #21 Co-authored-by: Taiki Endo <[email protected]>
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]>
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]>
UPDATE: Replaced with #89 TR; DR: Added "Whether or not rust-lang/rust#64325 stabilizes 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. |
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]>
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]>
Published 0.4.0. Thanks everybody for your contribution and feedback (especially @Aaron1011!). |
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
#[unsafe_project]
has been replaced with#[pin_project]
. (Replaceunsafe_project
with safepin_projectable
attribute #18, Remove pin_project! macro and add #[pinned_drop] attribute #33)Unpin
argument has been removed - anUnpin
impl is now generated by default. (Replaceunsafe_project
with safepin_projectable
attribute #18)#[pinned_drop]
attribute instead of via a normalDrop
impl. (Replaceunsafe_project
with safepin_projectable
attribute #18, Remove pin_project! macro and add #[pinned_drop] attribute #33, Change #[pinned_drop] to trait implementation #86)Unpin
impls must be specified with an impl ofUnsafeUnpin
, instead of implementing the normalUnpin
trait. (Replaceunsafe_project
with safepin_projectable
attribute #18)ChangedEDIT: reverted in Change the argument type of project method back toproject
method generated by#[pin_project]
attribute to take an&mut Pin<&mut Self>
argument. (Make generated 'project' reference take an '&mut Pin<&mut Self>' #47)self: Pin<&mut Self>
#90#[project]
attribute (Remove "project_attr" feature and always enable #[project] attribute #94)#[project]
attribute can now be used forimpl
blocks. (Add impl block support to #[project] attribute #46)#[project]
attribute can now be used foruse
statements. (Add use statements support to #[project] attribute #85)MadeEDIT: replaced with Remove "project_attr" feature and always enable #[project] attribute #94#[project]
attribute disabled by default. (Should #[project] attribute be disabled by default? #36, Make #[project] attribute disabled by default #41)project_ref
method and#[project_ref]
attribute. (Add 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. (Determine the visibility based on the original type #96)TODO
Some adjustments are needed.
unsafe_project
with safepin_projectable
attribute #18 (comment)); done in Cleanup #22unsafe_Unpin
vsUnsafeUnpin
vsunsafe_unpin
(Replaceunsafe_project
with safepin_projectable
attribute #18 (comment)); done in Change 'unsafe_Unpin' to UpperCamelCase (UnsafeUnpin) #40 (AdoptedUnsafeUnpin
).Test code examples in README (Test code examples in README #19)EDIT: see Test code examples in README #19 (comment)repr(packed)
checking by hiding it in a proc-macro-attribute #32 in the documents; done in Ensure that #[repr(packed)] cannot be used on #[pin_projectable] structs #34Unresolved issues
Unpin
vsDrop
(Weirdly different approach toUnpin
vsDrop
#26); done in Change #[pinned_drop] to trait implementation #86self: Pin<&mut Self>
(Change the argument type of project method back toself: Pin<&mut Self>
#89)Blockers
Whether or notEDIT: replaced with Change the argument type of project method back toself: &mut Pin<&mut Self>
stabilizes in Rust 1.39 (Stabilize nested self receivers in 1.41.0 rust-lang/rust#64325)self: Pin<&mut Self>
#89I plan to have a few alpha releases before the blockers are resolved.
The text was updated successfully, but these errors were encountered: