Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions library/core/src/marker/variance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ phantom_lifetime! {
/// For all `'a`, the following are guaranteed:
/// * `size_of::<PhantomCovariantLifetime<'a>>() == 0`
/// * `align_of::<PhantomCovariantLifetime<'a>>() == 1`
#[rustc_pub_transparent]
#[repr(transparent)]
pub struct PhantomCovariantLifetime<'a>(PhantomCovariant<&'a ()>);
/// Zero-sized type used to mark a lifetime as contravariant.
///
Expand All @@ -149,6 +151,8 @@ phantom_lifetime! {
/// For all `'a`, the following are guaranteed:
/// * `size_of::<PhantomContravariantLifetime<'a>>() == 0`
/// * `align_of::<PhantomContravariantLifetime<'a>>() == 1`
#[rustc_pub_transparent]
#[repr(transparent)]
pub struct PhantomContravariantLifetime<'a>(PhantomContravariant<&'a ()>);
/// Zero-sized type used to mark a lifetime as invariant.
///
Expand All @@ -162,6 +166,8 @@ phantom_lifetime! {
/// For all `'a`, the following are guaranteed:
/// * `size_of::<PhantomInvariantLifetime<'a>>() == 0`
/// * `align_of::<PhantomInvariantLifetime<'a>>() == 1`
#[rustc_pub_transparent]
#[repr(transparent)]
pub struct PhantomInvariantLifetime<'a>(PhantomInvariant<&'a ()>);
}

Expand All @@ -179,6 +185,8 @@ phantom_type! {
/// For all `T`, the following are guaranteed:
/// * `size_of::<PhantomCovariant<T>>() == 0`
/// * `align_of::<PhantomCovariant<T>>() == 1`
#[rustc_pub_transparent]
#[repr(transparent)]
pub struct PhantomCovariant<T>(PhantomData<fn() -> T>);
/// Zero-sized type used to mark a type parameter as contravariant.
///
Expand All @@ -193,6 +201,8 @@ phantom_type! {
/// For all `T`, the following are guaranteed:
/// * `size_of::<PhantomContravariant<T>>() == 0`
/// * `align_of::<PhantomContravariant<T>>() == 1`
#[rustc_pub_transparent]
#[repr(transparent)]
pub struct PhantomContravariant<T>(PhantomData<fn(T)>);
/// Zero-sized type used to mark a type parameter as invariant.
///
Expand All @@ -206,6 +216,8 @@ phantom_type! {
/// For all `T`, the following are guaranteed:
/// * `size_of::<PhantomInvariant<T>>() == 0`
/// * `align_of::<PhantomInvariant<T>>() == 1`
#[rustc_pub_transparent]
#[repr(transparent)]
pub struct PhantomInvariant<T>(PhantomData<fn(T) -> T>);
}

Expand Down
Loading