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

Ensure that users cannot implement PinnedDrop without proper attr #180

Merged
merged 3 commits into from
Jan 27, 2020

Conversation

Aaron1011
Copy link
Collaborator

Fixes #179

Previously, it was possible to provide a #[pinned_drop] implementation
without annotating the pin-projected type with
#[pin_project(PinnedDrop)]. This would result in the PinnedDrop impl
never being used, without any warnings or errors being emitted to the
user.

This commit makes us generate a dummy PinnedDrop impl if the user does
not pass PinnedDrop as an argument to #[pin_project]. This dummy
impl will conflict with any user-provided impl, ensuring that the user
cannot accidentally a non-functional PinnedDrop impl.

Fixes taiki-e#179

Previously, it was possible to provide a `#[pinned_drop]` implementation
without annotating the pin-projected type with
`#[pin_project(PinnedDrop)]`. This would result in the `PinnedDrop` impl
never being used, without any warnings or errors being emitted to the
user.

This commit makes us generate a dummy `PinnedDrop` impl if the user does
not pass `PinnedDrop` as an argument to `#[pin_project]`. This dummy
impl will conflict with any user-provided impl, ensuring that the user
cannot accidentally a non-functional `PinnedDrop` impl.
@@ -0,0 +1,8 @@
error[E0119]: conflicting implementations of trait `pin_project::__private::PinnedDrop` for type `Foo`:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This isn't the greatest error message, but I don't see any way of improving it.

@taiki-e
Copy link
Owner

taiki-e commented Jan 27, 2020

Looks good, thanks!

bors r+

bors bot added a commit that referenced this pull request Jan 27, 2020
180: Ensure that users cannot implement `PinnedDrop` without proper attr r=taiki-e a=Aaron1011

Fixes #179

Previously, it was possible to provide a `#[pinned_drop]` implementation
without annotating the pin-projected type with
`#[pin_project(PinnedDrop)]`. This would result in the `PinnedDrop` impl
never being used, without any warnings or errors being emitted to the
user.

This commit makes us generate a dummy `PinnedDrop` impl if the user does
not pass `PinnedDrop` as an argument to `#[pin_project]`. This dummy
impl will conflict with any user-provided impl, ensuring that the user
cannot accidentally a non-functional `PinnedDrop` impl.

Co-authored-by: Aaron Hill <aa1ronham@gmail.com>
@bors
Copy link
Contributor

bors bot commented Jan 27, 2020

Build succeeded

  • style (clippy)
  • style (rustdoc)
  • style (rustfmt)
  • test (1.33.0)
  • test (1.36.0)
  • test (beta)
  • test (macos)
  • test (nightly)
  • test (stable)

@bors bors bot merged commit 124f807 into taiki-e:master Jan 27, 2020
@taiki-e taiki-e added the A-drop Area: #[pinned_drop] and Drop label May 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-drop Area: #[pinned_drop] and Drop
Projects
None yet
Development

Successfully merging this pull request may close these issues.

#[pinned_drop] is a silent no-op if (PinnedDrop) isn't added to #[pin_project]
2 participants