-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
Closed as not planned
Labels
A-pinArea: PinArea: PinC-discussionCategory: Discussion or questions that doesn't represent real issues.Category: Discussion or questions that doesn't represent real issues.
Description
The safe constructor Pin::new(pointer: Ptr) restricts the pointed object with the Unpin trait. However, this restriction can be bypassed using the literal constructor of Pin or the pin! macro.
Why not prevent this by making the literal constructor private and modifying the pin! macro as follows?
pub struct Pin<Ptr> {
__pointer: Ptr,
}
macro_rules! safe_pin {
($value:expr) => {
Pin::<&mut _>::new(&mut $value)
};
}To the best of my knowledge, the side effect is that API users can no longer create a Pin object using pin! if the object does not implement Unpin. However, developers can still use Pin::new_unchecked(pointer: Ptr) to achieve the same result. More importantly, I believe unsoundness must not be tolerated in safe Rust.
Metadata
Metadata
Assignees
Labels
A-pinArea: PinArea: PinC-discussionCategory: Discussion or questions that doesn't represent real issues.Category: Discussion or questions that doesn't represent real issues.