Skip to content

Commit 068320b

Browse files
committed
Auto merge of #77893 - petertodd:2020-impl-default-for-phantompinned, r=dtolnay
Impl Default for PhantomPinned `PhantomPinned` is just a marker type, with an obvious default value (the only value). So I can't think of a reason not to do this. Sure, it's used in exotic situations with unsafe code. But the people writing that code can decide for themselves if they can derive `Default`, and in many situations the derived impl will make sense: ```rust #[derive(Default)] struct NeedsPin { marker: PhantomPinned, buf: [u8; 1024], ptr_to_data: Option<*const u8>, } ```
2 parents 1823a87 + 28f8e62 commit 068320b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

library/core/src/marker.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ pub auto trait Unpin {}
775775
///
776776
/// If a type contains a `PhantomPinned`, it will not implement `Unpin` by default.
777777
#[stable(feature = "pin", since = "1.33.0")]
778-
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
778+
#[derive(Debug, Default, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
779779
pub struct PhantomPinned;
780780

781781
#[stable(feature = "pin", since = "1.33.0")]

0 commit comments

Comments
 (0)