From 57c4db34cd0ce07677f33e66c21a144f97296666 Mon Sep 17 00:00:00 2001 From: Bastian Kauschke Date: Sun, 3 May 2020 09:06:47 +0200 Subject: [PATCH] make `mem::Discriminant` invariant --- src/libcore/mem/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libcore/mem/mod.rs b/src/libcore/mem/mod.rs index b1bbcaeab8def..cef319cd10d3a 100644 --- a/src/libcore/mem/mod.rs +++ b/src/libcore/mem/mod.rs @@ -929,8 +929,9 @@ pub unsafe fn transmute_copy(src: &T) -> U { /// See the [`discriminant`] function in this module for more information. /// /// [`discriminant`]: fn.discriminant.html +// We use `PhantomData T>` because we want `Discriminant` to be invariant. #[stable(feature = "discriminant_value", since = "1.21.0")] -pub struct Discriminant(u64, PhantomData T>); +pub struct Discriminant(u64, PhantomData T>); // N.B. These trait implementations cannot be derived because we don't want any bounds on T.