-
-
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
Assert lack of Drop impl without implementing Drop #48
Conversation
Previously, we would provide an empty Drop impl for types that did not provide a pinned_drop method, in order to assert that the user was not providing their own Drop impl. However, the compiler places certain restrictions on types that implement Drop. For example, you cannot move out of the fields of such types, as that would cause the Drop impl to observe the fields in an uninitialized state. This commit changes to a purely trait-based approach, as used in the assert-impl crate by @upsuper . This prevents the creation of unnecessary Drop impls, while still ensuring that the user cannot provide their own Drop impl without going through pinned_drop
Looks great to me. Could you update the documents as well?
pin-project/pin-project-internal/src/lib.rs Lines 144 to 145 in 44426ae
|
r=me with documents updated bors delegate+ |
✌️ Aaron1011 can now approve this pull request |
@taiki-e: I updated the first doc comment. I believe the second one is still accurate, as we still generate a |
96d486f
to
deea6e8
Compare
Ah, indeed. |
bors r+ |
46: Add impl block support to #[project] attribute r=taiki-e a=taiki-e This adds a feature to convert an annotated impl to a projected type's impl. Example: ```rust #[project] impl<T, U> Foo<T, U> { fn baz(self) { let Self { future, field } = self; } } // convert to: impl<'_pin, T, U> __FooProjection<'_pin, T, U> { fn baz(self) { let Self { future, field } = self; } } ``` Closes #43 cc @Nemo157 48: Assert lack of Drop impl without implementing Drop r=taiki-e a=Aaron1011 Previously, we would provide an empty Drop impl for types that did not provide a pinned_drop method, in order to assert that the user was not providing their own Drop impl. However, the compiler places certain restrictions on types that implement Drop. For example, you cannot move out of the fields of such types, as that would cause the Drop impl to observe the fields in an uninitialized state. This commit changes to a purely trait-based approach, as used in the assert-impl crate by @upsuper . This prevents the creation of unnecessary Drop impls, while still ensuring that the user cannot provide their own Drop impl without going through pinned_drop Co-authored-by: Taiki Endo <[email protected]> Co-authored-by: Aaron Hill <[email protected]>
Build succeeded
|
Previously, we would provide an empty Drop impl for types that did not
provide a pinned_drop method, in order to assert that the user was not
providing their own Drop impl.
However, the compiler places certain restrictions on types that
implement Drop. For example, you cannot move out of the fields of such
types, as that would cause the Drop impl to observe the fields in an
uninitialized state.
This commit changes to a purely trait-based approach, as used in
the assert-impl crate by @upsuper . This prevents the creation of
unnecessary Drop impls, while still ensuring that the user cannot
provide their own Drop impl without going through pinned_drop