Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 932f7fd

Browse files
committedFeb 15, 2025
Make phantom variance markers transparent
1 parent d8810e3 commit 932f7fd

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
 

‎library/core/src/marker/variance.rs

+12
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ phantom_lifetime! {
136136
/// For all `'a`, the following are guaranteed:
137137
/// * `size_of::<PhantomCovariantLifetime<'a>>() == 0`
138138
/// * `align_of::<PhantomCovariantLifetime<'a>>() == 1`
139+
#[rustc_pub_transparent]
140+
#[repr(transparent)]
139141
pub struct PhantomCovariantLifetime<'a>(PhantomCovariant<&'a ()>);
140142
/// Zero-sized type used to mark a lifetime as contravariant.
141143
///
@@ -149,6 +151,8 @@ phantom_lifetime! {
149151
/// For all `'a`, the following are guaranteed:
150152
/// * `size_of::<PhantomContravariantLifetime<'a>>() == 0`
151153
/// * `align_of::<PhantomContravariantLifetime<'a>>() == 1`
154+
#[rustc_pub_transparent]
155+
#[repr(transparent)]
152156
pub struct PhantomContravariantLifetime<'a>(PhantomContravariant<&'a ()>);
153157
/// Zero-sized type used to mark a lifetime as invariant.
154158
///
@@ -162,6 +166,8 @@ phantom_lifetime! {
162166
/// For all `'a`, the following are guaranteed:
163167
/// * `size_of::<PhantomInvariantLifetime<'a>>() == 0`
164168
/// * `align_of::<PhantomInvariantLifetime<'a>>() == 1`
169+
#[rustc_pub_transparent]
170+
#[repr(transparent)]
165171
pub struct PhantomInvariantLifetime<'a>(PhantomInvariant<&'a ()>);
166172
}
167173

@@ -179,6 +185,8 @@ phantom_type! {
179185
/// For all `T`, the following are guaranteed:
180186
/// * `size_of::<PhantomCovariant<T>>() == 0`
181187
/// * `align_of::<PhantomCovariant<T>>() == 1`
188+
#[rustc_pub_transparent]
189+
#[repr(transparent)]
182190
pub struct PhantomCovariant<T>(PhantomData<fn() -> T>);
183191
/// Zero-sized type used to mark a type parameter as contravariant.
184192
///
@@ -193,6 +201,8 @@ phantom_type! {
193201
/// For all `T`, the following are guaranteed:
194202
/// * `size_of::<PhantomContravariant<T>>() == 0`
195203
/// * `align_of::<PhantomContravariant<T>>() == 1`
204+
#[rustc_pub_transparent]
205+
#[repr(transparent)]
196206
pub struct PhantomContravariant<T>(PhantomData<fn(T)>);
197207
/// Zero-sized type used to mark a type parameter as invariant.
198208
///
@@ -206,6 +216,8 @@ phantom_type! {
206216
/// For all `T`, the following are guaranteed:
207217
/// * `size_of::<PhantomInvariant<T>>() == 0`
208218
/// * `align_of::<PhantomInvariant<T>>() == 1`
219+
#[rustc_pub_transparent]
220+
#[repr(transparent)]
209221
pub struct PhantomInvariant<T>(PhantomData<fn(T) -> T>);
210222
}
211223

0 commit comments

Comments
 (0)
Failed to load comments.