Skip to content

Commit 57c4db3

Browse files
committed
make mem::Discriminant invariant
1 parent 7184d13 commit 57c4db3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/libcore/mem/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -929,8 +929,9 @@ pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
929929
/// See the [`discriminant`] function in this module for more information.
930930
///
931931
/// [`discriminant`]: fn.discriminant.html
932+
// We use `PhantomData<fn(T) -> T>` because we want `Discriminant` to be invariant.
932933
#[stable(feature = "discriminant_value", since = "1.21.0")]
933-
pub struct Discriminant<T>(u64, PhantomData<fn() -> T>);
934+
pub struct Discriminant<T>(u64, PhantomData<fn(T) -> T>);
934935

935936
// N.B. These trait implementations cannot be derived because we don't want any bounds on T.
936937

0 commit comments

Comments
 (0)