Skip to content

__UnpinStruct is restricting the pinned field. #102

Closed
@ogoffart

Description

@ogoffart

Unless I misunderstand something, it seems the logic to put the field in __UnpinStruct is reversed, as it checks that the #[pin]'ed field are Unpin.

For example:

// This structure cannot be moved
struct Property {
    pin: std::marker::PhantomPinned
}

#[pin_project::pin_project]
struct Container {
    #[pin]
    xxx : Property
}

Result in this error:

error[E0277]: the trait bound `std::marker::PhantomPinned: std::marker::Unpin` is not satisfied in `__unpin_scope_Container::__UnpinStructContainer`
   |
20 | #[pin_project::pin_project]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `__unpin_scope_Container::__UnpinStructContainer`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
   |

__UnpinStruct constraints all the pin'ed types. But I believe it should be the opposite, only the types that are not pinned should satisfy Unpin.

Metadata

Metadata

Assignees

Labels

A-unpinArea: Unpin and UnsafeUnpinC-bugCategory: related to a bug.C-enhancementCategory: A new feature or an improvement for an existing oneregression-from-0.3-to-0.4Regression from 0.3 to 0.4

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions